/[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.3 - (show annotations) (download)
Wed Mar 17 23:08:09 2004 UTC (20 years, 3 months ago) by dimitri
Branch: MAIN
Changes since 1.2: +2 -28 lines
o Added capability to read-in both atmospheric fluxes and atmospheric
  conditions, needed for running sea-ice model in conjunction with fluxes.
o Removed ALLOW_CLIM_CYCLIC: cyclic monthly forcing is instead diagnosed
  from presence or absence of input parameters clim*period

1 C $Header: /usr/local/gcmpack/MITgcm/pkg/exf/exf_set_uv.F,v 1.2 2004/03/15 17:15:38 dimitri Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "EXF_OPTIONS.h"
6
7 #ifdef USE_EXF_INTERPOLATION
8
9 subroutine exf_set_uv(
10 & uvecfile, uvecstartdate, uvecperiod,
11 & exf_inscal_uvec, uvec, uvec0, uvec1, uvecmask,
12 & uvec_lon0, uvec_lon_inc, uvec_lat0, uvec_lat_inc,
13 & uvec_nlon, uvec_nlat,
14 & vvecfile, vvecstartdate, vvecperiod,
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
61 _RL uvecstartdate, uvecperiod
62 _RL exf_inscal_uvec
63 _RL uvec (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
64 _RL uvec0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
65 _RL uvec1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
66 character*1 uvecmask
67 _RL uvec_lon0, uvec_lon_inc
68 _RL uvec_lat0, uvec_lat_inc(MAX_LAT_INC)
69 INTEGER uvec_nlon, uvec_nlat
70 character*(128) vvecfile
71 _RL vvecstartdate, vvecperiod
72 _RL exf_inscal_vvec
73 _RL vvec (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
74 _RL vvec0 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
75 _RL vvec1 (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
76 character*1 vvecmask
77 _RL vvec_lon0, vvec_lon_inc
78 _RL vvec_lat0, vvec_lat_inc(MAX_LAT_INC)
79 INTEGER vvec_nlon, vvec_nlat
80 _RL mycurrenttime
81 integer mycurrentiter
82 integer mythid
83
84 c == local variables ==
85
86 logical first, changed
87 _RL fac, x1, x2, x3, x4, y1, y2, y3, y4, dx, dy
88 _RL tmp_u (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
89 _RL tmp_v (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
90 integer count0, count1
91 integer i, j, bi, bj
92 integer interp_method
93 parameter(interp_method=2)
94
95 c == end of interface ==
96
97 IF ( useCubedSphereExchange ) THEN
98
99 if ( uvecfile .NE. ' ' .and. vvecfile .NE. ' ' ) then
100
101 c some restrictions that can be relaxed later on
102 if ( uvecstartdate .ne. vvecstartdate .or.
103 & uvecperiod .ne. vvecperiod ) then
104 print*,'For useCubedSphereExchange, S/R exf_set_uv.F'
105 print*,'assumes that the u and v wind or wind stress'
106 print*,'files have the same startdate and period.'
107 stop
108 endif
109
110 c get record numbers and interpolation factor
111 call exf_GetFFieldRec(
112 I uvecstartdate, uvecperiod
113 O , fac, first, changed
114 O , count0, count1
115 I , mycurrenttime, mycurrentiter, mythid
116 & )
117
118 if ( first ) then
119 c scalar interpolation to (xC,yC) locations
120 call exf_interp( uvecfile, exf_iprec
121 & , tmp_u, count0, xC, yC
122 & , uvec_lon0,uvec_lon_inc
123 & , uvec_lat0,uvec_lat_inc
124 & , uvec_nlon,uvec_nlat,interp_method,mythid
125 & )
126 call exf_interp( vvecfile, exf_iprec
127 & , tmp_v, count0, xC, yC
128 & , vvec_lon0,vvec_lon_inc
129 & , vvec_lat0,vvec_lat_inc
130 & , vvec_nlon,vvec_nlat,interp_method,mythid
131 & )
132 c vector rotation
133 do bj = mybylo(mythid),mybyhi(mythid)
134 do bi = mybxlo(mythid),mybxhi(mythid)
135 do j = 1,sny
136 do i = 1,snx
137 x1=xG(i,j,bi,bj)
138 x2=xG(i+1,j,bi,bj)
139 x3=xG(i,j+1,bi,bj)
140 x4=xG(i+1,j+1,bi,bj)
141 if ((x2-x1).gt.180) x2=x2-360
142 if ((x1-x2).gt.180) x2=x2+360
143 if ((x3-x1).gt.180) x3=x3-360
144 if ((x1-x3).gt.180) x3=x3+360
145 if ((x4-x1).gt.180) x4=x4-360
146 if ((x1-x4).gt.180) x4=x4+360
147 y1=yG(i,j,bi,bj)
148 y2=yG(i+1,j,bi,bj)
149 y3=yG(i,j+1,bi,bj)
150 y4=yG(i+1,j+1,bi,bj)
151 dx=0.5*(x3+x4-x1-x2)
152 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
153 dy=0.5*(y3+y4-y1-y2)
154 vvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
155 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
156 dx=0.5*(x2+x4-x1-x3)
157 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
158 dy=0.5*(y2+y4-y1-y3)
159 uvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
160 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
161 enddo
162 enddo
163 enddo
164 enddo
165 c apply mask
166 if (exf_yftype .eq. 'RL') then
167 call exf_filter_rl( uvec1, uvecmask, mythid )
168 call exf_filter_rl( vvec1, vvecmask, mythid )
169 else
170 call exf_filter_rs( uvec1, uvecmask, mythid )
171 call exf_filter_rs( vvec1, vvecmask, mythid )
172 end if
173 endif
174
175 if (( first ) .or. ( changed )) then
176 call exf_SwapFFields( uvec0, uvec1, mythid )
177 call exf_SwapFFields( vvec0, vvec1, mythid )
178 c scalar interpolation to (xC,yC) locations
179 call exf_interp( uvecfile, exf_iprec
180 & , tmp_u, count1, xC, yC
181 & , uvec_lon0,uvec_lon_inc
182 & , uvec_lat0,uvec_lat_inc
183 & , uvec_nlon,uvec_nlat,interp_method,mythid
184 & )
185 call exf_interp( vvecfile, exf_iprec
186 & , tmp_v, count1, xC, yC
187 & , vvec_lon0,vvec_lon_inc
188 & , vvec_lat0,vvec_lat_inc
189 & , vvec_nlon,vvec_nlat,interp_method,mythid
190 & )
191 c vector rotation
192 do bj = mybylo(mythid),mybyhi(mythid)
193 do bi = mybxlo(mythid),mybxhi(mythid)
194 do j = 1,sny
195 do i = 1,snx
196 x1=xG(i,j,bi,bj)
197 x2=xG(i+1,j,bi,bj)
198 x3=xG(i,j+1,bi,bj)
199 x4=xG(i+1,j+1,bi,bj)
200 if ((x2-x1).gt.180) x2=x2-360
201 if ((x1-x2).gt.180) x2=x2+360
202 if ((x3-x1).gt.180) x3=x3-360
203 if ((x1-x3).gt.180) x3=x3+360
204 if ((x4-x1).gt.180) x4=x4-360
205 if ((x1-x4).gt.180) x4=x4+360
206 y1=yG(i,j,bi,bj)
207 y2=yG(i+1,j,bi,bj)
208 y3=yG(i,j+1,bi,bj)
209 y4=yG(i+1,j+1,bi,bj)
210 dx=0.5*(x3+x4-x1-x2)
211 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
212 dy=0.5*(y3+y4-y1-y2)
213 vvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
214 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
215 dx=0.5*(x2+x4-x1-x3)
216 dx=dx*cos(deg2rad*yC(i,j,bi,bj))
217 dy=0.5*(y2+y4-y1-y3)
218 uvec1(i,j,bi,bj)=(tmp_u(i,j,bi,bj)*dx+
219 & tmp_v(i,j,bi,bj)*dy)/sqrt(dx*dx+dy*dy)
220 enddo
221 enddo
222 enddo
223 enddo
224 c apply mask
225 if (exf_yftype .eq. 'RL') then
226 call exf_filter_rl( uvec1, uvecmask, mythid )
227 call exf_filter_rl( vvec1, vvecmask, mythid )
228 else
229 call exf_filter_rs( uvec1, uvecmask, mythid )
230 call exf_filter_rs( vvec1, vvecmask, mythid )
231 end if
232 endif
233
234 c Interpolate linearly onto the current time.
235 do bj = mybylo(mythid),mybyhi(mythid)
236 do bi = mybxlo(mythid),mybxhi(mythid)
237 do j = 1,sny
238 do i = 1,snx
239 uvec(i,j,bi,bj) = exf_inscal_uvec * (
240 & fac * uvec0(i,j,bi,bj) +
241 & (exf_one - fac) * uvec1(i,j,bi,bj) )
242 vvec(i,j,bi,bj) = exf_inscal_vvec * (
243 & fac * vvec0(i,j,bi,bj) +
244 & (exf_one - fac) * vvec1(i,j,bi,bj) )
245 enddo
246 enddo
247 enddo
248 enddo
249
250 endif
251
252 ELSE
253 c IF ( .NOT. useCubedSphereExchange )
254
255 call exf_set_gen(
256 & uvecfile, uvecstartdate, uvecperiod,
257 & exf_inscal_uvec,
258 & uvec, uvec0, uvec1, uvecmask,
259 & uvec_lon0, uvec_lon_inc, uvec_lat0, uvec_lat_inc,
260 & uvec_nlon, uvec_nlat, xC, yC,
261 & mycurrenttime, mycurrentiter, mythid )
262 call exf_set_gen(
263 & vvecfile, vvecstartdate, vvecperiod,
264 & exf_inscal_vvec,
265 & vvec, vvec0, vvec1, vvecmask,
266 & vvec_lon0, vvec_lon_inc, vvec_lat0, vvec_lat_inc,
267 & vvec_nlon, vvec_nlat, xC, yC,
268 & mycurrenttime, mycurrentiter, mythid )
269
270 ENDIF
271
272 return
273 end
274
275 #endif /* USE_EXF_INTERPOLATION */

  ViewVC Help
Powered by ViewVC 1.1.22