/[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.19 - (show annotations) (download)
Wed Apr 18 13:24:28 2007 UTC (17 years, 1 month ago) by heimbach
Branch: MAIN
Changes since 1.18: +10 -1 lines
Re-instating some CLIM stuff until fixing exf_getclim.F

1 C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_set_gen.F,v 1.18 2007/04/16 23:27:21 jmc 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
151 #ifdef USE_EXF_INTERPOLATION
152 call exf_interp( genfile0, exf_iprec
153 & , gen1, count0, gen_xout, gen_yout
154 & , gen_lon0,gen_lon_inc
155 & , gen_lat0,gen_lat_inc
156 & , gen_nlon,gen_nlat,interp_method,mythid
157 & )
158 #else
159 call mdsreadfield( genfile0, exf_iprec, exf_yftype, 1
160 & , gen1, count0, mythid
161 & )
162 #endif /* USE_EXF_INTERPOLATION */
163
164 if (exf_yftype .eq. 'RL') then
165 call exf_filter_rl( gen1, genmask, mythid )
166 else
167 call exf_filter_rs( gen1, genmask, mythid )
168 end if
169 endif
170
171 if (( first ) .or. ( changed )) then
172 call exf_SwapFFields( gen0, gen1, mythid )
173
174 if (useExfYearlyFields.and.genperiod.gt.0) then
175 C Complete filename with YR or _YEAR extension
176 il = ilnblnk( genfile )
177 if (twoDigitYear) then
178 if (year1.ge.2000) then
179 write(genfile1(1:128),'(a,i2.2)')
180 & genfile(1:il),year1-2000
181 else
182 write(genfile1(1:128),'(a,i2.2)')
183 & genfile(1:il),year1-1900
184 endif
185 else
186 write(genfile1(1:128),'(2a,i4.4)')
187 & genfile(1:il),'_',year1
188 endif
189 else
190 genfile1 = genfile
191 endif
192 #ifdef USE_EXF_INTERPOLATION
193 call exf_interp( genfile1, exf_iprec
194 & , gen1, count1, gen_xout, gen_yout
195 & , gen_lon0,gen_lon_inc
196 & , gen_lat0,gen_lat_inc
197 & , gen_nlon,gen_nlat,interp_method,mythid
198 & )
199 #else
200 call mdsreadfield( genfile1, exf_iprec, exf_yftype, 1
201 & , gen1, count1, mythid
202 & )
203 #endif /* USE_EXF_INTERPOLATION */
204
205 if (exf_yftype .eq. 'RL') then
206 call exf_filter_rl( gen1, genmask, mythid )
207 else
208 call exf_filter_rs( gen1, genmask, mythid )
209 end if
210 endif
211
212 c Loop over tiles.
213 do bj = mybylo(mythid),mybyhi(mythid)
214 do bi = mybxlo(mythid),mybxhi(mythid)
215 do j = 1,sny
216 do i = 1,snx
217 c Interpolate linearly onto the time.
218 cph if ( genfile .EQ. climsstfile ) then
219 cph if (gen0(i,j,bi,bj) .lt. climtempfreeze) then
220 cph gen0(i,j,bi,bj) = climtempfreeze
221 cph endif
222 cph if (gen1(i,j,bi,bj) .lt. climtempfreeze) then
223 cph gen1(i,j,bi,bj) = climtempfreeze
224 cph endif
225 cph endif
226 genfld(i,j,bi,bj) = exf_inscal_gen * (
227 & fac * gen0(i,j,bi,bj) +
228 & (exf_one - fac) * gen1(i,j,bi,bj) )
229 genfld(i,j,bi,bj) =
230 & genfld(i,j,bi,bj) -
231 & exf_inscal_gen * ( genremove_intercept +
232 & genremove_slope*(mytime-starttime) )
233 enddo
234 enddo
235 enddo
236 enddo
237
238 endif
239
240 end
241
242
243 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
244 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
245
246 subroutine exf_init_gen (
247 & genfile, genperiod, exf_inscal_gen, genmask,
248 & genconst, genfld, gen0, gen1,
249 #ifdef USE_EXF_INTERPOLATION
250 & gen_lon0, gen_lon_inc, gen_lat0, gen_lat_inc,
251 & gen_nlon, gen_nlat, gen_xout, gen_yout, interp_method,
252 #endif
253 & mythid )
254
255
256 c ==================================================================
257 c SUBROUTINE exf_init_gen
258 c ==================================================================
259 c
260 c o
261 c
262 c started: Ralf.Giering@FastOpt.de 25-Mai-2000
263 c changed: heimbach@mit.edu 10-Jan-2002
264 c heimbach@mit.edu: totally re-organized exf_set_...
265 c replaced all routines by one generic routine
266 c
267 c ==================================================================
268 c SUBROUTINE exf_init_gen
269 c ==================================================================
270
271 implicit none
272
273 c == global variables ==
274
275 #include "EEPARAMS.h"
276 #include "SIZE.h"
277
278 #include "EXF_PARAM.h"
279
280 c == routine arguments ==
281
282 _RL genperiod, exf_inscal_gen, genconst
283 _RL genfld(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
284 _RL gen0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
285 _RL gen1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
286 character*1 genmask
287 character*(128) genfile
288 integer mythid
289
290 #ifdef USE_EXF_INTERPOLATION
291 c gen_lon_0 ,gen_lat_0 :: longitude and latitude of SouthWest
292 c corner of global input grid
293 c gen_nlon, gen_nlat :: input x-grid and y-grid size
294 c gen_lon_inc :: scalar x-grid increment
295 c gen_lat_inc :: vector y-grid increments
296 c gen_xout, gen_yout :: coordinates for output grid
297 _RL gen_lon0, gen_lon_inc
298 _RL gen_lat0, gen_lat_inc(MAX_LAT_INC)
299 INTEGER gen_nlon, gen_nlat
300 _RS gen_xout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
301 _RS gen_yout (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
302 integer interp_method
303 #endif /* USE_EXF_INTERPOLATION */
304
305 c == local variables ==
306
307 integer bi, bj, i, j, count
308
309 c == end of interface ==
310
311 do bj = mybylo(mythid), mybyhi(mythid)
312 do bi = mybxlo(mythid), mybxhi(mythid)
313 do j = 1-oly, sny+oly
314 do i = 1-olx, snx+olx
315 genfld(i,j,bi,bj) = genconst
316 gen0(i,j,bi,bj) = genconst
317 gen1(i,j,bi,bj) = genconst
318 enddo
319 enddo
320 enddo
321 enddo
322
323 if ( genfile .NE. ' ' .and. genperiod .eq. 0. ) then
324 count = 1
325
326 #ifdef USE_EXF_INTERPOLATION
327 call exf_interp( genfile, exf_iprec
328 & , genfld, count, gen_xout, gen_yout
329 & , gen_lon0,gen_lon_inc
330 & , gen_lat0,gen_lat_inc
331 & , gen_nlon,gen_nlat,interp_method,mythid
332 & )
333 #else
334 call mdsreadfield( genfile, exf_iprec, exf_yftype, 1
335 & , genfld, count, mythid
336 & )
337 #endif /* USE_EXF_INTERPOLATION */
338
339 if (exf_yftype .eq. 'RL') then
340 call exf_filter_rl( genfld, genmask, mythid )
341 else
342 call exf_filter_rs( genfld, genmask, mythid )
343 end if
344
345 c Loop over tiles.
346 do bj = mybylo(mythid),mybyhi(mythid)
347 do bi = mybxlo(mythid),mybxhi(mythid)
348 do j = 1,sny
349 do i = 1,snx
350 c Interpolate linearly onto the time.
351 genfld(i,j,bi,bj) =
352 & exf_inscal_gen * genfld(i,j,bi,bj)
353 enddo
354 enddo
355 enddo
356 enddo
357
358 endif
359
360 end

  ViewVC Help
Powered by ViewVC 1.1.22