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

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

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


Revision 1.8 - (show annotations) (download)
Mon Feb 21 05:32:55 2005 UTC (19 years, 3 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint57g_post, checkpoint57e_post, checkpoint57g_pre, checkpoint57f_pre, eckpoint57e_pre, checkpoint57f_post
Changes since 1.7: +51 -9 lines
pkg/exf: added twoDigitYear to useExfYearlyFields

1 C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_set_uv.F,v 1.7 2004/12/20 23:32:52 dimitri Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "EXF_OPTIONS.h"
6
7 subroutine exf_set_uv(
8 & uvecfile, uvecstartdate, uvecperiod,
9 & uvecstartdate1, uvecstartdate2,
10 & exf_inscal_uvec, uvec, uvec0, uvec1, uvecmask,
11 & uvec_lon0, uvec_lon_inc, uvec_lat0, uvec_lat_inc,
12 & uvec_nlon, uvec_nlat,
13 & vvecfile, vvecstartdate, vvecperiod,
14 & vvecstartdate1, vvecstartdate2,
15 & exf_inscal_vvec, vvec, vvec0, vvec1, vvecmask,
16 & vvec_lon0, vvec_lon_inc, vvec_lat0, vvec_lat_inc,
17 & vvec_nlon, vvec_nlat,
18 & mycurrenttime, mycurrentiter, mythid )
19
20 c ==================================================================
21 c SUBROUTINE exf_set_uv
22 c ==================================================================
23 c
24 c o Read-in, interpolate, and rotate wind or wind stress vectors
25 c from a spherical-polar input grid to an arbitrary output grid.
26 c
27 c menemenlis@jpl.nasa.gov, 8-Dec-2003
28 c
29 c ==================================================================
30 c SUBROUTINE exf_set_uv
31 c ==================================================================
32
33 implicit none
34
35 c == global variables ==
36
37 #include "EEPARAMS.h"
38 #include "SIZE.h"
39 #include "PARAMS.h"
40 #include "DYNVARS.h"
41 #include "GRID.h"
42
43 #include "exf_param.h"
44 #include "exf_fields.h"
45 #include "exf_constants.h"
46
47 #ifdef ALLOW_AUTODIFF
48 # include "ctrl.h"
49 # include "ctrl_dummy.h"
50 #endif
51
52 c == routine arguments ==
53
54 c *vec_lon_0, :: longitude and latitude of SouthWest
55 c *vec_lat_0 corner of global input grid for *vec
56 c *vec_nlon, *vec_nlat :: input x-grid and y-grid size for *vec
57 c *vec_lon_inc :: scalar x-grid increment for *vec
58 c *vec_lat_inc :: vector y-grid increments for *vec
59
60 character*(128) uvecfile, uvecfile0, uvecfile1
61 _RL uvecstartdate, uvecperiod
62 integer uvecstartdate1, uvecstartdate2
63 _RL exf_inscal_uvec
64 _RL uvec (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
65 _RL uvec0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
66 _RL uvec1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
67 character*1 uvecmask
68 _RL uvec_lon0, uvec_lon_inc
69 _RL uvec_lat0, uvec_lat_inc(MAX_LAT_INC)
70 INTEGER uvec_nlon, uvec_nlat
71 character*(128) vvecfile, vvecfile0, vvecfile1
72 _RL vvecstartdate, vvecperiod
73 integer vvecstartdate1, vvecstartdate2
74 _RL exf_inscal_vvec
75 _RL vvec (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
76 _RL vvec0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
77 _RL vvec1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
78 character*1 vvecmask
79 _RL vvec_lon0, vvec_lon_inc
80 _RL vvec_lat0, vvec_lat_inc(MAX_LAT_INC)
81 INTEGER vvec_nlon, vvec_nlat
82 _RL mycurrenttime
83 integer mycurrentiter
84 integer mythid
85
86 #ifdef USE_EXF_INTERPOLATION
87 c == local variables ==
88
89 logical first, changed
90 _RL fac, x1, x2, x3, x4, y1, y2, y3, y4, dx, dy
91 _RL tmp_u (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
92 _RL tmp_v (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
93 integer count0, count1
94 integer i, j, bi, bj
95 integer il, interp_method
96 parameter(interp_method=2)
97 integer year0, year1
98
99 c == external ==
100
101 integer ilnblnk
102 external ilnblnk
103
104 c == end of interface ==
105
106 IF ( useCubedSphereExchange ) THEN
107
108 if ( uvecfile .NE. ' ' .and. vvecfile .NE. ' ' ) then
109
110 c get record numbers and interpolation factor
111 call exf_GetFFieldRec(
112 I uvecstartdate, uvecperiod
113 I , uvecstartdate1, uvecstartdate2
114 I , useExfYearlyFields
115 O , fac, first, changed
116 O , count0, count1, year0, year1
117 I , mycurrenttime, mycurrentiter, mythid
118 & )
119
120 if ( first ) then
121 if (useExfYearlyFields) then
122 C Complete filenames with YR or _YEAR extension
123 il = ilnblnk( uvecfile )
124 if (twoDigitYear) then
125 if (year0.ge.2000) then
126 write(uvecfile0(1:128),'(a,i2.2)')
127 & uvecfile(1:il),year0-2000
128 else
129 write(uvecfile0(1:128),'(a,i2.2)')
130 & uvecfile(1:il),year0-1900
131 endif
132 else
133 write(uvecfile0(1:128),'(2a,i4.4)')
134 & uvecfile(1:il),'_',year0
135 endif
136 il = ilnblnk( vvecfile )
137 if (twoDigitYear) then
138 if (year0.ge.2000) then
139 write(vvecfile0(1:128),'(a,i2.2)')
140 & vvecfile(1:il),year0-2000
141 else
142 write(vvecfile0(1:128),'(a,i2.2)')
143 & vvecfile(1:il),year0-1900
144 endif
145 else
146 write(vvecfile0(1:128),'(2a,i4.4)')
147 & vvecfile(1:il),'_',year0
148 endif
149 else
150 uvecfile0 = uvecfile
151 vvecfile0 = vvecfile
152 endif
153 c scalar interpolation to (xC,yC) locations
154 call exf_interp( uvecfile0, exf_iprec
155 & , tmp_u, count0, xC, yC
156 & , uvec_lon0,uvec_lon_inc
157 & , uvec_lat0,uvec_lat_inc
158 & , uvec_nlon,uvec_nlat,interp_method,mythid
159 & )
160 call exf_interp( vvecfile0, exf_iprec
161 & , tmp_v, count0, xC, yC
162 & , vvec_lon0,vvec_lon_inc
163 & , vvec_lat0,vvec_lat_inc
164 & , vvec_nlon,vvec_nlat,interp_method,mythid
165 & )
166 c vector rotation
167 do bj = mybylo(mythid),mybyhi(mythid)
168 do bi = mybxlo(mythid),mybxhi(mythid)
169 do j = 1,sny
170 do i = 1,snx
171 x1=xG(i,j,bi,bj)
172 x2=xG(i+1,j,bi,bj)
173 x3=xG(i,j+1,bi,bj)
174 x4=xG(i+1,j+1,bi,bj)
175 if ((x2-x1).gt.180) x2=x2-360
176 if ((x1-x2).gt.180) x2=x2+360
177 if ((x3-x1).gt.180) x3=x3-360
178 if ((x1-x3).gt.180) x3=x3+360
179 if ((x4-x1).gt.180) x4=x4-360
180 if ((x1-x4).gt.180) x4=x4+360
181 y1=yG(i,j,bi,bj)
182 y2=yG(i+1,j,bi,bj)
183 y3=yG(i,j+1,bi,bj)
184 y4=yG(i+1,j+1,bi,bj)
185 dx=0.5*(x3+x4-x1-x2)
186 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
187 dy=0.5*(y3+y4-y1-y2)
188 vvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
189 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
190 dx=0.5*(x2+x4-x1-x3)
191 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
192 dy=0.5*(y2+y4-y1-y3)
193 uvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
194 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
195 enddo
196 enddo
197 enddo
198 enddo
199 c apply mask
200 if (exf_yftype .eq. 'RL') then
201 call exf_filter_rl( uvec1, uvecmask, mythid )
202 call exf_filter_rl( vvec1, vvecmask, mythid )
203 else
204 call exf_filter_rs( uvec1, uvecmask, mythid )
205 call exf_filter_rs( vvec1, vvecmask, mythid )
206 end if
207 endif
208
209 if (( first ) .or. ( changed )) then
210 call exf_SwapFFields( uvec0, uvec1, mythid )
211 call exf_SwapFFields( vvec0, vvec1, mythid )
212 if (useExfYearlyFields) then
213 C Complete filenames with YR or _YEAR extension
214 il = ilnblnk( uvecfile )
215 if (twoDigitYear) then
216 if (year1.ge.2000) then
217 write(uvecfile1(1:128),'(a,i2.2)')
218 & uvecfile(1:il),year1-2000
219 else
220 write(uvecfile1(1:128),'(a,i2.2)')
221 & uvecfile(1:il),year1-1900
222 endif
223 else
224 write(uvecfile1(1:128),'(2a,i4.4)')
225 & uvecfile(1:il),'_',year1
226 endif
227 il = ilnblnk( vvecfile )
228 if (twoDigitYear) then
229 if (year1.ge.2000) then
230 write(vvecfile1(1:128),'(a,i2.2)')
231 & vvecfile(1:il),year1-2000
232 else
233 write(vvecfile1(1:128),'(a,i2.2)')
234 & vvecfile(1:il),year1-1900
235 endif
236 else
237 write(vvecfile1(1:128),'(2a,i4.4)')
238 & vvecfile(1:il),'_',year1
239 endif
240 else
241 uvecfile1 = uvecfile
242 vvecfile1 = vvecfile
243 endif
244 c scalar interpolation to (xC,yC) locations
245 call exf_interp( uvecfile1, exf_iprec
246 & , tmp_u, count1, xC, yC
247 & , uvec_lon0,uvec_lon_inc
248 & , uvec_lat0,uvec_lat_inc
249 & , uvec_nlon,uvec_nlat,interp_method,mythid
250 & )
251 call exf_interp( vvecfile1, exf_iprec
252 & , tmp_v, count1, xC, yC
253 & , vvec_lon0,vvec_lon_inc
254 & , vvec_lat0,vvec_lat_inc
255 & , vvec_nlon,vvec_nlat,interp_method,mythid
256 & )
257 c vector rotation
258 do bj = mybylo(mythid),mybyhi(mythid)
259 do bi = mybxlo(mythid),mybxhi(mythid)
260 do j = 1,sny
261 do i = 1,snx
262 x1=xG(i,j,bi,bj)
263 x2=xG(i+1,j,bi,bj)
264 x3=xG(i,j+1,bi,bj)
265 x4=xG(i+1,j+1,bi,bj)
266 if ((x2-x1).gt.180) x2=x2-360
267 if ((x1-x2).gt.180) x2=x2+360
268 if ((x3-x1).gt.180) x3=x3-360
269 if ((x1-x3).gt.180) x3=x3+360
270 if ((x4-x1).gt.180) x4=x4-360
271 if ((x1-x4).gt.180) x4=x4+360
272 y1=yG(i,j,bi,bj)
273 y2=yG(i+1,j,bi,bj)
274 y3=yG(i,j+1,bi,bj)
275 y4=yG(i+1,j+1,bi,bj)
276 dx=0.5*(x3+x4-x1-x2)
277 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
278 dy=0.5*(y3+y4-y1-y2)
279 vvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
280 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
281 dx=0.5*(x2+x4-x1-x3)
282 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
283 dy=0.5*(y2+y4-y1-y3)
284 uvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
285 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
286 enddo
287 enddo
288 enddo
289 enddo
290 c apply mask
291 if (exf_yftype .eq. 'RL') then
292 call exf_filter_rl( uvec1, uvecmask, mythid )
293 call exf_filter_rl( vvec1, vvecmask, mythid )
294 else
295 call exf_filter_rs( uvec1, uvecmask, mythid )
296 call exf_filter_rs( vvec1, vvecmask, mythid )
297 end if
298 endif
299
300 c Interpolate linearly onto the current time.
301 do bj = mybylo(mythid),mybyhi(mythid)
302 do bi = mybxlo(mythid),mybxhi(mythid)
303 do j = 1,sny
304 do i = 1,snx
305 uvec(i,j,bi,bj) = exf_inscal_uvec * (
306 & fac * uvec0(i,j,bi,bj) +
307 & (exf_one - fac) * uvec1(i,j,bi,bj) )
308 vvec(i,j,bi,bj) = exf_inscal_vvec * (
309 & fac * vvec0(i,j,bi,bj) +
310 & (exf_one - fac) * vvec1(i,j,bi,bj) )
311 enddo
312 enddo
313 enddo
314 enddo
315
316 endif
317
318 ELSE
319 c IF ( .NOT. useCubedSphereExchange )
320
321 call exf_set_gen(
322 & uvecfile, uvecstartdate, uvecperiod,
323 I uvecstartdate1, uvecstartdate2,
324 & exf_inscal_uvec,
325 & uvec, uvec0, uvec1, uvecmask,
326 & uvec_lon0, uvec_lon_inc, uvec_lat0, uvec_lat_inc,
327 & uvec_nlon, uvec_nlat, xC, yC, interp_method,
328 & mycurrenttime, mycurrentiter, mythid )
329 call exf_set_gen(
330 & vvecfile, vvecstartdate, vvecperiod,
331 I vvecstartdate1, vvecstartdate2,
332 & exf_inscal_vvec,
333 & vvec, vvec0, vvec1, vvecmask,
334 & vvec_lon0, vvec_lon_inc, vvec_lat0, vvec_lat_inc,
335 & vvec_nlon, vvec_nlat, xC, yC, interp_method,
336 & mycurrenttime, mycurrentiter, mythid )
337
338 ENDIF
339
340 #endif /* USE_EXF_INTERPOLATION */
341
342 return
343 end

  ViewVC Help
Powered by ViewVC 1.1.22