1 |
edhill |
1.7 |
#include "EXF_OPTIONS.h" |
2 |
heimbach |
1.2 |
|
3 |
|
|
subroutine exf_set_gen( |
4 |
heimbach |
1.10 |
& genfile, genstartdate, genperiod, |
5 |
|
|
& genstartdate1, genstartdate2, |
6 |
heimbach |
1.13 |
& exf_inscal_gen, genremove_intercept, genremove_slope, |
7 |
dimitri |
1.3 |
& genfld, gen0, gen1, genmask, |
8 |
|
|
#ifdef USE_EXF_INTERPOLATION |
9 |
|
|
& gen_lon0, gen_lon_inc, gen_lat0, gen_lat_inc, |
10 |
dimitri |
1.11 |
& gen_nlon, gen_nlat, gen_xout, gen_yout, interp_method, |
11 |
dimitri |
1.3 |
#endif |
12 |
heimbach |
1.13 |
& mytime, myiter, mythid ) |
13 |
heimbach |
1.2 |
|
14 |
|
|
c ================================================================== |
15 |
|
|
c SUBROUTINE exf_set_gen |
16 |
|
|
c ================================================================== |
17 |
|
|
c |
18 |
|
|
c o set external forcing gen |
19 |
|
|
c |
20 |
|
|
c started: Ralf.Giering@FastOpt.de 25-Mai-2000 |
21 |
|
|
c changed: heimbach@mit.edu 10-Jan-2002 |
22 |
dimitri |
1.4 |
c 20-Dec-2002: mods for pkg/seaice, menemenlis@jpl.nasa.gov |
23 |
heimbach |
1.2 |
c heimbach@mit.edu: totally re-organized exf_set_... |
24 |
|
|
c replaced all routines by one generic routine |
25 |
dimitri |
1.4 |
c 5-Aug-2003: added USE_EXF_INTERPOLATION for arbitrary |
26 |
|
|
c input grid capability |
27 |
dimitri |
1.15 |
c 11-Dec-2006 added time-mean and monthly-mean climatology options |
28 |
|
|
c genperiod=0 means input file is one time-constant field |
29 |
|
|
c genperiod=-12 means input file contains 12 monthly means |
30 |
heimbach |
1.2 |
|
31 |
|
|
c ================================================================== |
32 |
|
|
c SUBROUTINE exf_set_gen |
33 |
|
|
c ================================================================== |
34 |
|
|
|
35 |
|
|
implicit none |
36 |
|
|
|
37 |
|
|
c == global variables == |
38 |
|
|
|
39 |
|
|
#include "EEPARAMS.h" |
40 |
|
|
#include "SIZE.h" |
41 |
heimbach |
1.13 |
#include "PARAMS.h" |
42 |
heimbach |
1.2 |
#include "GRID.h" |
43 |
|
|
|
44 |
|
|
#include "exf_param.h" |
45 |
|
|
#include "exf_constants.h" |
46 |
|
|
|
47 |
|
|
c == routine arguments == |
48 |
|
|
|
49 |
heimbach |
1.10 |
integer genstartdate1, genstartdate2 |
50 |
heimbach |
1.13 |
_RL genstartdate, genperiod |
51 |
|
|
_RL exf_inscal_gen |
52 |
|
|
_RL genremove_intercept, genremove_slope |
53 |
|
|
_RL genfld(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
54 |
|
|
_RL gen0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
55 |
|
|
_RL gen1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
56 |
heimbach |
1.2 |
character*1 genmask |
57 |
dimitri |
1.16 |
character*(128) genfile |
58 |
heimbach |
1.13 |
_RL mytime |
59 |
|
|
integer myiter |
60 |
heimbach |
1.2 |
integer mythid |
61 |
dimitri |
1.16 |
|
62 |
dimitri |
1.3 |
#ifdef USE_EXF_INTERPOLATION |
63 |
dimitri |
1.4 |
c gen_lon_0 ,gen_lat_0 :: longitude and latitude of SouthWest |
64 |
|
|
c corner of global input grid |
65 |
|
|
c gen_nlon, gen_nlat :: input x-grid and y-grid size |
66 |
|
|
c gen_lon_inc :: scalar x-grid increment |
67 |
|
|
c gen_lat_inc :: vector y-grid increments |
68 |
|
|
c gen_xout, gen_yout :: coordinates for output grid |
69 |
dimitri |
1.3 |
_RL gen_lon0, gen_lon_inc |
70 |
|
|
_RL gen_lat0, gen_lat_inc(MAX_LAT_INC) |
71 |
|
|
INTEGER gen_nlon, gen_nlat |
72 |
dimitri |
1.4 |
_RS gen_xout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
73 |
|
|
_RS gen_yout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
74 |
dimitri |
1.11 |
integer interp_method |
75 |
dimitri |
1.16 |
#endif /* USE_EXF_INTERPOLATION */ |
76 |
heimbach |
1.2 |
|
77 |
|
|
c == local variables == |
78 |
|
|
|
79 |
|
|
logical first, changed |
80 |
|
|
integer count0, count1 |
81 |
heimbach |
1.10 |
integer year0, year1 |
82 |
dimitri |
1.16 |
integer bi, bj, i, j, il |
83 |
heimbach |
1.2 |
_RL fac |
84 |
dimitri |
1.16 |
character*(128) genfile0, genfile1 |
85 |
heimbach |
1.10 |
|
86 |
|
|
c == external == |
87 |
|
|
|
88 |
|
|
integer ilnblnk |
89 |
|
|
external ilnblnk |
90 |
heimbach |
1.2 |
|
91 |
|
|
c == end of interface == |
92 |
|
|
|
93 |
dimitri |
1.16 |
if ( genfile .NE. ' ' .and. genperiod .ne. 0 ) then |
94 |
heimbach |
1.2 |
|
95 |
heimbach |
1.10 |
cph( |
96 |
|
|
cph-exf-print if (genfile .EQ. hfluxfile) year0 = 3000 |
97 |
|
|
cph) |
98 |
dimitri |
1.15 |
|
99 |
dimitri |
1.16 |
if ( genperiod .eq. -12 ) then |
100 |
dimitri |
1.15 |
c genperiod=-12 means input file contains 12 monthly means |
101 |
|
|
c record numbers are assumed 1 to 12 corresponding to |
102 |
|
|
c Jan. through Dec. |
103 |
|
|
call cal_GetMonthsRec( |
104 |
|
|
O fac, first, changed, |
105 |
|
|
O count0, count1, |
106 |
|
|
I mytime, myiter, mythid |
107 |
|
|
& ) |
108 |
|
|
|
109 |
|
|
elseif ( genperiod .lt. 0 ) then |
110 |
|
|
print *, 'genperiod is out of range' |
111 |
|
|
STOP 'ABNORMAL END: S/R EXF_GETFFIELDREC' |
112 |
|
|
|
113 |
|
|
else |
114 |
heimbach |
1.2 |
c get record numbers and interpolation factor for gen |
115 |
dimitri |
1.15 |
call exf_GetFFieldRec( |
116 |
|
|
I genstartdate, genperiod |
117 |
|
|
I , genstartdate1, genstartdate2 |
118 |
|
|
I , useExfYearlyFields |
119 |
|
|
O , fac, first, changed |
120 |
|
|
O , count0, count1, year0, year1 |
121 |
|
|
I , mytime, myiter, mythid |
122 |
|
|
& ) |
123 |
|
|
|
124 |
|
|
endif |
125 |
heimbach |
1.2 |
|
126 |
|
|
if ( first ) then |
127 |
dimitri |
1.15 |
if (useExfYearlyFields.and.genperiod.gt.0) then |
128 |
dimitri |
1.12 |
C Complete filename with YR or _YEAR extension |
129 |
heimbach |
1.10 |
il = ilnblnk( genfile ) |
130 |
dimitri |
1.12 |
if (twoDigitYear) then |
131 |
|
|
if (year0.ge.2000) then |
132 |
|
|
write(genfile0(1:128),'(a,i2.2)') |
133 |
|
|
& genfile(1:il),year0-2000 |
134 |
|
|
else |
135 |
|
|
write(genfile0(1:128),'(a,i2.2)') |
136 |
|
|
& genfile(1:il),year0-1900 |
137 |
|
|
endif |
138 |
|
|
else |
139 |
|
|
write(genfile0(1:128),'(2a,i4.4)') |
140 |
|
|
& genfile(1:il),'_',year0 |
141 |
|
|
endif |
142 |
heimbach |
1.10 |
else |
143 |
|
|
genfile0 = genfile |
144 |
|
|
endif |
145 |
dimitri |
1.15 |
|
146 |
|
|
|
147 |
dimitri |
1.3 |
#ifdef USE_EXF_INTERPOLATION |
148 |
heimbach |
1.10 |
call exf_interp( genfile0, exf_iprec |
149 |
dimitri |
1.4 |
& , gen1, count0, gen_xout, gen_yout |
150 |
dimitri |
1.3 |
& , gen_lon0,gen_lon_inc |
151 |
|
|
& , gen_lat0,gen_lat_inc |
152 |
dimitri |
1.5 |
& , gen_nlon,gen_nlat,interp_method,mythid |
153 |
dimitri |
1.3 |
& ) |
154 |
|
|
#else |
155 |
heimbach |
1.10 |
call mdsreadfield( genfile0, exf_iprec, exf_yftype, 1 |
156 |
heimbach |
1.2 |
& , gen1, count0, mythid |
157 |
|
|
& ) |
158 |
dimitri |
1.16 |
#endif /* USE_EXF_INTERPOLATION */ |
159 |
heimbach |
1.2 |
|
160 |
|
|
if (exf_yftype .eq. 'RL') then |
161 |
|
|
call exf_filter_rl( gen1, genmask, mythid ) |
162 |
|
|
else |
163 |
|
|
call exf_filter_rs( gen1, genmask, mythid ) |
164 |
|
|
end if |
165 |
|
|
endif |
166 |
|
|
|
167 |
|
|
if (( first ) .or. ( changed )) then |
168 |
|
|
call exf_SwapFFields( gen0, gen1, mythid ) |
169 |
|
|
|
170 |
dimitri |
1.15 |
if (useExfYearlyFields.and.genperiod.gt.0) then |
171 |
dimitri |
1.12 |
C Complete filename with YR or _YEAR extension |
172 |
heimbach |
1.10 |
il = ilnblnk( genfile ) |
173 |
dimitri |
1.12 |
if (twoDigitYear) then |
174 |
|
|
if (year1.ge.2000) then |
175 |
|
|
write(genfile1(1:128),'(a,i2.2)') |
176 |
|
|
& genfile(1:il),year1-2000 |
177 |
|
|
else |
178 |
|
|
write(genfile1(1:128),'(a,i2.2)') |
179 |
|
|
& genfile(1:il),year1-1900 |
180 |
|
|
endif |
181 |
|
|
else |
182 |
|
|
write(genfile1(1:128),'(2a,i4.4)') |
183 |
|
|
& genfile(1:il),'_',year1 |
184 |
|
|
endif |
185 |
heimbach |
1.10 |
else |
186 |
|
|
genfile1 = genfile |
187 |
|
|
endif |
188 |
dimitri |
1.3 |
#ifdef USE_EXF_INTERPOLATION |
189 |
heimbach |
1.10 |
call exf_interp( genfile1, exf_iprec |
190 |
dimitri |
1.4 |
& , gen1, count1, gen_xout, gen_yout |
191 |
dimitri |
1.3 |
& , gen_lon0,gen_lon_inc |
192 |
|
|
& , gen_lat0,gen_lat_inc |
193 |
dimitri |
1.5 |
& , gen_nlon,gen_nlat,interp_method,mythid |
194 |
dimitri |
1.3 |
& ) |
195 |
|
|
#else |
196 |
heimbach |
1.10 |
call mdsreadfield( genfile1, exf_iprec, exf_yftype, 1 |
197 |
heimbach |
1.2 |
& , gen1, count1, mythid |
198 |
|
|
& ) |
199 |
dimitri |
1.16 |
#endif /* USE_EXF_INTERPOLATION */ |
200 |
heimbach |
1.2 |
|
201 |
|
|
if (exf_yftype .eq. 'RL') then |
202 |
|
|
call exf_filter_rl( gen1, genmask, mythid ) |
203 |
|
|
else |
204 |
|
|
call exf_filter_rs( gen1, genmask, mythid ) |
205 |
|
|
end if |
206 |
|
|
endif |
207 |
|
|
|
208 |
|
|
c Loop over tiles. |
209 |
|
|
do bj = mybylo(mythid),mybyhi(mythid) |
210 |
heimbach |
1.13 |
do bi = mybxlo(mythid),mybxhi(mythid) |
211 |
|
|
do j = 1,sny |
212 |
|
|
do i = 1,snx |
213 |
|
|
c Interpolate linearly onto the time. |
214 |
|
|
genfld(i,j,bi,bj) = exf_inscal_gen * ( |
215 |
|
|
& fac * gen0(i,j,bi,bj) + |
216 |
|
|
& (exf_one - fac) * gen1(i,j,bi,bj) ) |
217 |
|
|
genfld(i,j,bi,bj) = |
218 |
|
|
& genfld(i,j,bi,bj) - |
219 |
|
|
& exf_inscal_gen * ( genremove_intercept + |
220 |
|
|
& genremove_slope*(mytime-starttime) ) |
221 |
heimbach |
1.2 |
enddo |
222 |
|
|
enddo |
223 |
|
|
enddo |
224 |
|
|
enddo |
225 |
|
|
|
226 |
|
|
endif |
227 |
|
|
|
228 |
|
|
end |
229 |
|
|
|
230 |
|
|
|
231 |
dimitri |
1.16 |
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
232 |
|
|
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
233 |
heimbach |
1.2 |
|
234 |
|
|
subroutine exf_init_gen ( |
235 |
dimitri |
1.17 |
& genfile, genperiod, exf_inscal_gen, genmask, |
236 |
dimitri |
1.16 |
& genconst, genfld, gen0, gen1, |
237 |
|
|
#ifdef USE_EXF_INTERPOLATION |
238 |
|
|
& gen_lon0, gen_lon_inc, gen_lat0, gen_lat_inc, |
239 |
|
|
& gen_nlon, gen_nlat, gen_xout, gen_yout, interp_method, |
240 |
|
|
#endif |
241 |
|
|
& mythid ) |
242 |
|
|
|
243 |
heimbach |
1.2 |
|
244 |
|
|
c ================================================================== |
245 |
|
|
c SUBROUTINE exf_init_gen |
246 |
|
|
c ================================================================== |
247 |
|
|
c |
248 |
|
|
c o |
249 |
|
|
c |
250 |
|
|
c started: Ralf.Giering@FastOpt.de 25-Mai-2000 |
251 |
|
|
c changed: heimbach@mit.edu 10-Jan-2002 |
252 |
|
|
c heimbach@mit.edu: totally re-organized exf_set_... |
253 |
|
|
c replaced all routines by one generic routine |
254 |
|
|
c |
255 |
|
|
c ================================================================== |
256 |
|
|
c SUBROUTINE exf_init_gen |
257 |
|
|
c ================================================================== |
258 |
|
|
|
259 |
|
|
implicit none |
260 |
|
|
|
261 |
|
|
c == global variables == |
262 |
|
|
|
263 |
|
|
#include "EEPARAMS.h" |
264 |
|
|
#include "SIZE.h" |
265 |
|
|
|
266 |
|
|
#include "exf_param.h" |
267 |
|
|
|
268 |
|
|
c == routine arguments == |
269 |
|
|
|
270 |
dimitri |
1.17 |
_RL genperiod, exf_inscal_gen, genconst |
271 |
heimbach |
1.2 |
_RL genfld(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
272 |
|
|
_RL gen0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
273 |
|
|
_RL gen1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
274 |
dimitri |
1.16 |
character*1 genmask |
275 |
|
|
character*(128) genfile |
276 |
heimbach |
1.2 |
integer mythid |
277 |
|
|
|
278 |
dimitri |
1.16 |
#ifdef USE_EXF_INTERPOLATION |
279 |
|
|
c gen_lon_0 ,gen_lat_0 :: longitude and latitude of SouthWest |
280 |
|
|
c corner of global input grid |
281 |
|
|
c gen_nlon, gen_nlat :: input x-grid and y-grid size |
282 |
|
|
c gen_lon_inc :: scalar x-grid increment |
283 |
|
|
c gen_lat_inc :: vector y-grid increments |
284 |
|
|
c gen_xout, gen_yout :: coordinates for output grid |
285 |
|
|
_RL gen_lon0, gen_lon_inc |
286 |
|
|
_RL gen_lat0, gen_lat_inc(MAX_LAT_INC) |
287 |
|
|
INTEGER gen_nlon, gen_nlat |
288 |
|
|
_RS gen_xout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
289 |
|
|
_RS gen_yout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
290 |
|
|
integer interp_method |
291 |
|
|
#endif /* USE_EXF_INTERPOLATION */ |
292 |
|
|
|
293 |
heimbach |
1.2 |
c == local variables == |
294 |
|
|
|
295 |
dimitri |
1.16 |
integer bi, bj, i, j, count |
296 |
heimbach |
1.2 |
|
297 |
|
|
c == end of interface == |
298 |
|
|
|
299 |
|
|
do bj = mybylo(mythid), mybyhi(mythid) |
300 |
|
|
do bi = mybxlo(mythid), mybxhi(mythid) |
301 |
heimbach |
1.9 |
do j = 1-oly, sny+oly |
302 |
|
|
do i = 1-olx, snx+olx |
303 |
heimbach |
1.2 |
genfld(i,j,bi,bj) = genconst |
304 |
heimbach |
1.9 |
gen0(i,j,bi,bj) = genconst |
305 |
|
|
gen1(i,j,bi,bj) = genconst |
306 |
heimbach |
1.2 |
enddo |
307 |
|
|
enddo |
308 |
|
|
enddo |
309 |
|
|
enddo |
310 |
|
|
|
311 |
dimitri |
1.17 |
if ( genfile .NE. ' ' .and. genperiod .eq. 0. ) then |
312 |
dimitri |
1.16 |
count = 1 |
313 |
|
|
|
314 |
|
|
#ifdef USE_EXF_INTERPOLATION |
315 |
|
|
call exf_interp( genfile, exf_iprec |
316 |
|
|
& , genfld, count, gen_xout, gen_yout |
317 |
|
|
& , gen_lon0,gen_lon_inc |
318 |
|
|
& , gen_lat0,gen_lat_inc |
319 |
|
|
& , gen_nlon,gen_nlat,interp_method,mythid |
320 |
|
|
& ) |
321 |
|
|
#else |
322 |
|
|
call mdsreadfield( genfile, exf_iprec, exf_yftype, 1 |
323 |
|
|
& , genfld, count, mythid |
324 |
|
|
& ) |
325 |
|
|
#endif /* USE_EXF_INTERPOLATION */ |
326 |
|
|
|
327 |
|
|
if (exf_yftype .eq. 'RL') then |
328 |
|
|
call exf_filter_rl( genfld, genmask, mythid ) |
329 |
|
|
else |
330 |
|
|
call exf_filter_rs( genfld, genmask, mythid ) |
331 |
|
|
end if |
332 |
|
|
|
333 |
|
|
c Loop over tiles. |
334 |
|
|
do bj = mybylo(mythid),mybyhi(mythid) |
335 |
|
|
do bi = mybxlo(mythid),mybxhi(mythid) |
336 |
|
|
do j = 1,sny |
337 |
|
|
do i = 1,snx |
338 |
|
|
c Interpolate linearly onto the time. |
339 |
|
|
genfld(i,j,bi,bj) = |
340 |
|
|
& exf_inscal_gen * genfld(i,j,bi,bj) |
341 |
|
|
enddo |
342 |
|
|
enddo |
343 |
|
|
enddo |
344 |
|
|
enddo |
345 |
|
|
|
346 |
heimbach |
1.14 |
endif |
347 |
|
|
|
348 |
heimbach |
1.2 |
end |