forrest@0
|
1 |
;************************************************
|
forrest@0
|
2 |
; Read ascii, Write nc
|
forrest@0
|
3 |
;************************************************
|
forrest@0
|
4 |
;load "/fs/cgd/data0/shea/nclGSUN/gsn_code.ncl"
|
forrest@0
|
5 |
;load "/fs/cgd/data0/shea/nclGSUN/gsn_csm.ncl"
|
forrest@0
|
6 |
;load "/fs/cgd/data0/shea/nclGSUN/shea_util.ncl"
|
forrest@0
|
7 |
;************************************************
|
forrest@0
|
8 |
begin
|
forrest@0
|
9 |
;---------------------------------------------------
|
forrest@0
|
10 |
; final data
|
forrest@0
|
11 |
c = addfile("Npp_0.05deg_mean4.nc","c")
|
forrest@0
|
12 |
filedimdef(c,"time",-1,True)
|
forrest@0
|
13 |
|
forrest@0
|
14 |
nlat = 180*20
|
forrest@0
|
15 |
nlon = 360*20
|
forrest@0
|
16 |
|
forrest@0
|
17 |
;---------------------------------------------------
|
forrest@0
|
18 |
; input data
|
forrest@0
|
19 |
b = "Npp_0.05deg_mean.ASCII2"
|
forrest@0
|
20 |
|
forrest@0
|
21 |
t = new((/1,nlat,nlon/),float)
|
forrest@0
|
22 |
lon = new((/nlon/),float)
|
forrest@0
|
23 |
lat = new((/nlat/),float)
|
forrest@0
|
24 |
time = new((/1/),integer)
|
forrest@0
|
25 |
|
forrest@0
|
26 |
; sam result
|
forrest@0
|
27 |
; lon = fspan(-180.,179.95,nlon)
|
forrest@0
|
28 |
; lat = fspan(-90. , 89.95,nlat)
|
forrest@0
|
29 |
|
forrest@0
|
30 |
do i = 0,nlon-1
|
forrest@0
|
31 |
lon(i) = -180. + i*(360./nlon)
|
forrest@0
|
32 |
end do
|
forrest@0
|
33 |
|
forrest@0
|
34 |
do j = 0,nlat-1
|
forrest@0
|
35 |
lat(j) = -90. + j*(180./nlat)
|
forrest@0
|
36 |
end do
|
forrest@0
|
37 |
|
forrest@0
|
38 |
time = 1
|
forrest@0
|
39 |
|
forrest@0
|
40 |
; print (lon)
|
forrest@0
|
41 |
; print (lat)
|
forrest@0
|
42 |
; print (time)
|
forrest@0
|
43 |
;=============================
|
forrest@0
|
44 |
; create lat and long coordinate variables
|
forrest@0
|
45 |
;============================
|
forrest@0
|
46 |
lon!0 = "lon"
|
forrest@0
|
47 |
lon@long_name = "lon"
|
forrest@0
|
48 |
lon@units = "degrees-east"
|
forrest@0
|
49 |
lon&lon = lon
|
forrest@0
|
50 |
|
forrest@0
|
51 |
lat!0 = "lat"
|
forrest@0
|
52 |
lat@long_name = "lat"
|
forrest@0
|
53 |
lat@units = "degrees_north"
|
forrest@0
|
54 |
lat&lat = lat
|
forrest@0
|
55 |
;=============================
|
forrest@0
|
56 |
; name dimensions of t and assign coordinate variables
|
forrest@0
|
57 |
;============================
|
forrest@0
|
58 |
t!0 = "time"
|
forrest@0
|
59 |
t!1 = "lat"
|
forrest@0
|
60 |
t!2 = "lon"
|
forrest@0
|
61 |
t&time = time
|
forrest@0
|
62 |
t&lat = lat
|
forrest@0
|
63 |
t&lon = lon
|
forrest@0
|
64 |
t@long_name = "net primary production"
|
forrest@0
|
65 |
t@units = "gC/m^2/year"
|
forrest@0
|
66 |
t@_FillValue= 1.e+36
|
forrest@0
|
67 |
t@missing_value= 1.e+36
|
forrest@0
|
68 |
|
forrest@0
|
69 |
t(0,:,:) = asciiread(b,(/nlat,nlon/),"float")
|
forrest@0
|
70 |
|
forrest@0
|
71 |
c->NPP = t
|
forrest@0
|
72 |
c->lat = lat
|
forrest@0
|
73 |
c->lon = lon
|
forrest@0
|
74 |
c->time = time
|
forrest@0
|
75 |
|
forrest@0
|
76 |
do i = 0,nlon-1
|
forrest@0
|
77 |
do j = 0,nlat-1
|
forrest@0
|
78 |
if (t(0,j,i) .gt. 0.) then
|
forrest@0
|
79 |
print (t(0,j,i))
|
forrest@0
|
80 |
end if
|
forrest@0
|
81 |
end do
|
forrest@0
|
82 |
end do
|
forrest@0
|
83 |
end
|