/[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.15 - (show annotations) (download)
Mon Oct 20 03:13:32 2014 UTC (10 years, 1 month ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65g
Changes since 1.14: +7 -1 lines
- ECCO_OPTIONS.h is needed when including ecco_cost.h, ecco.h
- AUTODIFF_OPTIONS.h is needed when including tamc.h, tamc_keys.h
- CTRL_OPTIONS.h is needed when including ctrl.h

1 C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_wind.F,v 1.14 2014/09/12 14:57:44 gforget 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 #if (defined (ALLOW_CTRL) && \
41 defined (ALLOW_GENTIM2D_CONTROL))
42 # include "ctrl.h"
43 # include "optim.h"
44 # include "CTRL_SIZE.h"
45 # include "CTRL_GENARR.h"
46 #endif
47
48 C == routine arguments ==
49
50 _RL myTime
51 INTEGER myIter
52 INTEGER myThid
53
54 C == external functions ==
55
56 C == local variables ==
57
58 INTEGER bi,bj
59 INTEGER i,j
60 _RL wsLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
61 _RL wsSq
62 _RL usSq, recip_sqrtRhoA, ustar
63 _RL tmp1, tmp2, tmp3, tmp4
64 _RL oneThirdRL
65 PARAMETER ( oneThirdRL = 1.d0 / 3.d0 )
66 #if (defined (ALLOW_CTRL) && \
67 defined (ALLOW_GENTIM2D_CONTROL))
68 INTEGER iarr
69 #endif
70 C == end of interface ==
71
72 C-- Use atmospheric state to compute surface fluxes.
73
74 C Loop over tiles.
75 DO bj = myByLo(myThid),myByHi(myThid)
76 DO bi = myBxLo(myThid),myBxHi(myThid)
77
78 #ifdef ALLOW_AUTODIFF_TAMC
79 act1 = bi - myBxLo(myThid)
80 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
81 act2 = bj - myByLo(myThid)
82 max2 = myByHi(myThid) - myByLo(myThid) + 1
83 act3 = myThid - 1
84 max3 = nTx*nTy
85 act4 = ikey_dynamics - 1
86 ikey = (act1 + 1) + act2*max1
87 & + act3*max1*max2
88 & + act4*max1*max2*max3
89 #endif /* ALLOW_AUTODIFF_TAMC */
90
91 C-- Initialise
92 DO j = 1,sNy
93 DO i = 1,sNx
94 wsLoc(i,j) = 0. _d 0
95 cw(i,j,bi,bj) = 0. _d 0
96 sw(i,j,bi,bj) = 0. _d 0
97 sh(i,j,bi,bj) = 0. _d 0
98 wStress(i,j,bi,bj) = 0. _d 0
99 ENDDO
100 ENDDO
101
102 #ifdef ALLOW_AUTODIFF_TAMC
103 CADJ STORE uwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
104 CADJ STORE vwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
105 CADJ STORE wspeed(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
106 #endif
107
108 IF ( useAtmWind ) THEN
109
110 C-- Wind speed and direction.
111 DO j = 1,sNy
112 DO i = 1,sNx
113 wsSq = uwind(i,j,bi,bj)*uwind(i,j,bi,bj)
114 & + vwind(i,j,bi,bj)*vwind(i,j,bi,bj)
115 IF ( wsSq .NE. 0. _d 0 ) THEN
116 wsLoc(i,j) = SQRT(wsSq)
117 cw(i,j,bi,bj) = uwind(i,j,bi,bj)/wsLoc(i,j)
118 sw(i,j,bi,bj) = vwind(i,j,bi,bj)/wsLoc(i,j)
119 ELSE
120 wsLoc(i,j) = 0. _d 0
121 cw(i,j,bi,bj) = 0. _d 0
122 sw(i,j,bi,bj) = 0. _d 0
123 ENDIF
124 ENDDO
125 ENDDO
126 IF ( wspeedfile .EQ. ' ' ) THEN
127 C- wind-speed is not loaded from file: save local array into common block
128 DO j = 1,sNy
129 DO i = 1,sNx
130 wspeed(i,j,bi,bj) = wsLoc(i,j)
131 ENDDO
132 ENDDO
133 ENDIF
134
135 ELSE
136
137 C-- Wind stress and direction.
138 DO j = 1,sNy
139 DO i = 1,sNx
140 IF ( stressIsOnCgrid ) THEN
141 usSq = ( ustress(i, j,bi,bj)*ustress(i ,j,bi,bj)
142 & +ustress(i+1,j,bi,bj)*ustress(i+1,j,bi,bj)
143 & +vstress(i,j, bi,bj)*vstress(i,j ,bi,bj)
144 & +vstress(i,j+1,bi,bj)*vstress(i,j+1,bi,bj)
145 & )*0.5 _d 0
146 ELSE
147 usSq = ustress(i,j,bi,bj)*ustress(i,j,bi,bj)
148 & +vstress(i,j,bi,bj)*vstress(i,j,bi,bj)
149 ENDIF
150 IF ( usSq .NE. 0. _d 0 ) THEN
151 wStress(i,j,bi,bj) = SQRT(usSq)
152 c ustar = SQRT(usSq/atmrho)
153 cw(i,j,bi,bj) = ustress(i,j,bi,bj)/wStress(i,j,bi,bj)
154 sw(i,j,bi,bj) = vstress(i,j,bi,bj)/wStress(i,j,bi,bj)
155 ELSE
156 wStress(i,j,bi,bj) = 0. _d 0
157 cw(i,j,bi,bj) = 0. _d 0
158 sw(i,j,bi,bj) = 0. _d 0
159 ENDIF
160 ENDDO
161 ENDDO
162
163 IF ( wspeedfile .EQ. ' ' ) THEN
164 C-- wspeed is not loaded ; derive wind-speed by inversion of
165 C wind-stress=fct(wind-speed) relation:
166 C The variables us, sh and rdn have to be computed from
167 C given wind stresses inverting relationship for neutral
168 C drag coeff. cdn.
169 C The inversion is based on linear and quadratic form of
170 C cdn(umps); ustar can be directly computed from stress;
171 recip_sqrtRhoA = 1. _d 0 / SQRT(atmrho)
172 DO j = 1,sNy
173 DO i = 1,sNx
174 ustar = wStress(i,j,bi,bj)*recip_sqrtRhoA
175 IF ( ustar .EQ. 0. _d 0 ) THEN
176 wsLoc(i,j) = 0. _d 0
177 ELSE IF ( ustar .LT. ustofu11 ) THEN
178 tmp1 = -cquadrag_2/cquadrag_1*exf_half
179 tmp2 = SQRT(tmp1*tmp1 + ustar*ustar/cquadrag_1)
180 wsLoc(i,j) = SQRT(tmp1 + tmp2)
181 ELSE
182 tmp1 = clindrag_2/clindrag_1*oneThirdRL
183 tmp2 = ustar*ustar/clindrag_1*exf_half
184 & - tmp1*tmp1*tmp1
185 tmp3 = SQRT( ustar*ustar/clindrag_1*
186 & (ustar*ustar/clindrag_1*0.25 _d 0 - tmp1*tmp1*tmp1 )
187 & )
188 tmp4 = (tmp2 + tmp3)**oneThirdRL
189 wsLoc(i,j) = tmp4 + tmp1*tmp1 / tmp4 - tmp1
190 c wsLoc(i,j) = (tmp2 + tmp3)**oneThirdRL +
191 c & tmp1*tmp1 * (tmp2 + tmp3)**(-oneThirdRL) - tmp1
192 ENDIF
193 ENDDO
194 ENDDO
195 C- save local array wind-speed to common block
196 DO j = 1,sNy
197 DO i = 1,sNx
198 wspeed(i,j,bi,bj) = wsLoc(i,j)
199 ENDDO
200 ENDDO
201 ENDIF
202
203 #ifdef ALLOW_AUTODIFF_TAMC
204 CADJ STORE wspeed(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
205 CADJ STORE uwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
206 CADJ STORE vwind (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
207 CADJ STORE cw (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
208 CADJ STORE sw (:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
209 #endif
210
211 C-- infer wind field from wind-speed & wind-stress direction
212 DO j = 1,sNy
213 DO i = 1,sNx
214 uwind(i,j,bi,bj) = wspeed(i,j,bi,bj)*cw(i,j,bi,bj)
215 vwind(i,j,bi,bj) = wspeed(i,j,bi,bj)*sw(i,j,bi,bj)
216 ENDDO
217 ENDDO
218 ENDIF
219
220 #if (defined (ALLOW_CTRL) && \
221 defined (ALLOW_GENTIM2D_CONTROL))
222 DO j = 1,sNy
223 DO i = 1,sNx
224 do iarr = 1, maxCtrlTim2D
225 if (xx_gentim2d_file(iarr).EQ.'xxg_wspeed')
226 & wspeed(i,j,bi,bj)=wspeed(i,j,bi,bj)+
227 & xx_gentim2d(i,j,bi,bj,iarr)
228 enddo
229 ENDDO
230 ENDDO
231 #endif
232
233 #ifdef ALLOW_AUTODIFF_TAMC
234 CADJ STORE wspeed(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
235 #endif
236
237 C-- set wind-speed lower limit
238 DO j = 1,sNy
239 DO i = 1,sNx
240 sh(i,j,bi,bj) = MAX(wspeed(i,j,bi,bj),uMin)
241 ENDDO
242 ENDDO
243
244 C-- end bi,bj loops
245 ENDDO
246 ENDDO
247
248 RETURN
249 END

  ViewVC Help
Powered by ViewVC 1.1.22