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

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

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


Revision 1.18 - (show annotations) (download)
Sat Jan 28 18:29:11 2017 UTC (7 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, HEAD
Changes since 1.17: +5 -7 lines
remove restriction related to ALLOW_ATM_WIND

1 C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_wind.F,v 1.17 2017/01/27 17:22:55 jmc Exp $
2 C $Name: $
3
4 #include "EXF_OPTIONS.h"
5 #ifdef ALLOW_CTRL
6 # include "CTRL_OPTIONS.h"
7 #endif
8 #ifdef ALLOW_AUTODIFF
9 # include "AUTODIFF_OPTIONS.h"
10 #endif
11
12 SUBROUTINE EXF_WIND( myTime, myIter, myThid )
13
14 C ==================================================================
15 C SUBROUTINE exf_wind
16 C ==================================================================
17 C
18 C o Prepare wind speed and stress fields
19 C
20 C ==================================================================
21 C SUBROUTINE exf_wind
22 C ==================================================================
23
24 IMPLICIT NONE
25
26 C == global variables ==
27
28 #include "SIZE.h"
29 #include "EEPARAMS.h"
30 #include "PARAMS.h"
31
32 #include "EXF_PARAM.h"
33 #include "EXF_FIELDS.h"
34 #include "EXF_CONSTANTS.h"
35
36 #ifdef ALLOW_AUTODIFF_TAMC
37 #include "tamc.h"
38 #include "tamc_keys.h"
39 #endif
40 #ifdef ALLOW_GENTIM2D_CONTROL
41 # include "ctrl.h"
42 # include "optim.h"
43 # include "CTRL_SIZE.h"
44 # include "CTRL_GENARR.h"
45 #endif
46
47 C == routine arguments ==
48
49 _RL myTime
50 INTEGER myIter
51 INTEGER myThid
52
53 C == external functions ==
54
55 C == local variables ==
56
57 INTEGER bi,bj
58 INTEGER i,j
59 _RL wsLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
60 _RL wsSq
61 #ifdef ALLOW_BULKFORMULAE
62 _RL usSq, recip_sqrtRhoA, ustar
63 _RL tmp1, tmp2, tmp3, tmp4
64 #endif /* ALLOW_BULKFORMULAE */
65 _RL oneThirdRL
66 PARAMETER ( oneThirdRL = 1.d0 / 3.d0 )
67 #if !(defined ALLOW_BULKFORMULAE) || !(defined ALLOW_ATM_TEMP)
68 _RL wsm, tmpbulk
69 #endif
70 #ifdef ALLOW_GENTIM2D_CONTROL
71 INTEGER iarr
72 #endif
73 C == end of interface ==
74
75 C-- Use atmospheric state to compute surface fluxes.
76
77 C Loop over tiles.
78 DO bj = myByLo(myThid),myByHi(myThid)
79 DO bi = myBxLo(myThid),myBxHi(myThid)
80
81 #ifdef ALLOW_AUTODIFF_TAMC
82 act1 = bi - myBxLo(myThid)
83 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
84 act2 = bj - myByLo(myThid)
85 max2 = myByHi(myThid) - myByLo(myThid) + 1
86 act3 = myThid - 1
87 max3 = nTx*nTy
88 act4 = ikey_dynamics - 1
89 ikey = (act1 + 1) + act2*max1
90 & + act3*max1*max2
91 & + act4*max1*max2*max3
92 #endif /* ALLOW_AUTODIFF_TAMC */
93
94 C-- Initialise
95 DO j = 1,sNy
96 DO i = 1,sNx
97 wsLoc(i,j) = 0. _d 0
98 cw(i,j,bi,bj) = 0. _d 0
99 sw(i,j,bi,bj) = 0. _d 0
100 sh(i,j,bi,bj) = 0. _d 0
101 wStress(i,j,bi,bj) = 0. _d 0
102 ENDDO
103 ENDDO
104
105 #ifdef ALLOW_AUTODIFF_TAMC
106 CADJ STORE uwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
107 CADJ STORE vwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
108 CADJ STORE wspeed(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
109 #endif
110
111 IF ( useAtmWind ) THEN
112
113 C-- Wind speed and direction.
114 DO j = 1,sNy
115 DO i = 1,sNx
116 wsSq = uwind(i,j,bi,bj)*uwind(i,j,bi,bj)
117 & + vwind(i,j,bi,bj)*vwind(i,j,bi,bj)
118 IF ( wsSq .NE. 0. _d 0 ) THEN
119 wsLoc(i,j) = SQRT(wsSq)
120 cw(i,j,bi,bj) = uwind(i,j,bi,bj)/wsLoc(i,j)
121 sw(i,j,bi,bj) = vwind(i,j,bi,bj)/wsLoc(i,j)
122 ELSE
123 wsLoc(i,j) = 0. _d 0
124 cw(i,j,bi,bj) = 0. _d 0
125 sw(i,j,bi,bj) = 0. _d 0
126 ENDIF
127 ENDDO
128 ENDDO
129 IF ( wspeedfile .EQ. ' ' ) THEN
130 C- wind-speed is not loaded from file: save local array into common block
131 DO j = 1,sNy
132 DO i = 1,sNx
133 wspeed(i,j,bi,bj) = wsLoc(i,j)
134 ENDDO
135 ENDDO
136 ENDIF
137
138 #ifdef ALLOW_BULKFORMULAE
139 ELSE
140 C-- case useAtmWind=F
141
142 C-- Wind stress and direction.
143 DO j = 1,sNy
144 DO i = 1,sNx
145 IF ( stressIsOnCgrid ) THEN
146 usSq = ( ustress(i, j,bi,bj)*ustress(i ,j,bi,bj)
147 & +ustress(i+1,j,bi,bj)*ustress(i+1,j,bi,bj)
148 & +vstress(i,j, bi,bj)*vstress(i,j ,bi,bj)
149 & +vstress(i,j+1,bi,bj)*vstress(i,j+1,bi,bj)
150 & )*0.5 _d 0
151 ELSE
152 usSq = ustress(i,j,bi,bj)*ustress(i,j,bi,bj)
153 & +vstress(i,j,bi,bj)*vstress(i,j,bi,bj)
154 ENDIF
155 IF ( usSq .NE. 0. _d 0 ) THEN
156 wStress(i,j,bi,bj) = SQRT(usSq)
157 c ustar = SQRT(usSq/atmrho)
158 cw(i,j,bi,bj) = ustress(i,j,bi,bj)/wStress(i,j,bi,bj)
159 sw(i,j,bi,bj) = vstress(i,j,bi,bj)/wStress(i,j,bi,bj)
160 ELSE
161 wStress(i,j,bi,bj) = 0. _d 0
162 cw(i,j,bi,bj) = 0. _d 0
163 sw(i,j,bi,bj) = 0. _d 0
164 ENDIF
165 ENDDO
166 ENDDO
167
168 IF ( wspeedfile .EQ. ' ' ) THEN
169 C-- wspeed is not loaded ; derive wind-speed by inversion of
170 C wind-stress=fct(wind-speed) relation:
171 C The variables us, sh and rdn have to be computed from
172 C given wind stresses inverting relationship for neutral
173 C drag coeff. cdn.
174 C The inversion is based on linear and quadratic form of
175 C cdn(umps); ustar can be directly computed from stress;
176 recip_sqrtRhoA = 1. _d 0 / SQRT(atmrho)
177 DO j = 1,sNy
178 DO i = 1,sNx
179 ustar = wStress(i,j,bi,bj)*recip_sqrtRhoA
180 IF ( ustar .EQ. 0. _d 0 ) THEN
181 wsLoc(i,j) = 0. _d 0
182 ELSE IF ( ustar .LT. ustofu11 ) THEN
183 tmp1 = -cquadrag_2/cquadrag_1*exf_half
184 tmp2 = SQRT(tmp1*tmp1 + ustar*ustar/cquadrag_1)
185 wsLoc(i,j) = SQRT(tmp1 + tmp2)
186 ELSE
187 tmp1 = clindrag_2/clindrag_1*oneThirdRL
188 tmp2 = ustar*ustar/clindrag_1*exf_half
189 & - tmp1*tmp1*tmp1
190 tmp3 = SQRT( ustar*ustar/clindrag_1*
191 & (ustar*ustar/clindrag_1*0.25 _d 0 - tmp1*tmp1*tmp1 )
192 & )
193 tmp4 = (tmp2 + tmp3)**oneThirdRL
194 wsLoc(i,j) = tmp4 + tmp1*tmp1 / tmp4 - tmp1
195 c wsLoc(i,j) = (tmp2 + tmp3)**oneThirdRL +
196 c & tmp1*tmp1 * (tmp2 + tmp3)**(-oneThirdRL) - tmp1
197 ENDIF
198 ENDDO
199 ENDDO
200 C- save local array wind-speed to common block
201 DO j = 1,sNy
202 DO i = 1,sNx
203 wspeed(i,j,bi,bj) = wsLoc(i,j)
204 ENDDO
205 ENDDO
206 C- end if wspeedfile = empty
207 ENDIF
208
209 #ifdef ALLOW_AUTODIFF_TAMC
210 CADJ STORE wspeed(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
211 CADJ STORE uwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
212 CADJ STORE vwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
213 CADJ STORE cw (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
214 CADJ STORE sw (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
215 #endif
216
217 C-- infer wind field from wind-speed & wind-stress direction
218 DO j = 1,sNy
219 DO i = 1,sNx
220 uwind(i,j,bi,bj) = wspeed(i,j,bi,bj)*cw(i,j,bi,bj)
221 vwind(i,j,bi,bj) = wspeed(i,j,bi,bj)*sw(i,j,bi,bj)
222 ENDDO
223 ENDDO
224
225 #endif /* ALLOW_BULKFORMULAE */
226 C-- end if/else useAtmWind
227 ENDIF
228
229 #ifdef ALLOW_GENTIM2D_CONTROL
230 DO j = 1,sNy
231 DO i = 1,sNx
232 do iarr = 1, maxCtrlTim2D
233 if (xx_gentim2d_file(iarr)(1:9).EQ.'xx_wspeed')
234 & wspeed(i,j,bi,bj)=wspeed(i,j,bi,bj)+
235 & xx_gentim2d(i,j,bi,bj,iarr)
236 enddo
237 ENDDO
238 ENDDO
239 #endif
240
241 #ifdef ALLOW_AUTODIFF_TAMC
242 CADJ STORE wspeed(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
243 #endif
244
245 C-- set wind-speed lower limit
246 DO j = 1,sNy
247 DO i = 1,sNx
248 sh(i,j,bi,bj) = MAX(wspeed(i,j,bi,bj),uMin)
249 ENDDO
250 ENDDO
251
252 #if !(defined ALLOW_BULKFORMULAE) || !(defined ALLOW_ATM_TEMP)
253 C Note: In case ALLOW_BULKFORMULAE and ALLOW_ATM_TEMP are defined,
254 C wind-stress is computed (if needed) within S/R EXF_BULKFORMULAE
255 IF ( useAtmWind ) THEN
256 c#ifdef ALLOW_ATM_WIND
257 C-- Computes wind-stress:
258 DO j = 1,sNy
259 DO i = 1,sNx
260 wsm = sh(i,j,bi,bj)
261 tmpbulk = exf_scal_BulkCdn
262 & * ( cdrag_1/wsm + cdrag_2 + cdrag_3*wsm )
263 ustress(i,j,bi,bj) = atmrho*tmpbulk*wspeed(i,j,bi,bj)
264 & * uwind(i,j,bi,bj)
265 vstress(i,j,bi,bj) = atmrho*tmpbulk*wspeed(i,j,bi,bj)
266 & * vwind(i,j,bi,bj)
267 ENDDO
268 ENDDO
269 c#else /* ALLOW_ATM_WIND */
270 c STOP 'ABNORMAL END: S/R EXF_WIND: missing code for useAtmWind'
271 c#endif /* ALLOW_ATM_WIND */
272 C-- end if useAtmWind
273 ENDIF
274 #endif /* ndef ALLOW_BULKFORMULAE or ndef ALLOW_ATM_TEMP */
275
276 C-- end bi,bj loops
277 ENDDO
278 ENDDO
279
280 RETURN
281 END

  ViewVC Help
Powered by ViewVC 1.1.22