forrest@0
|
1 |
;************************************************
|
forrest@0
|
2 |
; Read ascii, Write nc
|
forrest@0
|
3 |
; output: lat: N->S lon: -180W->180E
|
forrest@0
|
4 |
;************************************************
|
forrest@0
|
5 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@0
|
6 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@0
|
7 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@0
|
8 |
;************************************************
|
forrest@0
|
9 |
begin
|
forrest@0
|
10 |
|
forrest@0
|
11 |
; output
|
forrest@0
|
12 |
|
forrest@0
|
13 |
model_name = "i01.10cn"
|
forrest@0
|
14 |
|
forrest@0
|
15 |
diro = "/ptmp/jeff/"
|
forrest@0
|
16 |
filo = model_name + "_ameriflux_1990-2004_monthly.nc"
|
forrest@0
|
17 |
c = addfile(diro+filo,"c")
|
forrest@0
|
18 |
filedimdef(c,"year",-1,True)
|
forrest@0
|
19 |
|
forrest@0
|
20 |
; input data
|
forrest@0
|
21 |
|
forrest@0
|
22 |
nlat = 64
|
forrest@0
|
23 |
nlon = 128
|
forrest@0
|
24 |
|
forrest@0
|
25 |
year_start = 1990
|
forrest@0
|
26 |
year_end = 2004
|
forrest@0
|
27 |
|
forrest@0
|
28 |
nyear = year_end - year_start + 1
|
forrest@0
|
29 |
nmonth = 12
|
forrest@0
|
30 |
|
forrest@0
|
31 |
data1 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
32 |
data2 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
33 |
data3 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
34 |
data4 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
35 |
data5 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
36 |
data6 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
37 |
data7 = new((/nyear,nmonth,nlat,nlon/),float)
|
forrest@0
|
38 |
date = new((/nyear,nmonth/),integer)
|
forrest@0
|
39 |
|
forrest@0
|
40 |
; name dimensions and assign coordinate variables
|
forrest@0
|
41 |
|
forrest@0
|
42 |
data1!0 ="year"
|
forrest@0
|
43 |
data1!1 ="month"
|
forrest@0
|
44 |
data1!2 = "lat"
|
forrest@0
|
45 |
data1!3 = "lon"
|
forrest@0
|
46 |
|
forrest@0
|
47 |
data2!0 ="year"
|
forrest@0
|
48 |
data2!1 ="month"
|
forrest@0
|
49 |
data2!2 = "lat"
|
forrest@0
|
50 |
data2!3 = "lon"
|
forrest@0
|
51 |
|
forrest@0
|
52 |
data3!0 ="year"
|
forrest@0
|
53 |
data3!1 ="month"
|
forrest@0
|
54 |
data3!2 = "lat"
|
forrest@0
|
55 |
data3!3 = "lon"
|
forrest@0
|
56 |
|
forrest@0
|
57 |
data4!0 ="year"
|
forrest@0
|
58 |
data4!1 ="month"
|
forrest@0
|
59 |
data4!2 = "lat"
|
forrest@0
|
60 |
data4!3 = "lon"
|
forrest@0
|
61 |
|
forrest@0
|
62 |
data5!0 ="year"
|
forrest@0
|
63 |
data5!1 ="month"
|
forrest@0
|
64 |
data5!2 = "lat"
|
forrest@0
|
65 |
data5!3 = "lon"
|
forrest@0
|
66 |
|
forrest@0
|
67 |
data6!0 ="year"
|
forrest@0
|
68 |
data6!1 ="month"
|
forrest@0
|
69 |
data6!2 = "lat"
|
forrest@0
|
70 |
data6!3 = "lon"
|
forrest@0
|
71 |
|
forrest@0
|
72 |
data7!0 ="year"
|
forrest@0
|
73 |
data7!1 ="month"
|
forrest@0
|
74 |
data7!2 = "lat"
|
forrest@0
|
75 |
data7!3 = "lon"
|
forrest@0
|
76 |
|
forrest@0
|
77 |
date!0 ="year"
|
forrest@0
|
78 |
date!1 ="month"
|
forrest@0
|
79 |
date@long_name = "date: yyyymm"
|
forrest@0
|
80 |
|
forrest@0
|
81 |
; input dir
|
forrest@0
|
82 |
diri = "/ptmp/jeff/"+model_name+"/"
|
forrest@0
|
83 |
|
forrest@0
|
84 |
do m = 0,nyear-1
|
forrest@0
|
85 |
year = year_start + m
|
forrest@0
|
86 |
do n = 0,nmonth-1
|
forrest@0
|
87 |
nn = n+1
|
forrest@0
|
88 |
date(m,n) = year*100 +nn
|
forrest@0
|
89 |
|
forrest@0
|
90 |
; input file
|
forrest@0
|
91 |
if (nn .ge. 10) then
|
forrest@0
|
92 |
fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
|
forrest@0
|
93 |
else
|
forrest@0
|
94 |
fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
|
forrest@0
|
95 |
end if
|
forrest@0
|
96 |
|
forrest@0
|
97 |
print (fili)
|
forrest@0
|
98 |
|
forrest@0
|
99 |
g = addfile (diri+fili,"r")
|
forrest@0
|
100 |
|
forrest@0
|
101 |
b = g->NEE
|
forrest@0
|
102 |
data1(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
103 |
data1@long_name = b@long_name
|
forrest@0
|
104 |
data1@units = b@units
|
forrest@0
|
105 |
data1@_FillValue = b@_FillValue
|
forrest@0
|
106 |
delete (b)
|
forrest@0
|
107 |
|
forrest@0
|
108 |
b = g->GPP
|
forrest@0
|
109 |
data2(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
110 |
data2@long_name = b@long_name
|
forrest@0
|
111 |
data2@units = b@units
|
forrest@0
|
112 |
data2@_FillValue = b@_FillValue
|
forrest@0
|
113 |
delete (b)
|
forrest@0
|
114 |
|
forrest@0
|
115 |
b = g->ER
|
forrest@0
|
116 |
data3(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
117 |
data3@long_name = b@long_name
|
forrest@0
|
118 |
data3@units = b@units
|
forrest@0
|
119 |
data3@_FillValue = b@_FillValue
|
forrest@0
|
120 |
delete (b)
|
forrest@0
|
121 |
|
forrest@0
|
122 |
b = g->NETRAD
|
forrest@0
|
123 |
data4(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
124 |
data4@long_name = b@long_name
|
forrest@0
|
125 |
data4@units = b@units
|
forrest@0
|
126 |
data4@_FillValue = b@_FillValue
|
forrest@0
|
127 |
delete (b)
|
forrest@0
|
128 |
|
forrest@0
|
129 |
b = g->LATENT
|
forrest@0
|
130 |
data5(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
131 |
data5@long_name = b@long_name
|
forrest@0
|
132 |
data5@units = b@units
|
forrest@0
|
133 |
data5@_FillValue = b@_FillValue
|
forrest@0
|
134 |
delete (b)
|
forrest@0
|
135 |
|
forrest@0
|
136 |
b = g->FSH
|
forrest@0
|
137 |
data6(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
138 |
data6@long_name = b@long_name
|
forrest@0
|
139 |
data6@units = b@units
|
forrest@0
|
140 |
data6@_FillValue = b@_FillValue
|
forrest@0
|
141 |
delete (b)
|
forrest@0
|
142 |
|
forrest@0
|
143 |
b = g->FSDS
|
forrest@0
|
144 |
data7(m,n,:,:) = (/b(0,:,:)/)
|
forrest@0
|
145 |
data7@long_name = b@long_name
|
forrest@0
|
146 |
data7@units = b@units
|
forrest@0
|
147 |
data7@_FillValue = b@_FillValue
|
forrest@0
|
148 |
delete (b)
|
forrest@0
|
149 |
|
forrest@0
|
150 |
end do
|
forrest@0
|
151 |
end do
|
forrest@0
|
152 |
|
forrest@0
|
153 |
c->NEE = data1
|
forrest@0
|
154 |
c->GPP = data2
|
forrest@0
|
155 |
c->ER = data3
|
forrest@0
|
156 |
c->NETRAD = data4
|
forrest@0
|
157 |
c->LATENT = data5
|
forrest@0
|
158 |
c->FSH = data6
|
forrest@0
|
159 |
c->FSDS = data7
|
forrest@0
|
160 |
c->date = date
|
forrest@0
|
161 |
c->area = g->area
|
forrest@0
|
162 |
|
forrest@0
|
163 |
print (date)
|
forrest@0
|
164 |
|
forrest@0
|
165 |
end
|