/[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.15 - (show annotations) (download)
Mon Dec 11 16:19:19 2006 UTC (17 years, 6 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint58u_post, checkpoint58t_post, checkpoint58s_post
Changes since 1.14: +38 -10 lines
o pkg/exf: removed exf_init_runoff.F and placed functionality in
  exf_init.F and exf_set_gen.F; changed exf_set_gen.F so that
    genperiod=0 means input file is one time-constant field and
    genperiod=-12 means input file contains 12 monthly means
Note 1: need to complete ALLOW_RUNOFF_CONTROL in exf_getffields.F
Note 2: exf_set_gen.F now includes functionality of exf_set_climsss.F
        and exf_set_climsst.F, which can evetually be removed

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

  ViewVC Help
Powered by ViewVC 1.1.22