-
Notifications
You must be signed in to change notification settings - Fork 1
/
test1.f
147 lines (126 loc) · 4.51 KB
/
test1.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
program readwrite
c Read surface air temperature time series from NRL and write to NetCDF.
c
c Curt Covey January 1997
c
c To compile on SGI:
c
c f77 -col120 readwrite.F -I/usr/local/grads/lats \
c -L/usr/local/grads/lats -llats \
c -L/usr/local/lib -lnetcdf
integer testmode ! yes/no (1/0) switch for running a quick test
data testmode /1/
include "lats.inc"
parameter(nyr=36,mm=nyr*12)
ccc parameter(im=144,jm=72,lm=18)
parameter(im=72,jm=45,lm=18)
dimension pr(im,jm),ps(im,jm),taux(im,jm),tauy(im,jm),
. hf(im,jm),wf(im,jm),seaice(im,jm),
. snow(im,jm)
dimension tzm(jm,lm),uzm(jm,lm),vzm(jm,lm),qzm(jm,lm)
dimension ts(im,jm,mm)
dimension tas(im,jm) ! This variable will be written to LATS.
c*cc dimension sd1(jm,lm),sd2(jm,lm)
c=================================================================
c
c NRL Coupled GCM Experiments (36-yr run)
c
c=================================================================
c
c pr precipitation (cm/day)
c ps sea-level pressure (mb)
c taux surface zonal wind stress (N/m2)
c tauy surface meridional wind stress (N/m2)
c hf net surface heat flux (W/m2)
c wf net surface freshwater flux (pr-evaporation) (cm/day)
c seaice sea ice cover (1: sea ice; 0: no sea ice)
c (Note: seaice temperatures are calculated interactively in the model,
c but seaice cover is specified from climatology)
c snow snow depth (cm)
c tzm zonal mean air temperature (degree K)
c uzm zonal mean zonal wind (m/s)
c vzm zonal mean meridional wind (m/s)
c qzm zonal mean specific humidity (g/kg)
c ts 36-yr (432-mth) lowest-layer air temperature (degree K)
c sd1 standard deviation of annual-mean zonal-mean temperature (degree K)
c sd2 standard deviation of decadal-mean zonal-mean temperature (degree K)
c
c----------------------------------------------------------------------------------------------
c Atmospheric model grid:
double precision lats(jm), lons(im)
lons(1) = 0.0
do i = 2, im
lons(i) = lons(i-1) + 5.0
enddo
lats(1)=-88.0
do j=2,jm
lats(j)=lats(j-1)+4.0
end do
print *, "Final value is ", lons(im),lats(jm)
print *, "Creating LATS grid, file and variable . . ."
idgrid = latsgrid("NRL_grid", LATS_GENERIC, im, lons, jm, lats)
ccc idgrid = latsgrid("NRL_grid", LATS_GAUSSIAN, im, lons, jm, lats)
idfile = latscreate("nrl", LATS_COARDS, LATS_STANDARD, LATS_MONTHLY, 1,
. "nrl", "Coupled Ocean-Atmosphere GCM", "prescribed seaice")
idvarb = latsvar(idfile, "tas", LATS_FLOAT, LATS_AVERAGE, idgrid, 0,
. "Precise definitions of near-surface will vary.")
if (idvarb .ne. 0) print *, "Creations appear to be successful."
if (testmode .eq. 0) then
print *, "Reading atmospheric data . . ."
open(9992,file='/pcmdi/aux2/triton1/TwoDFields/NRL/cmip_atm.dta')
c for DJF
read(9992,9901) pr,ps,taux,tauy,hf,wf,
. seaice,snow,tzm,uzm,vzm,qzm
c for JJA
read(9992,9901) pr,ps,taux,tauy,hf,wf,
. seaice,snow,tzm,uzm,vzm,qzm
read(9992,9901) ts
c*cc read(9992,9901) sd1,sd2
else
print *, "Putting 0.9's into test array . . ."
ccc do k = 1, mm
do k = 1, 1
do j = 1, jm
do i = 1, im
ts(i, j, k) = 0.9
enddo
enddo
enddo
endif
print *, "Sample value: ts(72, 36, 216) = ", ts(72, 36, 216)
print *, "Writing to LATS file . . ."
icount = 0
if (testmode .eq. 0) then
iyrmax = nyr
else
iyrmax = 1
endif
do iyr = 1, iyrmax
print *, " . . . for Year ", iyr, " . . ."
ccc do imo = 1, 12
do imo = 1, 1
icount = icount + 1
do j = 1, jm
do i = 1, im
tas(im, jm) = ts(im, jm, icount)
enddo
enddo
idreturn = latswrite(idfile, idvarb, 0.0D00, iyr, imo, 1, 0, tas)
enddo
enddo
print *, "Total count of months = ", icount
if (idreturn .eq. 1) then
print *, "Writing appears to have been successful, but file isn't closed yet."
else
print *, "WARNING: Writing appears to have been unsuccessful."
endif
idreturn = latsclose(idfile)
if (idreturn .eq. 1) then
print *, "File appears to have been closed successfully."
else
print *, "WARNING: Closing appears to have been unsuccessful."
print *, " Return code from latsclose = ", idreturn
endif
9901 format(10e13.6)
c*cc stop
end