/[MITgcm]/MITgcm/pkg/exf/exf_set_gen.F
ViewVC logotype

Contents of /MITgcm/pkg/exf/exf_set_gen.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.17 - (show annotations) (download)
Fri Feb 9 04:53:52 2007 UTC (17 years, 4 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint58w_post, checkpoint58x_post, checkpoint58y_post
Changes since 1.16: +3 -4 lines
exf_set_init reads a file only if genperiod .eq. 0

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 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
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 #include "PARAMS.h"
42 #include "GRID.h"
43
44 #include "exf_param.h"
45 #include "exf_constants.h"
46
47 c == routine arguments ==
48
49 integer genstartdate1, genstartdate2
50 _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 character*1 genmask
57 character*(128) genfile
58 _RL mytime
59 integer myiter
60 integer mythid
61
62 #ifdef USE_EXF_INTERPOLATION
63 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 _RL gen_lon0, gen_lon_inc
70 _RL gen_lat0, gen_lat_inc(MAX_LAT_INC)
71 INTEGER gen_nlon, gen_nlat
72 _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 integer interp_method
75 #endif /* USE_EXF_INTERPOLATION */
76
77 c == local variables ==
78
79 logical first, changed
80 integer count0, count1
81 integer year0, year1
82 integer bi, bj, i, j, il
83 _RL fac
84 character*(128) genfile0, genfile1
85
86 c == external ==
87
88 integer ilnblnk
89 external ilnblnk
90
91 c == end of interface ==
92
93 if ( genfile .NE. ' ' .and. genperiod .ne. 0 ) then
94
95 cph(
96 cph-exf-print if (genfile .EQ. hfluxfile) year0 = 3000
97 cph)
98
99 if ( genperiod .eq. -12 ) then
100 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 c get record numbers and interpolation factor for gen
115 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
126 if ( first ) then
127 if (useExfYearlyFields.and.genperiod.gt.0) then
128 C Complete filename with YR or _YEAR extension
129 il = ilnblnk( genfile )
130 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 else
143 genfile0 = genfile
144 endif
145
146
147 #ifdef USE_EXF_INTERPOLATION
148 call exf_interp( genfile0, exf_iprec
149 & , gen1, count0, gen_xout, gen_yout
150 & , gen_lon0,gen_lon_inc
151 & , gen_lat0,gen_lat_inc
152 & , gen_nlon,gen_nlat,interp_method,mythid
153 & )
154 #else
155 call mdsreadfield( genfile0, exf_iprec, exf_yftype, 1
156 & , gen1, count0, mythid
157 & )
158 #endif /* USE_EXF_INTERPOLATION */
159
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 if (useExfYearlyFields.and.genperiod.gt.0) then
171 C Complete filename with YR or _YEAR extension
172 il = ilnblnk( genfile )
173 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 else
186 genfile1 = genfile
187 endif
188 #ifdef USE_EXF_INTERPOLATION
189 call exf_interp( genfile1, exf_iprec
190 & , gen1, count1, gen_xout, gen_yout
191 & , gen_lon0,gen_lon_inc
192 & , gen_lat0,gen_lat_inc
193 & , gen_nlon,gen_nlat,interp_method,mythid
194 & )
195 #else
196 call mdsreadfield( genfile1, exf_iprec, exf_yftype, 1
197 & , gen1, count1, mythid
198 & )
199 #endif /* USE_EXF_INTERPOLATION */
200
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 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 enddo
222 enddo
223 enddo
224 enddo
225
226 endif
227
228 end
229
230
231 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
232 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
233
234 subroutine exf_init_gen (
235 & genfile, genperiod, exf_inscal_gen, genmask,
236 & 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
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 _RL genperiod, exf_inscal_gen, genconst
271 _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 character*1 genmask
275 character*(128) genfile
276 integer mythid
277
278 #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 c == local variables ==
294
295 integer bi, bj, i, j, count
296
297 c == end of interface ==
298
299 do bj = mybylo(mythid), mybyhi(mythid)
300 do bi = mybxlo(mythid), mybxhi(mythid)
301 do j = 1-oly, sny+oly
302 do i = 1-olx, snx+olx
303 genfld(i,j,bi,bj) = genconst
304 gen0(i,j,bi,bj) = genconst
305 gen1(i,j,bi,bj) = genconst
306 enddo
307 enddo
308 enddo
309 enddo
310
311 if ( genfile .NE. ' ' .and. genperiod .eq. 0. ) then
312 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 endif
347
348 end

  ViewVC Help
Powered by ViewVC 1.1.22