/[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.21 - (show annotations) (download)
Wed Apr 18 19:55:34 2007 UTC (17 years, 2 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59i, checkpoint59h, checkpoint59j, checkpoint59
Changes since 1.20: +1 -2 lines
o Remove exf_clim code.
o Split exf namelist

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

  ViewVC Help
Powered by ViewVC 1.1.22