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