forrest@1: ;************************************************ forrest@1: ; Read ascii, Write nc forrest@1: ; output: lat: N->S lon: -180W->180E forrest@1: ;************************************************ forrest@1: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" forrest@1: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" forrest@1: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" forrest@1: ;************************************************ forrest@1: begin forrest@1: forrest@1: ; output forrest@1: forrest@1: model_name = "i01.43cn" forrest@1: forrest@1: ;diro = "/ptmp/jeff/" forrest@1: diro = "/lustre/wolf-ddn/scratch/hof/cases1/i01.43cn_out/" forrest@1: filo = model_name + "_ameriflux_2876-2900_monthly.nc" forrest@1: c = addfile(diro+filo,"c") forrest@1: filedimdef(c,"year",-1,True) forrest@1: forrest@1: ; input data forrest@1: forrest@1: nlat = 96 forrest@1: nlon = 144 forrest@1: forrest@1: year_start = 2876 forrest@1: year_end = 2900 forrest@1: forrest@1: nyear = year_end - year_start + 1 forrest@1: nmonth = 12 forrest@1: forrest@1: data1 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data2 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data3 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: ;data4 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: ;data5 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data6 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data7 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data8 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data9 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: data10 = new((/nyear,nmonth,nlat,nlon/),float) forrest@1: date = new((/nyear,nmonth/),integer) forrest@1: forrest@1: ; name dimensions and assign coordinate variables forrest@1: forrest@1: data1!0 ="year" forrest@1: data1!1 ="month" forrest@1: data1!2 = "lat" forrest@1: data1!3 = "lon" forrest@1: forrest@1: data2!0 ="year" forrest@1: data2!1 ="month" forrest@1: data2!2 = "lat" forrest@1: data2!3 = "lon" forrest@1: forrest@1: data3!0 ="year" forrest@1: data3!1 ="month" forrest@1: data3!2 = "lat" forrest@1: data3!3 = "lon" forrest@1: forrest@1: ;data4!0 ="year" forrest@1: ;data4!1 ="month" forrest@1: ;data4!2 = "lat" forrest@1: ;data4!3 = "lon" forrest@1: forrest@1: ;data5!0 ="year" forrest@1: ;data5!1 ="month" forrest@1: ;data5!2 = "lat" forrest@1: ;data5!3 = "lon" forrest@1: forrest@1: data6!0 ="year" forrest@1: data6!1 ="month" forrest@1: data6!2 = "lat" forrest@1: data6!3 = "lon" forrest@1: forrest@1: data7!0 ="year" forrest@1: data7!1 ="month" forrest@1: data7!2 = "lat" forrest@1: data7!3 = "lon" forrest@1: forrest@1: data8!0 ="year" forrest@1: data8!1 ="month" forrest@1: data8!2 = "lat" forrest@1: data8!3 = "lon" forrest@1: forrest@1: data9!0 ="year" forrest@1: data9!1 ="month" forrest@1: data9!2 = "lat" forrest@1: data9!3 = "lon" forrest@1: forrest@1: data10!0 ="year" forrest@1: data10!1 ="month" forrest@1: data10!2 = "lat" forrest@1: data10!3 = "lon" forrest@1: forrest@1: date!0 ="year" forrest@1: date!1 ="month" forrest@1: date@long_name = "date: yyyymm" forrest@1: forrest@1: ; input dir forrest@1: diri = "/lustre/wolf-ddn/scratch/hof/cases1/"+model_name+"/" forrest@1: forrest@1: do m = 0,nyear-1 forrest@1: year = year_start + m forrest@1: do n = 0,nmonth-1 forrest@1: nn = n+1 forrest@1: date(m,n) = year*100 +nn forrest@1: forrest@1: ; input file forrest@1: if (nn .ge. 10) then forrest@1: fili = model_name+".clm2.h0."+year+"-"+nn+".nc" forrest@1: else forrest@1: fili = model_name+".clm2.h0."+year+"-0"+nn+".nc" forrest@1: end if forrest@1: forrest@1: print (fili) forrest@1: forrest@1: g = addfile (diri+fili,"r") forrest@1: forrest@1: b = g->NEE forrest@1: data1(m,n,:,:) = (/b(0,:,:)/) forrest@1: data1@long_name = b@long_name forrest@1: data1@units = b@units forrest@1: data1@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: b = g->GPP forrest@1: data2(m,n,:,:) = (/b(0,:,:)/) forrest@1: data2@long_name = b@long_name forrest@1: data2@units = b@units forrest@1: data2@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: b = g->ER forrest@1: data3(m,n,:,:) = (/b(0,:,:)/) forrest@1: data3@long_name = b@long_name forrest@1: data3@units = b@units forrest@1: data3@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: ;b = g->NETRAD forrest@1: ;data4(m,n,:,:) = (/b(0,:,:)/) forrest@1: ;data4@long_name = b@long_name forrest@1: ;data4@units = b@units forrest@1: ;data4@_FillValue = b@_FillValue forrest@1: ;delete (b) forrest@1: forrest@1: ;b = g->LATENT forrest@1: ;data5(m,n,:,:) = (/b(0,:,:)/) forrest@1: ;data5@long_name = b@long_name forrest@1: ;data5@units = b@units forrest@1: ;data5@_FillValue = b@_FillValue forrest@1: ;delete (b) forrest@1: forrest@1: b = g->FSH forrest@1: data6(m,n,:,:) = (/b(0,:,:)/) forrest@1: data6@long_name = b@long_name forrest@1: data6@units = b@units forrest@1: data6@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: b = g->FSDS forrest@1: data7(m,n,:,:) = (/b(0,:,:)/) forrest@1: data7@long_name = b@long_name forrest@1: data7@units = b@units forrest@1: data7@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: b = g->FCEV forrest@1: data8(m,n,:,:) = (/b(0,:,:)/) forrest@1: data8@long_name = b@long_name forrest@1: data8@units = b@units forrest@1: data8@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: b = g->FCTR forrest@1: data9(m,n,:,:) = (/b(0,:,:)/) forrest@1: data9@long_name = b@long_name forrest@1: data9@units = b@units forrest@1: data9@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: b = g->FGEV forrest@1: data10(m,n,:,:) = (/b(0,:,:)/) forrest@1: data10@long_name = b@long_name forrest@1: data10@units = b@units forrest@1: data10@_FillValue = b@_FillValue forrest@1: delete (b) forrest@1: forrest@1: end do forrest@1: end do forrest@1: forrest@1: c->NEE = data1 forrest@1: c->GPP = data2 forrest@1: c->ER = data3 forrest@1: ;c->NETRAD = data4 forrest@1: ;c->LATENT = data5 forrest@1: c->FSH = data6 forrest@1: c->FSDS = data7 forrest@1: c->FCEV = data8 forrest@1: c->FCTR = data9 forrest@1: c->FGEV = data10 forrest@1: c->date = date forrest@1: c->area = g->area forrest@1: forrest@1: print (date) forrest@1: forrest@1: end