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: forrest@0: begin forrest@0: forrest@0: year_new = 2000 forrest@0: file_input = "1999_L4_m.nc" forrest@0: file_output = year_new+"_L4_m.nc" forrest@0: forrest@0: a = addfile(file_input,"r") forrest@0: b = addfile(file_output,"c") forrest@0: ;------------------------------------------------------------------- forrest@0: ; Enter predefine phase. forrest@0: forrest@0: ; Write global attributes to file. It's okay to do this before forrest@0: ; predefining the file's variables. We are still in "define" mode. forrest@0: forrest@0: fAtt = True forrest@0: fAtt@description = "Data read in from " + file_input forrest@0: fAtt@creation_date = systemfunc ("date") forrest@0: fileattdef( b, fAtt ) forrest@0: forrest@0: filedimdef( b,"year",-1,True) forrest@0: ;------------------------------------------------------------------- forrest@0: month_of_year = (/1,2,3,4,5,6,7,8,9,10,11,12/) forrest@0: forrest@0: Var = getfilevarnames(a) forrest@0: nVar= dimsizes(Var) forrest@0: forrest@0: ; do n = 0,nVar-1 forrest@0: ; print( (/Var(n)/)) forrest@0: ; end do forrest@0: forrest@0: do n = 0,nVar-1 forrest@0: forrest@0: if (Var(n).ne."year" .and. Var(n).ne."Month" .and. Var(n).ne."n_days" .and. Var(n).ne."lat" .and. Var(n).ne."lon" ) then forrest@0: forrest@0: temp = a->$Var(n)$ forrest@0: temp(0,:) = -999. forrest@0: b->$Var(n)$ = temp forrest@0: else forrest@0: forrest@0: if (Var(n).eq."year") then forrest@0: b->$Var(n)$ = year_new forrest@0: end if forrest@0: forrest@0: if (Var(n).eq."Month") then forrest@0: Month = a->$Var(n)$ forrest@0: Month(0,:)= month_of_year + year_new * 100 forrest@0: b->$Var(n)$ = Month forrest@0: end if forrest@0: forrest@0: if (Var(n).eq."n_days" .or. Var(n).eq."lat" .or. Var(n).eq."lon") then forrest@0: b->$Var(n)$ = a->$Var(n)$ forrest@0: end if forrest@0: forrest@0: end if forrest@0: end do forrest@0: forrest@0: end