/[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.20 - (show annotations) (download)
Wed Apr 18 15:34:40 2007 UTC (17 years, 5 months ago) by heimbach
Branch: MAIN
Changes since 1.19: +3 -12 lines
Re-clean CLIM part, this time correct (I hope).

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

  ViewVC Help
Powered by ViewVC 1.1.22