forrest@0: ;************************************************ forrest@0: ; Read ascii, Write nc forrest@0: ; output: lat: N->S lon: -180W->180E forrest@0: ;************************************************ forrest@0: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" forrest@0: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" forrest@0: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" forrest@0: ;************************************************ forrest@0: begin forrest@0: forrest@0: ; output forrest@0: forrest@0: model_name = "i01.10casa" forrest@0: forrest@0: diro = "/ptmp/jeff/" forrest@0: filo = model_name + "_ameriflux_1990-2004_monthly.nc" forrest@0: c = addfile(diro+filo,"c") forrest@0: filedimdef(c,"year",-1,True) forrest@0: forrest@0: ; input data forrest@0: forrest@0: nlat = 64 forrest@0: nlon = 128 forrest@0: forrest@0: year_start = 1990 forrest@0: year_end = 2004 forrest@0: forrest@0: nyear = year_end - year_start + 1 forrest@0: nmonth = 12 forrest@0: forrest@0: data1 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: data2 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: data3 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: data4 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: data5 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: data6 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: data7 = new((/nyear,nmonth,nlat,nlon/),float) forrest@0: date = new((/nyear,nmonth/),integer) forrest@0: forrest@0: ; name dimensions and assign coordinate variables forrest@0: forrest@0: data1!0 ="year" forrest@0: data1!1 ="month" forrest@0: data1!2 = "lat" forrest@0: data1!3 = "lon" forrest@0: forrest@0: data2!0 ="year" forrest@0: data2!1 ="month" forrest@0: data2!2 = "lat" forrest@0: data2!3 = "lon" forrest@0: forrest@0: data3!0 ="year" forrest@0: data3!1 ="month" forrest@0: data3!2 = "lat" forrest@0: data3!3 = "lon" forrest@0: forrest@0: data4!0 ="year" forrest@0: data4!1 ="month" forrest@0: data4!2 = "lat" forrest@0: data4!3 = "lon" forrest@0: forrest@0: data5!0 ="year" forrest@0: data5!1 ="month" forrest@0: data5!2 = "lat" forrest@0: data5!3 = "lon" forrest@0: forrest@0: data6!0 ="year" forrest@0: data6!1 ="month" forrest@0: data6!2 = "lat" forrest@0: data6!3 = "lon" forrest@0: forrest@0: data7!0 ="year" forrest@0: data7!1 ="month" forrest@0: data7!2 = "lat" forrest@0: data7!3 = "lon" forrest@0: forrest@0: date!0 ="year" forrest@0: date!1 ="month" forrest@0: date@long_name = "date: yyyymm" forrest@0: forrest@0: ; input dir forrest@0: diri = "/ptmp/jeff/"+model_name+"/" forrest@0: forrest@0: do m = 0,nyear-1 forrest@0: year = year_start + m forrest@0: do n = 0,nmonth-1 forrest@0: nn = n+1 forrest@0: date(m,n) = year*100 +nn forrest@0: forrest@0: ; input file forrest@0: if (nn .ge. 10) then forrest@0: fili = model_name+".clm2.h0."+year+"-"+nn+".nc" forrest@0: else forrest@0: fili = model_name+".clm2.h0."+year+"-0"+nn+".nc" forrest@0: end if forrest@0: forrest@0: print (fili) forrest@0: forrest@0: g = addfile (diri+fili,"r") forrest@0: forrest@0: b = g->NEE forrest@0: data1(m,n,:,:) = (/b(0,:,:)/) forrest@0: data1@long_name = b@long_name forrest@0: data1@units = b@units forrest@0: data1@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: b = g->GPP forrest@0: data2(m,n,:,:) = (/b(0,:,:)/) forrest@0: data2@long_name = b@long_name forrest@0: data2@units = b@units forrest@0: data2@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: b = g->AR forrest@0: data3(m,n,:,:) = (/b(0,:,:)/) forrest@0: b = g->HR forrest@0: data3(m,n,:,:) = data3(m,n,:,:)+(/b(0,:,:)/) forrest@0: data3@long_name = "total ecosystem respiration, autotrophic + heterotrophic" forrest@0: data3@units = b@units forrest@0: data3@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: b = g->NETRAD forrest@0: data4(m,n,:,:) = (/b(0,:,:)/) forrest@0: data4@long_name = b@long_name forrest@0: data4@units = b@units forrest@0: data4@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: b = g->LATENT forrest@0: data5(m,n,:,:) = (/b(0,:,:)/) forrest@0: data5@long_name = b@long_name forrest@0: data5@units = b@units forrest@0: data5@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: b = g->FSH forrest@0: data6(m,n,:,:) = (/b(0,:,:)/) forrest@0: data6@long_name = b@long_name forrest@0: data6@units = b@units forrest@0: data6@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: b = g->FSDS forrest@0: data7(m,n,:,:) = (/b(0,:,:)/) forrest@0: data7@long_name = b@long_name forrest@0: data7@units = b@units forrest@0: data7@_FillValue = b@_FillValue forrest@0: delete (b) forrest@0: forrest@0: end do forrest@0: end do forrest@0: forrest@0: c->NEE = data1 forrest@0: c->GPP = data2 forrest@0: c->ER = data3 forrest@0: c->NETRAD = data4 forrest@0: c->LATENT = data5 forrest@0: c->FSH = data6 forrest@0: c->FSDS = data7 forrest@0: c->date = date forrest@0: c->area = g->area forrest@0: forrest@0: print (date) forrest@0: forrest@0: end