1 |
#include "EXF_OPTIONS.h" |
2 |
|
3 |
subroutine exf_set_gen( |
4 |
& genfile, genstartdate, genperiod, |
5 |
& genstartdate1, genstartdate2, |
6 |
& exf_inscal_gen, genremove_intercept, genremove_slope, |
7 |
& genfld, gen0, gen1, genmask, |
8 |
#ifdef USE_EXF_INTERPOLATION |
9 |
& gen_lon0, gen_lon_inc, gen_lat0, gen_lat_inc, |
10 |
& gen_nlon, gen_nlat, gen_xout, gen_yout, interp_method, |
11 |
#endif |
12 |
& mytime, myiter, mythid ) |
13 |
|
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 |
c 20-Dec-2002: mods for pkg/seaice, menemenlis@jpl.nasa.gov |
23 |
c heimbach@mit.edu: totally re-organized exf_set_... |
24 |
c replaced all routines by one generic routine |
25 |
c 5-Aug-2003: added USE_EXF_INTERPOLATION for arbitrary |
26 |
c input grid capability |
27 |
|
28 |
c ================================================================== |
29 |
c SUBROUTINE exf_set_gen |
30 |
c ================================================================== |
31 |
|
32 |
implicit none |
33 |
|
34 |
c == global variables == |
35 |
|
36 |
#include "EEPARAMS.h" |
37 |
#include "SIZE.h" |
38 |
#include "PARAMS.h" |
39 |
#include "GRID.h" |
40 |
|
41 |
#include "exf_param.h" |
42 |
#include "exf_constants.h" |
43 |
|
44 |
c == routine arguments == |
45 |
|
46 |
integer genstartdate1, genstartdate2 |
47 |
_RL genstartdate, genperiod |
48 |
_RL exf_inscal_gen |
49 |
_RL genremove_intercept, genremove_slope |
50 |
_RL genfld(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
51 |
_RL gen0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
52 |
_RL gen1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
53 |
character*1 genmask |
54 |
character*(128) genfile, genfile0, genfile1 |
55 |
_RL mytime |
56 |
integer myiter |
57 |
integer mythid |
58 |
#ifdef USE_EXF_INTERPOLATION |
59 |
c gen_lon_0 ,gen_lat_0 :: longitude and latitude of SouthWest |
60 |
c corner of global input grid |
61 |
c gen_nlon, gen_nlat :: input x-grid and y-grid size |
62 |
c gen_lon_inc :: scalar x-grid increment |
63 |
c gen_lat_inc :: vector y-grid increments |
64 |
c gen_xout, gen_yout :: coordinates for output grid |
65 |
_RL gen_lon0, gen_lon_inc |
66 |
_RL gen_lat0, gen_lat_inc(MAX_LAT_INC) |
67 |
INTEGER gen_nlon, gen_nlat |
68 |
_RS gen_xout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
69 |
_RS gen_yout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
70 |
integer interp_method |
71 |
#endif |
72 |
|
73 |
c == local variables == |
74 |
|
75 |
logical first, changed |
76 |
integer count0, count1 |
77 |
integer year0, year1 |
78 |
_RL fac |
79 |
|
80 |
integer bi, bj |
81 |
integer i, j, il |
82 |
|
83 |
c == external == |
84 |
|
85 |
integer ilnblnk |
86 |
external ilnblnk |
87 |
|
88 |
c == end of interface == |
89 |
|
90 |
if ( genfile .NE. ' ' ) then |
91 |
|
92 |
cph( |
93 |
cph-exf-print if (genfile .EQ. hfluxfile) year0 = 3000 |
94 |
cph) |
95 |
c get record numbers and interpolation factor for gen |
96 |
call exf_GetFFieldRec( |
97 |
I genstartdate, genperiod |
98 |
I , genstartdate1, genstartdate2 |
99 |
I , useExfYearlyFields |
100 |
O , fac, first, changed |
101 |
O , count0, count1, year0, year1 |
102 |
I , mytime, myiter, mythid |
103 |
& ) |
104 |
|
105 |
if ( first ) then |
106 |
if (useExfYearlyFields) then |
107 |
C Complete filename with YR or _YEAR extension |
108 |
il = ilnblnk( genfile ) |
109 |
if (twoDigitYear) then |
110 |
if (year0.ge.2000) then |
111 |
write(genfile0(1:128),'(a,i2.2)') |
112 |
& genfile(1:il),year0-2000 |
113 |
else |
114 |
write(genfile0(1:128),'(a,i2.2)') |
115 |
& genfile(1:il),year0-1900 |
116 |
endif |
117 |
else |
118 |
write(genfile0(1:128),'(2a,i4.4)') |
119 |
& genfile(1:il),'_',year0 |
120 |
endif |
121 |
else |
122 |
genfile0 = genfile |
123 |
endif |
124 |
#ifdef USE_EXF_INTERPOLATION |
125 |
call exf_interp( genfile0, exf_iprec |
126 |
& , gen1, count0, gen_xout, gen_yout |
127 |
& , gen_lon0,gen_lon_inc |
128 |
& , gen_lat0,gen_lat_inc |
129 |
& , gen_nlon,gen_nlat,interp_method,mythid |
130 |
& ) |
131 |
#else |
132 |
call mdsreadfield( genfile0, exf_iprec, exf_yftype, 1 |
133 |
& , gen1, count0, mythid |
134 |
& ) |
135 |
#endif |
136 |
|
137 |
if (exf_yftype .eq. 'RL') then |
138 |
call exf_filter_rl( gen1, genmask, mythid ) |
139 |
else |
140 |
call exf_filter_rs( gen1, genmask, mythid ) |
141 |
end if |
142 |
endif |
143 |
|
144 |
if (( first ) .or. ( changed )) then |
145 |
call exf_SwapFFields( gen0, gen1, mythid ) |
146 |
|
147 |
if (useExfYearlyFields) then |
148 |
C Complete filename with YR or _YEAR extension |
149 |
il = ilnblnk( genfile ) |
150 |
if (twoDigitYear) then |
151 |
if (year1.ge.2000) then |
152 |
write(genfile1(1:128),'(a,i2.2)') |
153 |
& genfile(1:il),year1-2000 |
154 |
else |
155 |
write(genfile1(1:128),'(a,i2.2)') |
156 |
& genfile(1:il),year1-1900 |
157 |
endif |
158 |
else |
159 |
write(genfile1(1:128),'(2a,i4.4)') |
160 |
& genfile(1:il),'_',year1 |
161 |
endif |
162 |
else |
163 |
genfile1 = genfile |
164 |
endif |
165 |
#ifdef USE_EXF_INTERPOLATION |
166 |
call exf_interp( genfile1, exf_iprec |
167 |
& , gen1, count1, gen_xout, gen_yout |
168 |
& , gen_lon0,gen_lon_inc |
169 |
& , gen_lat0,gen_lat_inc |
170 |
& , gen_nlon,gen_nlat,interp_method,mythid |
171 |
& ) |
172 |
#else |
173 |
call mdsreadfield( genfile1, exf_iprec, exf_yftype, 1 |
174 |
& , gen1, count1, mythid |
175 |
& ) |
176 |
#endif |
177 |
|
178 |
if (exf_yftype .eq. 'RL') then |
179 |
call exf_filter_rl( gen1, genmask, mythid ) |
180 |
else |
181 |
call exf_filter_rs( gen1, genmask, mythid ) |
182 |
end if |
183 |
endif |
184 |
|
185 |
c Loop over tiles. |
186 |
do bj = mybylo(mythid),mybyhi(mythid) |
187 |
do bi = mybxlo(mythid),mybxhi(mythid) |
188 |
do j = 1,sny |
189 |
do i = 1,snx |
190 |
c Interpolate linearly onto the time. |
191 |
genfld(i,j,bi,bj) = exf_inscal_gen * ( |
192 |
& fac * gen0(i,j,bi,bj) + |
193 |
& (exf_one - fac) * gen1(i,j,bi,bj) ) |
194 |
genfld(i,j,bi,bj) = |
195 |
& genfld(i,j,bi,bj) - |
196 |
& exf_inscal_gen * ( genremove_intercept + |
197 |
& genremove_slope*(mytime-starttime) ) |
198 |
enddo |
199 |
enddo |
200 |
enddo |
201 |
enddo |
202 |
|
203 |
endif |
204 |
|
205 |
end |
206 |
|
207 |
|
208 |
|
209 |
subroutine exf_init_gen ( |
210 |
& genconst, genfld, gen0, gen1, geninitfile, mythid ) |
211 |
|
212 |
c ================================================================== |
213 |
c SUBROUTINE exf_init_gen |
214 |
c ================================================================== |
215 |
c |
216 |
c o |
217 |
c |
218 |
c started: Ralf.Giering@FastOpt.de 25-Mai-2000 |
219 |
c changed: heimbach@mit.edu 10-Jan-2002 |
220 |
c heimbach@mit.edu: totally re-organized exf_set_... |
221 |
c replaced all routines by one generic routine |
222 |
c |
223 |
c ================================================================== |
224 |
c SUBROUTINE exf_init_gen |
225 |
c ================================================================== |
226 |
|
227 |
implicit none |
228 |
|
229 |
c == global variables == |
230 |
|
231 |
#include "EEPARAMS.h" |
232 |
#include "SIZE.h" |
233 |
|
234 |
#include "exf_param.h" |
235 |
|
236 |
c == routine arguments == |
237 |
|
238 |
_RL genconst |
239 |
_RL genfld(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
240 |
_RL gen0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
241 |
_RL gen1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
242 |
character*(128) geninitfile |
243 |
integer mythid |
244 |
|
245 |
c == local variables == |
246 |
|
247 |
integer bi, bj |
248 |
integer i, j |
249 |
|
250 |
c == end of interface == |
251 |
|
252 |
do bj = mybylo(mythid), mybyhi(mythid) |
253 |
do bi = mybxlo(mythid), mybxhi(mythid) |
254 |
do j = 1-oly, sny+oly |
255 |
do i = 1-olx, snx+olx |
256 |
genfld(i,j,bi,bj) = genconst |
257 |
gen0(i,j,bi,bj) = genconst |
258 |
gen1(i,j,bi,bj) = genconst |
259 |
enddo |
260 |
enddo |
261 |
enddo |
262 |
enddo |
263 |
|
264 |
if ( geninitfile .NE. ' ' ) then |
265 |
call mdsreadfield( geninitfile, exf_iprec, exf_yftype, |
266 |
& 1, genfld, 1, mythid ) |
267 |
endif |
268 |
|
269 |
end |