|
1 ;************************************************************ |
|
2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
|
3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
|
4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
|
5 ;************************************************************ |
|
6 |
|
7 begin |
|
8 |
|
9 year_new = 2000 |
|
10 file_input = "1999_L4_m.nc" |
|
11 file_output = year_new+"_L4_m.nc" |
|
12 |
|
13 a = addfile(file_input,"r") |
|
14 b = addfile(file_output,"c") |
|
15 ;------------------------------------------------------------------- |
|
16 ; Enter predefine phase. |
|
17 |
|
18 ; Write global attributes to file. It's okay to do this before |
|
19 ; predefining the file's variables. We are still in "define" mode. |
|
20 |
|
21 fAtt = True |
|
22 fAtt@description = "Data read in from " + file_input |
|
23 fAtt@creation_date = systemfunc ("date") |
|
24 fileattdef( b, fAtt ) |
|
25 |
|
26 filedimdef( b,"year",-1,True) |
|
27 ;------------------------------------------------------------------- |
|
28 month_of_year = (/1,2,3,4,5,6,7,8,9,10,11,12/) |
|
29 |
|
30 Var = getfilevarnames(a) |
|
31 nVar= dimsizes(Var) |
|
32 |
|
33 ; do n = 0,nVar-1 |
|
34 ; print( (/Var(n)/)) |
|
35 ; end do |
|
36 |
|
37 do n = 0,nVar-1 |
|
38 |
|
39 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 |
|
40 |
|
41 temp = a->$Var(n)$ |
|
42 temp(0,:) = -999. |
|
43 b->$Var(n)$ = temp |
|
44 else |
|
45 |
|
46 if (Var(n).eq."year") then |
|
47 b->$Var(n)$ = year_new |
|
48 end if |
|
49 |
|
50 if (Var(n).eq."Month") then |
|
51 Month = a->$Var(n)$ |
|
52 Month(0,:)= month_of_year + year_new * 100 |
|
53 b->$Var(n)$ = Month |
|
54 end if |
|
55 |
|
56 if (Var(n).eq."n_days" .or. Var(n).eq."lat" .or. Var(n).eq."lon") then |
|
57 b->$Var(n)$ = a->$Var(n)$ |
|
58 end if |
|
59 |
|
60 end if |
|
61 end do |
|
62 |
|
63 end |