File indexing completed on 2022-01-29 06:11:22 UTC
view on githubraw file Latest commit 4578baf3 on 2021-12-13 15:21:55 UTC
0d1e4b948d Mich*0001 #include "GMREDI_OPTIONS.h"
0002
7ea279c259 Jean*0003
0d1e4b948d Mich*0004
7ea279c259 Jean*0005 SUBROUTINE GMREDI_CALC_BATES_K(
0006 I iMin, iMax, jMin, jMax,
0007 I sigmaX, sigmaY, sigmaR,
0008 I bi, bj, myTime, myIter, myThid )
0d1e4b948d Mich*0009
0010
0011
7ea279c259 Jean*0012
0013
0d1e4b948d Mich*0014
0015
0016
0017 IMPLICIT NONE
0018
0019
0020 #include "SIZE.h"
0021 #include "EEPARAMS.h"
0022 #include "PARAMS.h"
a08df3a232 Jean*0023 #include "GRID.h"
0024 #include "DYNVARS.h"
0ff5c71d8d Jean*0025 #include "FFIELDS.h"
0d1e4b948d Mich*0026 #include "GMREDI.h"
0027
0028
0029
0030
7ea279c259 Jean*0031
0032
0d1e4b948d Mich*0033
0034
0035 INTEGER iMin,iMax,jMin,jMax
4578baf364 Jean*0036 _RL sigmaX(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0037 _RL sigmaY(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0038 _RL sigmaR(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0d1e4b948d Mich*0039 INTEGER bi, bj
5a6ef5c2b4 Mich*0040 _RL myTime
7ea279c259 Jean*0041 INTEGER myIter
0d1e4b948d Mich*0042 INTEGER myThid
0043
05118ac017 Jean*0044 #ifdef GM_BATES_K3D
0d1e4b948d Mich*0045
5a6ef5c2b4 Mich*0046
0047 LOGICAL DIFFERENT_MULTIPLE
0048 EXTERNAL DIFFERENT_MULTIPLE
0049
0d1e4b948d Mich*0050
0051
74e46366ba Davi*0052 INTEGER i,j,k,kk,m,kp1
5a6ef5c2b4 Mich*0053
0054
0055 LOGICAL update_modes
0056
0057
0058
0059
0060
4578baf364 Jean*0061 INTEGER surfk(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0062 INTEGER kLow_C(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0063 INTEGER kLow_U(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0064 INTEGER kLow_V(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
5a6ef5c2b4 Mich*0065
0066
0067
0068
0069
0070
0071
05118ac017 Jean*0072
5a6ef5c2b4 Mich*0073
0074
0075
0076
0077
4578baf364 Jean*0078 _RL N2loc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0d1e4b948d Mich*0079 _RL slope
4578baf364 Jean*0080 _RL slopeC(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
5a6ef5c2b4 Mich*0081 _RL Req
4578baf364 Jean*0082 _RL deltaH(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0d1e4b948d Mich*0083 _RL g_reciprho_sq
4578baf364 Jean*0084 _RL M4loc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0085 _RL M4onN2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0d1e4b948d Mich*0086 _RL maxDRhoDz
0087 _RL sigx, sigy, sigz
74e46366ba Davi*0088 _RL hsurf, mskp1
0d1e4b948d Mich*0089 _RL small
5a6ef5c2b4 Mich*0090
74e46366ba Davi*0091
0092
0ea5811d0e Mich*0093
5a6ef5c2b4 Mich*0094
0095
0096
0097
0098
0099
0100
0101
0102
4578baf364 Jean*0103 _RL dfdy( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0104 _RL dfdx( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0105 _RL dummy( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0106 _RL Rurms( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0107 _RL RRhines(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0108 _RL Rmix( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0109 _RL N2( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0110 _RL N2W( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0111 _RL N2S( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0112 _RL N( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0113 _RL BVint( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0114 _RL Ubaro( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0115 _RL ubar( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0116
0117 _RL tmpU( 1-OLx:sNx+OLx,1-OLy:sNy+OLy )
0118 _RL tmpV( 1-OLx:sNx+OLx,1-OLy:sNy+OLy )
0119 _RL uFldX( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr )
0120 _RL vFldY( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr )
5a6ef5c2b4 Mich*0121
0122
0123
40739f94bb Mich*0124
0125
5a6ef5c2b4 Mich*0126
0127
0128
0129
0130
0131
0132
0133
5dbdc05725 Davi*0134
0135
5a6ef5c2b4 Mich*0136
4578baf364 Jean*0137 _RL Rmid(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0138 _RL KPV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0139 _RL Kdqdy(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0140 _RL Kdqdx(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0141 _RL SlopeX(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0142 _RL SlopeY(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0143 _RL dSigmaDx(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0144 _RL dSigmaDy(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0145 _RL tfluxX(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0146 _RL tfluxY(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0147 _RL coriU(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0148 _RL coriV(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0149 _RL fCoriU(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0150 _RL fCoriV(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0151 _RL surfkz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
5a6ef5c2b4 Mich*0152
df226773af Mich*0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
224bd236ac Mich*0166 _RL centreX, centreY
0167 _RL numerator, denominator
4578baf364 Jean*0168 _RL uInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0169 _RL vInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0170 _RL KdqdxInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0171 _RL KdqdyInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0172 _RL uKdqdyInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0173 _RL vKdqdxInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0174 _RL uXiyInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0175 _RL vXixInt(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0176 _RL Renorm(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0177 _RL RenormU(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0178 _RL RenormV(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
224bd236ac Mich*0179
5a6ef5c2b4 Mich*0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
4578baf364 Jean*0193 _RL gradqx(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0194 _RL gradqy(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0195 _RL XimX(GM_Bates_NModes,1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0196 _RL XimY(GM_Bates_NModes,1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0197 _RL cDopp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0198 _RL umc( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr)
0199 _RL eady( 1-OLx:sNx+OLx,1-OLy:sNy+OLy)
0200 _RL urms( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr)
0201 _RL supp( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr)
0202 _RL ustar(1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr)
0203 _RL vstar(1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr)
0204 _RL Xix( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
0205 _RL Xiy( 1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
05118ac017 Jean*0206 #ifdef GM_BATES_PASSIVE
5a6ef5c2b4 Mich*0207
4578baf364 Jean*0208 _RL psistar(1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr)
5a6ef5c2b4 Mich*0209 #endif
0d1e4b948d Mich*0210
0211
0212
0213
0214
0215
0216 small = TINY(zeroRL)
5a6ef5c2b4 Mich*0217 update_modes=.FALSE.
05118ac017 Jean*0218 IF ( DIFFERENT_MULTIPLE(GM_Bates_vecFreq,myTime,deltaTClock) )
5a6ef5c2b4 Mich*0219 & update_modes=.TRUE.
0220
4578baf364 Jean*0221 DO j=1-OLy,sNy+OLy
0222 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0223 kLow_C(i,j) = kLowC(i,j,bi,bj)
0224 ENDDO
0225 ENDDO
4578baf364 Jean*0226 DO j=1-OLy,sNy+OLy
0227 DO i=1-OLx+1,sNx+OLx
0d1e4b948d Mich*0228 kLow_U(i,j) = MIN( kLow_C(i,j), kLow_C(i-1,j) )
0229 ENDDO
0230 ENDDO
4578baf364 Jean*0231 DO j=1-OLy+1,sNy+OLy
0232 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0233 kLow_V(i,j) = MIN( kLow_C(i,j), kLow_C(i,j-1) )
0234 ENDDO
0235 ENDDO
0236
219a8971b6 Mich*0237
0238
4578baf364 Jean*0239 i=1-OLx
0240 DO j=1-OLy,sNy+OLy
219a8971b6 Mich*0241 kLow_U(i,j) = 0
0d1e4b948d Mich*0242 ENDDO
4578baf364 Jean*0243 j=1-OLy
0244 DO i=1-OLx,sNx+OLx
219a8971b6 Mich*0245 kLow_V(i,j) = 0
0d1e4b948d Mich*0246 ENDDO
0247
0248 g_reciprho_sq = (gravity*recip_rhoConst)**2
0249
4578baf364 Jean*0250 DO j=1-OLy+1,sNy+OLy
0251 DO i=1-OLx+1,sNx+OLx
0d1e4b948d Mich*0252 dfdx(i,j) = ( fCori(i,j,bi,bj)-fCori(i-1,j,bi,bj) )
0253 & *recip_dxC(i,j,bi,bj)
0254 dfdy(i,j) = ( fCori(i,j,bi,bj)-fCori(i,j-1,bi,bj) )
0255 & *recip_dyC(i,j,bi,bj)
0256 ENDDO
0257 ENDDO
0258
5dbdc05725 Davi*0259
0d1e4b948d Mich*0260
4578baf364 Jean*0261 DO j=1-OLy,sNy+OLy
0262 DO i=1-OLx+1,sNx+OLx
9d5e80ac5d Mich*0263
5dbdc05725 Davi*0264 fCoriU(i,j)= op5*( fCori(i,j,bi,bj)+fCori(i-1,j,bi,bj) )
0265
05118ac017 Jean*0266 coriU(i,j) = SIGN( MAX( ABS(fCoriU(i,j)),GM_Bates_minCori ),
5dbdc05725 Davi*0267 & fCoriU(i,j) )
9d5e80ac5d Mich*0268 ENDDO
0269 ENDDO
4578baf364 Jean*0270 DO j=1-OLy+1,sNy+OLy
0271 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0272
5dbdc05725 Davi*0273 fCoriV(i,j)= op5*( fCori(i,j,bi,bj)+fCori(i,j-1,bi,bj) )
0274
05118ac017 Jean*0275 coriV(i,j) = SIGN( MAX( ABS(fCoriV(i,j)),GM_Bates_minCori ),
5dbdc05725 Davi*0276 & fCoriV(i,j) )
0d1e4b948d Mich*0277 ENDDO
0278 ENDDO
9d5e80ac5d Mich*0279
4578baf364 Jean*0280 i=1-OLx
0281 DO j=1-OLy,sNy+OLy
5dbdc05725 Davi*0282 fCoriU(i,j)= fCori(i,j,bi,bj)
05118ac017 Jean*0283 coriU(i,j) = SIGN( MAX( ABS(fCori(i,j,bi,bj)),GM_Bates_minCori ),
5dbdc05725 Davi*0284 & fCori(i,j,bi,bj) )
9d5e80ac5d Mich*0285 ENDDO
4578baf364 Jean*0286 j=1-OLy
0287 DO i=1-OLx,sNx+OLx
5dbdc05725 Davi*0288 fCoriV(i,j)= fCori(i,j,bi,bj)
05118ac017 Jean*0289 coriV(i,j) = SIGN( MAX( ABS(fCori(i,j,bi,bj)),GM_Bates_minCori ),
5dbdc05725 Davi*0290 & fCori(i,j,bi,bj) )
9d5e80ac5d Mich*0291 ENDDO
0d1e4b948d Mich*0292
0293
4578baf364 Jean*0294 DO j=1-OLy,sNy+OLy
0295 DO i=1-OLx,sNx+OLx
74b49ccfa8 Mich*0296 eady(i,j) = zeroRL
0297 BVint(i,j) = zeroRL
0298 Ubaro(i,j) = zeroRL
0299 deltaH(i,j) = zeroRL
0300 ENDDO
0301 ENDDO
0302 DO k=1,Nr
4578baf364 Jean*0303 DO j=1-OLy,sNy+OLy
0304 DO i=1-OLx,sNx+OLx
74b49ccfa8 Mich*0305 slopeC(i,j,k)=zeroRL
0306 ENDDO
0d1e4b948d Mich*0307 ENDDO
0308 ENDDO
0309
9d5e80ac5d Mich*0310
4578baf364 Jean*0311 DO j=1-OLy,sNy+OLy
0312 DO i=1-OLx,sNx+OLx
9d5e80ac5d Mich*0313 Rurms(i,j)=zeroRL
0314 RRhines(i,j)=zeroRL
0315 Rmix(i,j)=zeroRL
0316 ENDDO
0317 ENDDO
0318
0319 DO k=1,Nr
4578baf364 Jean*0320 DO j=1-OLy,sNy+OLy
0321 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0322 N2loc(i,j,k)=GM_Bates_minN2
0323 N2W(i,j,k) = GM_Bates_minN2
0324 N2S(i,j,k) = GM_Bates_minN2
9d5e80ac5d Mich*0325 M4loc(i,j,k)=zeroRL
0326 M4onN2(i,j,k)=zeroRL
0327 urms(i,j,k)=zeroRL
0328 SlopeX(i,j,k)=zeroRL
0329 SlopeY(i,j,k)=zeroRL
0330 dSigmaDx(i,j,k)=zeroRL
0331 dSigmaDy(i,j,k)=zeroRL
0332 gradqx(i,j,k)=zeroRL
0333 gradqy(i,j,k)=zeroRL
0334 ENDDO
0335 ENDDO
0336 ENDDO
0337
0d1e4b948d Mich*0338
0ff5c71d8d Jean*0339 #ifdef ALLOW_EDDYPSI
5853335f7f Mich*0340 IF (GM_InMomAsStress) THEN
93219a225f Mich*0341 DO k=1,Nr
4578baf364 Jean*0342 DO i = 1-OLx,sNx+OLx
0343 DO j = 1-OLy,sNy+OLy
93219a225f Mich*0344 uFldX(i,j,k) = uEulerMean(i,j,k,bi,bj)
0345 vFldY(i,j,k) = vEulerMean(i,j,k,bi,bj)
0346 ENDDO
0347 ENDDO
0348 ENDDO
5853335f7f Mich*0349 ELSE
0350 #endif
93219a225f Mich*0351 DO k=1,Nr
4578baf364 Jean*0352 DO i = 1-OLx,sNx+OLx
0353 DO j = 1-OLy,sNy+OLy
93219a225f Mich*0354 uFldX(i,j,k) = uVel(i,j,k,bi,bj)
0355 vFldY(i,j,k) = vVel(i,j,k,bi,bj)
0356 ENDDO
0357 ENDDO
0358 ENDDO
0ff5c71d8d Jean*0359 #ifdef ALLOW_EDDYPSI
5853335f7f Mich*0360 ENDIF
0361 #endif
0d1e4b948d Mich*0362
93219a225f Mich*0363
0364
0365
0366
0367 DO k = 1,Nr
4578baf364 Jean*0368 DO i = 1-OLx,sNx+OLx
0369 j=sNy+OLy
93219a225f Mich*0370 tmpU(i,j)=zeroRL
0371 tmpV(i,j)=zeroRL
0372 ENDDO
4578baf364 Jean*0373 DO j = 1-OLy,sNy+OLy-1
0374 i=sNx+OLx
93219a225f Mich*0375 tmpU(i,j)=zeroRL
0376 tmpV(i,j)=zeroRL
4578baf364 Jean*0377 DO i = 1-OLx,sNx+OLx-1
93219a225f Mich*0378 tmpU(i,j) = 0.5 _d 0
0379 & *( uFldX(i+1,j,k) + uFldX(i,j,k) )
0380 tmpV(i,j) = 0.5 _d 0
0381 & *( vFldY(i,j+1,k) + vFldY(i,j,k) )
74e46366ba Davi*0382
93219a225f Mich*0383 tmpU(i,j) = tmpU(i,j) * maskC(i,j,k,bi,bj)
0384 tmpV(i,j) = tmpV(i,j) * maskC(i,j,k,bi,bj)
0385 ENDDO
0386 ENDDO
66842ef555 Davi*0387
4578baf364 Jean*0388 DO j = 1-OLy,sNy+OLy
0389 DO i = 1-OLx,sNx+OLx
74e46366ba Davi*0390 ubar(i,j,k) =
93219a225f Mich*0391 & angleCosC(i,j,bi,bj)*tmpU(i,j)
0392 & -angleSinC(i,j,bi,bj)*tmpV(i,j)
0393 ENDDO
0394 ENDDO
0395 ENDDO
74e46366ba Davi*0396
f183cca6ba Davi*0397
0398
0399
0400 DO k=1,Nr
4578baf364 Jean*0401 DO j=1-OLy,sNy+OLy
0402 DO i=1-OLx,sNx+OLx
f183cca6ba Davi*0403 Ubaro(i,j) = Ubaro(i,j) +
0404 & drF(k)*hfacC(i,j,k,bi,bj)*ubar(i,j,k)
0405 ENDDO
0406 ENDDO
0407 ENDDO
4578baf364 Jean*0408 DO j=1-OLy,sNy+OLy
0409 DO i=1-OLx,sNx+OLx
f183cca6ba Davi*0410 IF (kLow_C(i,j).GT.0) THEN
0411
0412 Ubaro(i,j) = -Ubaro(i,j)/r_Low(i,j,bi,bj)
0413 ENDIF
0414 ENDDO
0415 ENDDO
0416
0d1e4b948d Mich*0417
74e46366ba Davi*0418
0419
0d1e4b948d Mich*0420 DO k=2,Nr
4578baf364 Jean*0421 DO j=1-OLy,sNy+OLy
0422 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0423 N2(i,j,k) = -gravity*recip_rhoConst*sigmaR(i,j,k)
05118ac017 Jean*0424 N2(i,j,k) = MAX(N2(i,j,k),GM_Bates_minN2)*maskC(i,j,k,bi,bj)
74e46366ba Davi*0425 N(i,j,k) = SQRT(N2(i,j,k))
0d1e4b948d Mich*0426 ENDDO
0427 ENDDO
0428 ENDDO
0429
4578baf364 Jean*0430 DO j=1-OLy,sNy+OLy
0431 DO i=1-OLx,sNx+OLx
74e46366ba Davi*0432 N2(i,j,1) = zeroRL
0433 N(i,j,1) = zeroRL
0d1e4b948d Mich*0434 ENDDO
0435 ENDDO
0436
05118ac017 Jean*0437 maxDRhoDz = -rhoConst*GM_Bates_minN2/gravity
0d1e4b948d Mich*0438
0439
74e46366ba Davi*0440
0d1e4b948d Mich*0441 DO k=1,Nr
74e46366ba Davi*0442 kp1 = min(k+1,Nr)
0443 mskp1 = oneRL
0444 IF ( k.EQ.Nr ) mskp1 = zeroRL
4578baf364 Jean*0445 DO j=1-OLy,sNy+OLy
0446 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0447 BVint(i,j) = BVint(i,j) + hFacC(i,j,k,bi,bj)*drF(k)
74e46366ba Davi*0448 & *op5*(N(i,j,k)+mskp1*N(i,j,kp1))
0d1e4b948d Mich*0449 ENDDO
0450 ENDDO
0451 ENDDO
0452
0453
5a6ef5c2b4 Mich*0454 IF (update_modes) THEN
0455 CALL GMREDI_CALC_EIGS(
0456 I iMin,iMax,jMin,jMax,bi,bj,N2,myThid,
0457 I kLow_C, maskC(:,:,:,bi,bj),
0458 I hfacC(:,:,:,bi,bj), recip_hfacC(:,:,:,bi,bj),
0459 I R_Low(:,:,bi,bj), 1, .TRUE.,
0460 O Rmid, modesC(:,:,:,:,bi,bj))
0461
0462
4578baf364 Jean*0463 DO j=1-OLy+1,sNy+OLy
0464 DO i=1-OLx+1,sNx+OLx
f183cca6ba Davi*0465 Req = SQRT(BVint(i,j)/(2. _d 0*pi*gradf(i,j,bi,bj)))
5a6ef5c2b4 Mich*0466 Rdef(i,j,bi,bj) = MIN(Rmid(i,j),Req)
0467 ENDDO
0468 ENDDO
0469 ENDIF
0d1e4b948d Mich*0470
0471
0472 DO k=1,Nr
4578baf364 Jean*0473 DO j=1-OLy,sNy+OLy-1
0474 DO i=1-OLx,sNx+OLx-1
0d1e4b948d Mich*0475 dSigmaDx(i,j,k) = op5*(sigmaX(i,j,k)+sigmaX(i+1,j,k))
0476 dSigmaDy(i,j,k) = op5*(sigmaY(i,j,k)+sigmaY(i,j+1,k))
0477 ENDDO
0478 ENDDO
0479 ENDDO
0480
0481
0482
0483
0484 DO k=1,Nr
0485
74e46366ba Davi*0486 kp1 = min(k+1,Nr)
0487 mskp1 = oneRL
0488 IF ( k.EQ.Nr ) mskp1 = zeroRL
0489
4578baf364 Jean*0490 DO j=1-OLy,sNy+OLy-1
0491 DO i=1-OLx,sNx+OLx-1
0ff5c71d8d Jean*0492 M4loc(i,j,k) = g_reciprho_sq*( dSigmaDx(i,j,k)**2
74b49ccfa8 Mich*0493 & +dSigmaDy(i,j,k)**2 )
74e46366ba Davi*0494 N2loc(i,j,k) = op5*(N2(i,j,k)+mskp1*N2(i,j,kp1))
74b49ccfa8 Mich*0495 ENDDO
0496 ENDDO
0d1e4b948d Mich*0497
0498
05118ac017 Jean*0499 IF (-rF(k+1) .LE. GM_Bates_EadyMinDepth) CYCLE
0d1e4b948d Mich*0500
c0612052db Jean*0501
0d1e4b948d Mich*0502
05118ac017 Jean*0503 IF (-rF(k).GE.GM_Bates_EadyMaxDepth) EXIT
0d1e4b948d Mich*0504
0505
4578baf364 Jean*0506 DO j=1-OLy,sNy+OLy-1
0507 DO i=1-OLx,sNx+OLx-1
0ff5c71d8d Jean*0508 IF ( (kLow_C(i,j).GE.k) .AND.
74b49ccfa8 Mich*0509 & (-hMixLayer(i,j,bi,bj).LE.-rC(k)) ) THEN
0d1e4b948d Mich*0510
c2dd265de5 Mich*0511 slopeC(i,j,k) = SQRT(M4loc(i,j,k))/N2loc(i,j,k)
0d1e4b948d Mich*0512
40739f94bb Mich*0513 IF (slopeC(i,j,k).LE.GM_maxSlope) THEN
0514 M4onN2(i,j,k) = M4loc(i,j,k)/N2loc(i,j,k)
0d1e4b948d Mich*0515 ELSE
40739f94bb Mich*0516 slopeC(i,j,k) = GM_maxslope
0517 M4onN2(i,j,k) = SQRT(M4loc(i,j,k))*GM_maxslope
0d1e4b948d Mich*0518 ENDIF
0ff5c71d8d Jean*0519 eady(i,j) = eady(i,j)
40739f94bb Mich*0520 & + hfacC(i,j,k,bi,bj)*drF(k)*M4onN2(i,j,k)
74b49ccfa8 Mich*0521 deltaH(i,j) = deltaH(i,j) + drF(k)
0d1e4b948d Mich*0522 ENDIF
0523 ENDDO
0524 ENDDO
0525 ENDDO
0526
4578baf364 Jean*0527 DO j=1-OLy,sNy+OLy
0528 DO i=1-OLx,sNx+OLx
74b49ccfa8 Mich*0529
0ff5c71d8d Jean*0530
74b49ccfa8 Mich*0531
0532
0533
0534 IF (deltaH(i,j).EQ.zeroRL) THEN
0d1e4b948d Mich*0535 eady(i,j) = small
0536
74b49ccfa8 Mich*0537
0538
0d1e4b948d Mich*0539 ELSE
74b49ccfa8 Mich*0540 eady(i,j) = SQRT(eady(i,j)/deltaH(i,j))
0ff5c71d8d Jean*0541
0d1e4b948d Mich*0542 ENDIF
0543
0544 ENDDO
0545 ENDDO
0546
0547
0548
0549
4578baf364 Jean*0550 DO j=1-OLy+1,sNy+OLy
0551 DO i=1-OLx+1,sNx+OLx-1
0d1e4b948d Mich*0552
05118ac017 Jean*0553 Rurms(i,j) = MIN(Rdef(i,j,bi,bj),GM_Bates_Rmax)
0554 urms(i,j,1) = GM_Bates_Lambda*eady(i,j)*Rurms(i,j)
0d1e4b948d Mich*0555
0556 k=kLow_C(i,j)
0557 IF (k.GT.0) urms(i,j,k) = 0.0
0558
0559
66842ef555 Davi*0560 RRhines(i,j) = SQRT(urms(i,j,1)/gradf(i,j,bi,bj))
0d1e4b948d Mich*0561
0562
5a6ef5c2b4 Mich*0563 Rmix(i,j) = MIN(Rdef(i,j,bi,bj), RRhines(i,j))
05118ac017 Jean*0564 Rmix(i,j) = MAX(Rmix(i,j),GM_Bates_Rmin)
0d1e4b948d Mich*0565
0566
74e46366ba Davi*0567
93219a225f Mich*0568 cDopp(i,j) = Ubaro(i,j)
66842ef555 Davi*0569 & - gradf(i,j,bi,bj)*Rdef(i,j,bi,bj)*Rdef(i,j,bi,bj)
05118ac017 Jean*0570
0571 IF (ABS(cDopp(i,j)).GT.GM_Bates_maxC) THEN
0572 cDopp(i,j) = MAX(GM_Bates_maxC, cDopp(i,j))
0d1e4b948d Mich*0573 ENDIF
0574
0575 ENDDO
0576 ENDDO
0577
0578
5a6ef5c2b4 Mich*0579 CALL GMREDI_CALC_URMS(
0580 I iMin,iMax,jMin,jMax,bi,bj,N2,myThid,
0581 U urms)
0d1e4b948d Mich*0582
0583
0584 DO k=1,Nr
4578baf364 Jean*0585 DO j=1-OLy,sNy+OLy
0586 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0587 IF (k.LE.kLow_C(i,j)) THEN
74b49ccfa8 Mich*0588 IF (deltaH(i,j).EQ.zeroRL) THEN
05118ac017 Jean*0589 GM_BatesK3d(i,j,k,bi,bj) = GM_Bates_smallK
0d1e4b948d Mich*0590 ELSE
0591 IF (urms(i,j,k).EQ.0.0) THEN
05118ac017 Jean*0592 GM_BatesK3d(i,j,k,bi,bj) = GM_Bates_smallK
0d1e4b948d Mich*0593 ELSE
74e46366ba Davi*0594 umc(i,j,k) =ubar(i,j,k) - cDopp(i,j)
05118ac017 Jean*0595 supp(i,j,k) = 1./
0596 & ( 1. + GM_Bates_b1*umc(i,j,k)**2/urms(i,j,1)**2 )
40739f94bb Mich*0597
05118ac017 Jean*0598 GM_BatesK3d(i,j,k,bi,bj) = GM_Bates_gamma*urms(i,j,k)
74e46366ba Davi*0599 & *2.*Rmix(i,j)*supp(i,j,k)
0d1e4b948d Mich*0600 ENDIF
0601
0602
05118ac017 Jean*0603 GM_BatesK3d(i,j,k,bi,bj) =
0604 & MIN( GM_BatesK3d(i,j,k,bi,bj), GM_Bates_maxK )
0605 GM_BatesK3d(i,j,k,bi,bj) =
0606 & MAX( GM_BatesK3d(i,j,k,bi,bj), GM_Bates_smallK )
0d1e4b948d Mich*0607 ENDIF
0608 ENDIF
0609 ENDDO
0610 ENDDO
0611 ENDDO
0612
0613
0614
0615
4e65b6d0de Mich*0616
0ff5c71d8d Jean*0617
4e65b6d0de Mich*0618
0619
0620
4578baf364 Jean*0621 DO j=1-OLy,sNy+OLy
0622 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0623 surfkz(i,j) = MIN(-GM_Bates_surfMinDepth,-hMixLayer(i,j,bi,bj))
4e65b6d0de Mich*0624 surfkz(i,j) = MAX(surfkz(i,j),R_low(i,j,bi,bj))
0625 IF(maskC(i,j,1,bi,bj).EQ.0.0) surfkz(i,j)=0.0
0626 surfk(i,j) = 0
0d1e4b948d Mich*0627 ENDDO
0628 ENDDO
5a6ef5c2b4 Mich*0629 DO k=1,Nr
4578baf364 Jean*0630 DO j=1-OLy,sNy+OLy
0631 DO i=1-OLx,sNx+OLx
0ff5c71d8d Jean*0632 IF (rF(k).GT.surfkz(i,j) .AND. surfkz(i,j).GE.rF(k+1))
4e65b6d0de Mich*0633 & surfk(i,j) = k
0d1e4b948d Mich*0634 ENDDO
0635 ENDDO
0636 ENDDO
4e65b6d0de Mich*0637
0d1e4b948d Mich*0638
4578baf364 Jean*0639 DO j=1-OLy,sNy+OLy-1
0640 DO i=1-OLx,sNx+OLx-1
0d1e4b948d Mich*0641 SlopeX(i,j,1) = zeroRL
0642 SlopeY(i,j,1) = zeroRL
0643 ENDDO
0644 ENDDO
0645 DO k=2,Nr
4578baf364 Jean*0646 DO j=1-OLy+1,sNy+OLy
0647 DO i=1-OLx+1,sNx+OLx
0d1e4b948d Mich*0648 IF(surfk(i,j).GE.kLowC(i,j,bi,bj)) THEN
0649
0650
0651 SlopeX(i,j,k) = zeroRL
0652 SlopeY(i,j,k) = zeroRL
0653
0654 ELSE
0655
5a6ef5c2b4 Mich*0656 sigz = MIN( op5*(sigmaR(i,j,k)+sigmaR(i-1,j,k)), maxDRhoDz )
0d1e4b948d Mich*0657 sigx = op5*( sigmaX(i,j,k)+sigmaX(i,j,k-1) )
0658 slope = sigx/sigz
0659 IF(ABS(slope).GT.GM_maxSlope)
0660 & slope = SIGN(GM_maxSlope,slope)
0661 SlopeX(i,j,k)=-maskW(i,j,k-1,bi,bj)*maskW(i,j,k,bi,bj)*slope
0ff5c71d8d Jean*0662
0d1e4b948d Mich*0663
5a6ef5c2b4 Mich*0664 sigz = MIN( op5*(sigmaR(i,j,k)+sigmaR(i,j-1,k)), maxDRhoDz )
0d1e4b948d Mich*0665 sigy = op5*( sigmaY(i,j,k) + sigmaY(i,j,k-1) )
0666 slope = sigy/sigz
0667 IF(ABS(slope).GT.GM_maxSlope)
0668 & slope = SIGN(GM_maxSlope,slope)
0669 SlopeY(i,j,k)=-maskS(i,j,k-1,bi,bj)*maskS(i,j,k,bi,bj)*slope
0670 ENDIF
0671 ENDDO
0672 ENDDO
0673 ENDDO
0674
c8602656d9 Davi*0675
0676
0d1e4b948d Mich*0677
0678 k=Nr
4578baf364 Jean*0679 DO j=1-OLy,sNy+OLy
0680 DO i=1-OLx,sNx+OLx
c8602656d9 Davi*0681
0d1e4b948d Mich*0682 tfluxX(i,j,k) = -fCoriU(i,j)*SlopeX(i,j,k)
0683 & *recip_drF(k)*recip_hFacW(i,j,k,bi,bj)
c8602656d9 Davi*0684
0d1e4b948d Mich*0685 tfluxY(i,j,k) = -fCoriV(i,j)*SlopeY(i,j,k)
0686 & *recip_drF(k)*recip_hFacS(i,j,k,bi,bj)
40312237e2 Mich*0687
0ff5c71d8d Jean*0688
40312237e2 Mich*0689
05118ac017 Jean*0690 KPV(i,j,k) = GM_BatesK3d(i,j,k,bi,bj)
40312237e2 Mich*0691
0d1e4b948d Mich*0692 ENDDO
0693 ENDDO
0694
c8602656d9 Davi*0695
0d1e4b948d Mich*0696 DO k=Nr-1,1,-1
4578baf364 Jean*0697 DO j=1-OLy,sNy+OLy
0698 DO i=1-OLx,sNx+OLx
c8602656d9 Davi*0699
40312237e2 Mich*0700 tfluxX(i,j,k)=-fCoriU(i,j)*(SlopeX(i,j,k)-SlopeX(i,j,k+1))
0701 & *recip_drF(k)*recip_hFacW(i,j,k,bi,bj)
0702 & *maskW(i,j,k,bi,bj)
c8602656d9 Davi*0703
40312237e2 Mich*0704 tfluxY(i,j,k)=-fCoriV(i,j)*(SlopeY(i,j,k)-SlopeY(i,j,k+1))
0705 & *recip_drF(k)*recip_hFacS(i,j,k,bi,bj)
0706 & *maskS(i,j,k,bi,bj)
0ff5c71d8d Jean*0707
0708
40312237e2 Mich*0709
05118ac017 Jean*0710 KPV(i,j,k) = GM_BatesK3d(i,j,k,bi,bj)
40312237e2 Mich*0711 ENDDO
0712 ENDDO
0713 ENDDO
0714
0ff5c71d8d Jean*0715
40312237e2 Mich*0716
05118ac017 Jean*0717 IF (GM_Bates_ThickSheet .OR. GM_Bates_surfK) THEN
40312237e2 Mich*0718 DO k=Nr-1,1,-1
4578baf364 Jean*0719 DO j=1-OLy,sNy+OLy
0720 DO i=1-OLx,sNx+OLx
0ff5c71d8d Jean*0721 IF(k.LE.surfk(i,j)) THEN
0722
40312237e2 Mich*0723
0724
05118ac017 Jean*0725 IF (GM_Bates_ThickSheet) THEN
40312237e2 Mich*0726
0727
0728
0ff5c71d8d Jean*0729
40312237e2 Mich*0730
0731 IF(kLow_U(i,j).LT.surfk(i,j)) THEN
0732 kk=kLow_U(i,j)
0733 hsurf = -rLowW(i,j,bi,bj)
0734 ELSE
0735 kk=surfk(i,j)
0736 hsurf = -surfkz(i,j)
0737 ENDIF
0738 IF(kk.GT.0) THEN
0739 IF(kk.EQ.Nr) THEN
0740 tfluxX(i,j,k) = -fCoriU(i,j)*maskW(i,j,k,bi,bj)
0741 & *SlopeX(i,j,kk)/hsurf
0742 ELSE
0743 tfluxX(i,j,k) = -fCoriU(i,j)*maskW(i,j,k,bi,bj)
0744 & *( SlopeX(i,j,kk)-SlopeX(i,j,kk+1) )/hsurf
0745 ENDIF
0746 ELSE
0747 tfluxX(i,j,k) = zeroRL
0748 ENDIF
0ff5c71d8d Jean*0749
40312237e2 Mich*0750 IF(kLow_V(i,j).LT.surfk(i,j)) THEN
0751 kk=kLow_V(i,j)
0752 hsurf = -rLowS(i,j,bi,bj)
0753 ELSE
0754 kk=surfk(i,j)
0755 hsurf = -surfkz(i,j)
0756 ENDIF
0757 IF(kk.GT.0) THEN
0758 IF(kk.EQ.Nr) THEN
0759 tfluxY(i,j,k) = -fCoriV(i,j)*maskS(i,j,k,bi,bj)
0760 & *SlopeY(i,j,kk)/hsurf
0761 ELSE
0762 tfluxY(i,j,k) = -fCoriV(i,j)*maskS(i,j,k,bi,bj)
0763 & *( SlopeY(i,j,kk)-SlopeY(i,j,kk+1) )/hsurf
0764 ENDIF
0765 ELSE
0766 tfluxY(i,j,k) = zeroRL
0767 ENDIF
5a6ef5c2b4 Mich*0768 ENDIF
0d1e4b948d Mich*0769
05118ac017 Jean*0770 IF (GM_Bates_surfK) THEN
40312237e2 Mich*0771
05118ac017 Jean*0772 KPV(i,j,k) = GM_Bates_constK
5a6ef5c2b4 Mich*0773 ENDIF
0d1e4b948d Mich*0774 ENDIF
40312237e2 Mich*0775 ENDDO
0776 ENDDO
0d1e4b948d Mich*0777 ENDDO
40312237e2 Mich*0778 ENDIF
0d1e4b948d Mich*0779
0780
05118ac017 Jean*0781 IF (GM_Bates_beta_eq_0) THEN
ecb6b844fc Mich*0782
ce74227608 Mich*0783 DO k=1,Nr
4578baf364 Jean*0784 DO j=1-OLy+1,sNy+OLy
0785 DO i=1-OLx+1,sNx+OLx
ce74227608 Mich*0786 gradqx(i,j,k) = maskW(i,j,k,bi,bj)*tfluxX(i,j,k)
0787 gradqy(i,j,k) = maskS(i,j,k,bi,bj)*tfluxY(i,j,k)
0788 ENDDO
0789 ENDDO
0d1e4b948d Mich*0790 ENDDO
0ff5c71d8d Jean*0791
ce74227608 Mich*0792 ELSE
0793
0794 DO k=1,Nr
4578baf364 Jean*0795 DO j=1-OLy+1,sNy+OLy
0796 DO i=1-OLx+1,sNx+OLx
ce74227608 Mich*0797 gradqx(i,j,k) = maskW(i,j,k,bi,bj)*(dfdx(i,j)+tfluxX(i,j,k))
0798 gradqy(i,j,k) = maskS(i,j,k,bi,bj)*(dfdy(i,j)+tfluxY(i,j,k))
0799 ENDDO
0800 ENDDO
0801 ENDDO
0802 ENDIF
0d1e4b948d Mich*0803
0804
0805
0806
0807
0808
0809 DO k=1,Nr
4578baf364 Jean*0810 DO j=1-OLy+1,sNy+OLy
0811 DO i=1-OLx+1,sNx+OLx
0d1e4b948d Mich*0812 N2W(i,j,k) = maskW(i,j,k,bi,bj)
0813 & *( N2(i,j,k)+N2(i-1,j,k) )
0814 N2S(i,j,k) = maskS(i,j,k,bi,bj)
0815 & *( N2(i,j,k)+N2(i,j-1,k) )
0816 ENDDO
0817 ENDDO
0818 ENDDO
0819
05118ac017 Jean*0820
0821
952f8e8fd1 Mich*0822
05118ac017 Jean*0823
0824 IF(GM_Bates_use_constK) THEN
ce74227608 Mich*0825 DO k=1,Nr
4578baf364 Jean*0826 DO j=1-OLy,sNy+OLy
0827 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0828 KPV(i,j,k) = GM_Bates_constK
ce74227608 Mich*0829 ENDDO
0830 ENDDO
0831 ENDDO
4e65b6d0de Mich*0832 ENDIF
ce74227608 Mich*0833
05118ac017 Jean*0834 IF (.NOT. GM_Bates_smooth) THEN
4e65b6d0de Mich*0835
0ff5c71d8d Jean*0836
4e65b6d0de Mich*0837
ce74227608 Mich*0838 DO k=1,Nr
4578baf364 Jean*0839 DO j=1-OLy,sNy+OLy
0840 DO i=1-OLx,sNx+OLx
4e65b6d0de Mich*0841 Xix(i,j,k) = -maskW(i,j,k,bi,bj)*KPV(i,j,k)*gradqx(i,j,k)
0842 Xiy(i,j,k) = -maskS(i,j,k,bi,bj)*KPV(i,j,k)*gradqy(i,j,k)
ce74227608 Mich*0843 ENDDO
0844 ENDDO
0845 ENDDO
0846
0847 ELSE
4e65b6d0de Mich*0848
0849
ce74227608 Mich*0850
0d1e4b948d Mich*0851
0852
0853
5a6ef5c2b4 Mich*0854 IF (update_modes) THEN
0855 CALL GMREDI_CALC_EIGS(
05118ac017 Jean*0856 I iMin,iMax,jMin,jMax,bi,bj, N2W, myThid,
0857 I kLow_U, maskW(:,:,:,bi,bj),
0858 I hfacW(:,:,:,bi,bj), recip_hfacW(:,:,:,bi,bj),
0859 I rLowW(:,:,bi,bj), GM_Bates_NModes, .FALSE.,
0860 O dummy, modesW(:,:,:,:,bi,bj) )
5a6ef5c2b4 Mich*0861 ENDIF
0ff5c71d8d Jean*0862
0d1e4b948d Mich*0863
4578baf364 Jean*0864 DO j=1-OLy,sNy+OLy
0865 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0866 DO m=1,GM_Bates_NModes
0d1e4b948d Mich*0867 XimX(m,i,j) = zeroRL
0868 ENDDO
0869 ENDDO
0870 ENDDO
0871 DO k=1,Nr
4578baf364 Jean*0872 DO j=1-OLy,sNy+OLy
0873 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0874 DO m=1,GM_Bates_NModes
40739f94bb Mich*0875 Kdqdx(i,j,k) = KPV(i,j,k)*gradqx(i,j,k)
0ff5c71d8d Jean*0876 XimX(m,i,j) = XimX(m,i,j)
40739f94bb Mich*0877 & - maskW(i,j,k,bi,bj)*drF(k)*hfacW(i,j,k,bi,bj)
0878 & *Kdqdx(i,j,k)*modesW(m,i,j,k,bi,bj)
0d1e4b948d Mich*0879 ENDDO
0880 ENDDO
0881 ENDDO
0882 ENDDO
0ff5c71d8d Jean*0883
0d1e4b948d Mich*0884
0885 DO k=1,Nr
4578baf364 Jean*0886 DO j=1-OLy,sNy+OLy
0887 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0888 Xix(i,j,k) = zeroRL
0889 ENDDO
0890 ENDDO
0891 ENDDO
0892 DO k=1,Nr
4578baf364 Jean*0893 DO j=1-OLy,sNy+OLy
0894 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0895 DO m=1,GM_Bates_NModes
0ff5c71d8d Jean*0896 Xix(i,j,k) = Xix(i,j,k)
5a6ef5c2b4 Mich*0897 & + maskW(i,j,k,bi,bj)*XimX(m,i,j)*modesW(m,i,j,k,bi,bj)
0d1e4b948d Mich*0898 ENDDO
0899 ENDDO
0900 ENDDO
0901 ENDDO
0902
0903
0904
0905
5a6ef5c2b4 Mich*0906 IF (update_modes) THEN
0907 CALL GMREDI_CALC_EIGS(
05118ac017 Jean*0908 I iMin,iMax,jMin,jMax,bi,bj, N2S, myThid,
0909 I kLow_V, maskS(:,:,:,bi,bj),
0910 I hfacS(:,:,:,bi,bj), recip_hfacS(:,:,:,bi,bj),
0911 I rLowS(:,:,bi,bj), GM_Bates_NModes, .FALSE.,
0912 O dummy, modesS(:,:,:,:,bi,bj) )
5a6ef5c2b4 Mich*0913 ENDIF
0914
4578baf364 Jean*0915 DO j=1-OLy,sNy+OLy
0916 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0917 DO m=1,GM_Bates_NModes
0d1e4b948d Mich*0918 XimY(m,i,j) = zeroRL
0919 ENDDO
0920 ENDDO
0921 ENDDO
0922 DO k=1,Nr
4578baf364 Jean*0923 DO j=1-OLy,sNy+OLy
0924 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0925 DO m=1,GM_Bates_NModes
40739f94bb Mich*0926 Kdqdy(i,j,k) = KPV(i,j,k)*gradqy(i,j,k)
4e65b6d0de Mich*0927 XimY(m,i,j) = XimY(m,i,j)
0928 & - drF(k)*hfacS(i,j,k,bi,bj)
40739f94bb Mich*0929 & *Kdqdy(i,j,k)*modesS(m,i,j,k,bi,bj)
0d1e4b948d Mich*0930 ENDDO
0931 ENDDO
0932 ENDDO
0933 ENDDO
0ff5c71d8d Jean*0934
0d1e4b948d Mich*0935
0936 DO k=1,Nr
4578baf364 Jean*0937 DO j=1-OLy,sNy+OLy
0938 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*0939 Xiy(i,j,k) = zeroRL
0940 ENDDO
0941 ENDDO
0942 ENDDO
0943 DO k=1,Nr
4578baf364 Jean*0944 DO j=1-OLy,sNy+OLy
0945 DO i=1-OLx,sNx+OLx
05118ac017 Jean*0946 DO m=1,GM_Bates_NModes
0ff5c71d8d Jean*0947 Xiy(i,j,k) = Xiy(i,j,k)
5a6ef5c2b4 Mich*0948 & + maskS(i,j,k,bi,bj)*XimY(m,i,j)*modesS(m,i,j,k,bi,bj)
0d1e4b948d Mich*0949 ENDDO
0950 ENDDO
0951 ENDDO
0952 ENDDO
0953
05118ac017 Jean*0954
0d1e4b948d Mich*0955 ENDIF
0956
224bd236ac Mich*0957
4578baf364 Jean*0958 DO j=1-OLy,sNy+OLy
0959 DO i=1-OLx,sNx+OLx
224bd236ac Mich*0960 uInt(i,j)=zeroRL
0961 vInt(i,j)=zeroRL
0962 KdqdyInt(i,j)=zeroRL
0963 KdqdxInt(i,j)=zeroRL
0964 uKdqdyInt(i,j)=zeroRL
0965 vKdqdxInt(i,j)=zeroRL
0966 uXiyInt(i,j)=zeroRL
0967 vXixInt(i,j)=zeroRL
df226773af Mich*0968 Renorm(i,j)=oneRL
0969 RenormU(i,j)=oneRL
0970 RenormV(i,j)=oneRL
224bd236ac Mich*0971 ENDDO
0972 ENDDO
0973 DO k=1,Nr
4578baf364 Jean*0974 DO j=1-OLy,sNy+OLy-1
0975 DO i=1-OLx,sNx+OLx-1
224bd236ac Mich*0976 centreX = op5*(uVel(i,j,k,bi,bj)+uVel(i+1,j,k,bi,bj))
0977 centreY = op5*(Kdqdy(i,j,k) +Kdqdy(i,j+1,k) )
0978
0ff5c71d8d Jean*0979 uInt(i,j) = uInt(i,j)
224bd236ac Mich*0980 & + centreX*hfacC(i,j,k,bi,bj)*drF(k)
0981 KdqdyInt(i,j) = KdqdyInt(i,j)
0982 & + centreY*hfacC(i,j,k,bi,bj)*drF(k)
0983 uKdqdyInt(i,j) = uKdqdyInt(i,j)
0984 & + centreX*centreY*hfacC(i,j,k,bi,bj)*drF(k)
0985
0986 centreY = op5*(Xiy(i,j,k) + Xiy(i,j+1,k))
0987 uXiyInt(i,j) = uXiyInt(i,j)
0988 & + centreX*centreY*hfacC(i,j,k,bi,bj)*drF(k)
0989
0990 centreX = op5*(Kdqdx(i,j,k) +Kdqdx(i+1,j,k))
0991 centreY = op5*(vVel(i,j,k,bi,bj)+vVel(i,j+1,k,bi,bj) )
0992
0993 vInt(i,j) = vInt(i,j)
0994 & + centreY*hfacC(i,j,k,bi,bj)*drF(k)
0995 KdqdxInt(i,j) = KdqdxInt(i,j)
0996 & + CentreX*hfacC(i,j,k,bi,bj)*drF(k)
0997 vKdqdxInt(i,j) = vKdqdxInt(i,j)
0998 & + centreY*centreX*hfacC(i,j,k,bi,bj)*drF(k)
0999
1000 centreX = op5*(Xix(i,j,k) + Xix(i+1,j,k))
1001 vXixInt(i,j) = vXixInt(i,j)
1002 & + centreY*centreX*hfacC(i,j,k,bi,bj)*drF(k)
1003
1004 ENDDO
1005 ENDDO
1006 ENDDO
1007
4578baf364 Jean*1008 DO j=1-OLy,sNy+OLy-1
1009 DO i=1-OLx,sNx+OLx-1
224bd236ac Mich*1010 IF (kLowC(i,j,bi,bj).GT.0) THEN
0ff5c71d8d Jean*1011 numerator =
224bd236ac Mich*1012 & (uKdqdyInt(i,j)-uInt(i,j)*KdqdyInt(i,j)/R_low(i,j,bi,bj))
1013 & -(vKdqdxInt(i,j)-vInt(i,j)*KdqdxInt(i,j)/R_low(i,j,bi,bj))
1014 denominator = uXiyInt(i,j) - vXixInt(i,j)
0ff5c71d8d Jean*1015
1016
df226773af Mich*1017
1018
1019
1020
1021
1022 IF (denominator.GT.small) THEN
224bd236ac Mich*1023 Renorm(i,j) = ABS(numerator/denominator)
05118ac017 Jean*1024 Renorm(i,j) = MAX(Renorm(i,j),GM_Bates_minRenorm)
1025 Renorm(i,j) = MIN(Renorm(i,j),GM_Bates_maxRenorm)
224bd236ac Mich*1026 ENDIF
1027 ENDIF
1028 ENDDO
1029 ENDDO
1030
4578baf364 Jean*1031 DO j=1-OLy+1,sNy+OLy-1
1032 DO i=1-OLx+1,sNx+OLx-1
224bd236ac Mich*1033 RenormU(i,j) = op5*(Renorm(i-1,j)+Renorm(i,j))
1034 RenormV(i,j) = op5*(Renorm(i,j-1)+Renorm(i,j))
1035 ENDDO
1036 ENDDO
1037
0d1e4b948d Mich*1038
1039 DO k=1,Nr
4578baf364 Jean*1040 DO j=1-OLy+1,sNy+OLy
1041 DO i=1-OLx+1,sNx+OLx
df226773af Mich*1042 ustar(i,j,k) = -RenormU(i,j)*Xix(i,j,k)/coriU(i,j)
0d1e4b948d Mich*1043 ENDDO
1044 ENDDO
0ff5c71d8d Jean*1045 ENDDO
0d1e4b948d Mich*1046
1047
1048 DO k=1,Nr
4578baf364 Jean*1049 DO j=1-OLy+1,sNy+OLy
1050 DO i=1-OLx+1,sNx+OLx
df226773af Mich*1051 vstar(i,j,k) = -RenormV(i,j)*Xiy(i,j,k)/coriV(i,j)
0d1e4b948d Mich*1052 ENDDO
1053 ENDDO
0ff5c71d8d Jean*1054 ENDDO
0d1e4b948d Mich*1055
1056
1057
1058
05118ac017 Jean*1059 #ifdef GM_BATES_PASSIVE
0d1e4b948d Mich*1060 k=Nr
4578baf364 Jean*1061 DO j=1-OLy,sNy+OLy
1062 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*1063 psistar(i,j,Nr) = -hfacS(i,j,k,bi,bj)*drF(k)*vstar(i,j,k)
1064 ENDDO
1065 ENDDO
1066 DO k=Nr-1,1,-1
4578baf364 Jean*1067 DO j=1-OLy,sNy+OLy
1068 DO i=1-OLx,sNx+OLx
0d1e4b948d Mich*1069 psistar(i,j,k) = psistar(i,j,k+1)
1070 & - hfacS(i,j,k,bi,bj)*drF(k)*vstar(i,j,k)
1071 ENDDO
1072 ENDDO
1073 ENDDO
0ff5c71d8d Jean*1074
0d1e4b948d Mich*1075 #else
1076
1077 IF (GM_AdvForm) THEN
1078 k=Nr
4578baf364 Jean*1079 DO j=1-OLy+1,sNy+1
1080 DO i=1-OLx+1,sNx+1
0d1e4b948d Mich*1081 GM_PsiX(i,j,k,bi,bj) = -hfacW(i,j,k,bi,bj)*drF(k)*ustar(i,j,k)
1082 GM_PsiY(i,j,k,bi,bj) = -hfacS(i,j,k,bi,bj)*drF(k)*vstar(i,j,k)
1083 ENDDO
1084 ENDDO
1085 DO k=Nr-1,1,-1
4578baf364 Jean*1086 DO j=1-OLy+1,sNy+1
1087 DO i=1-OLx+1,sNx+1
0d1e4b948d Mich*1088 GM_PsiX(i,j,k,bi,bj) = GM_PsiX(i,j,k+1,bi,bj)
1089 & - hfacW(i,j,k,bi,bj)*drF(k)*ustar(i,j,k)
1090 GM_PsiY(i,j,k,bi,bj) = GM_PsiY(i,j,k+1,bi,bj)
1091 & - hfacS(i,j,k,bi,bj)*drF(k)*vstar(i,j,k)
1092 ENDDO
1093 ENDDO
1094 ENDDO
1095
1096 ENDIF
1097 #endif
1098
1099 #ifdef ALLOW_DIAGNOSTICS
1100
1101 IF ( useDiagnostics ) THEN
05118ac017 Jean*1102 CALL DIAGNOSTICS_FILL( GM_BatesK3d, 'GM_BaK ',
1103 I 0, Nr, 1, bi, bj, myThid )
0ff5c71d8d Jean*1104 CALL DIAGNOSTICS_FILL(KPV, 'GM_KPV ',0,Nr,2,bi,bj,myThid)
1105 CALL DIAGNOSTICS_FILL(urms, 'GM_URMS ',0,Nr,2,bi,bj,myThid)
1106 CALL DIAGNOSTICS_FILL(Rdef, 'GM_RDEF ',0, 1,1,bi,bj,myThid)
1107 CALL DIAGNOSTICS_FILL(Rurms, 'GM_RURMS',0, 1,2,bi,bj,myThid)
1108 CALL DIAGNOSTICS_FILL(RRhines,'GM_RRHNS',0, 1,2,bi,bj,myThid)
1109 CALL DIAGNOSTICS_FILL(Rmix, 'GM_RMIX ',0, 1,2,bi,bj,myThid)
1110 CALL DIAGNOSTICS_FILL(supp, 'GM_SUPP ',0,Nr,2,bi,bj,myThid)
1111 CALL DIAGNOSTICS_FILL(Xix, 'GM_Xix ',0,Nr,2,bi,bj,myThid)
1112 CALL DIAGNOSTICS_FILL(Xiy, 'GM_Xiy ',0,Nr,2,bi,bj,myThid)
1113 CALL DIAGNOSTICS_FILL(cDopp, 'GM_C ',0, 1,2,bi,bj,myThid)
1114 CALL DIAGNOSTICS_FILL(Ubaro, 'GM_UBARO',0, 1,2,bi,bj,myThid)
1115 CALL DIAGNOSTICS_FILL(eady, 'GM_EADY ',0, 1,2,bi,bj,myThid)
1116 CALL DIAGNOSTICS_FILL(SlopeX, 'GM_Sx ',0,Nr,2,bi,bj,myThid)
1117 CALL DIAGNOSTICS_FILL(SlopeY, 'GM_Sy ',0,Nr,2,bi,bj,myThid)
1118 CALL DIAGNOSTICS_FILL(tfluxX, 'GM_TFLXX',0,Nr,2,bi,bj,myThid)
1119 CALL DIAGNOSTICS_FILL(tfluxY, 'GM_TFLXY',0,Nr,2,bi,bj,myThid)
1120 CALL DIAGNOSTICS_FILL(gradqx, 'GM_dqdx ',0,Nr,2,bi,bj,myThid)
1121 CALL DIAGNOSTICS_FILL(gradqy, 'GM_dqdy ',0,Nr,2,bi,bj,myThid)
1122 CALL DIAGNOSTICS_FILL(Kdqdy, 'GM_Kdqdy',0,Nr,2,bi,bj,myThid)
1123 CALL DIAGNOSTICS_FILL(Kdqdx, 'GM_Kdqdx',0,Nr,2,bi,bj,myThid)
1124 CALL DIAGNOSTICS_FILL(surfkz, 'GM_SFLYR',0, 1,2,bi,bj,myThid)
1125 CALL DIAGNOSTICS_FILL(ustar, 'GM_USTAR',0,Nr,2,bi,bj,myThid)
1126 CALL DIAGNOSTICS_FILL(vstar, 'GM_VSTAR',0,Nr,2,bi,bj,myThid)
1127 CALL DIAGNOSTICS_FILL(umc, 'GM_UMC ',0,Nr,2,bi,bj,myThid)
1128 CALL DIAGNOSTICS_FILL(ubar, 'GM_UBAR ',0,Nr,2,bi,bj,myThid)
1129 CALL DIAGNOSTICS_FILL(modesC, 'GM_MODEC',0,Nr,1,bi,bj,myThid)
1130 CALL DIAGNOSTICS_FILL(M4loc, 'GM_M4 ',0,Nr,2,bi,bj,myThid)
1131 CALL DIAGNOSTICS_FILL(N2loc, 'GM_N2 ',0,Nr,2,bi,bj,myThid)
1132 CALL DIAGNOSTICS_FILL(M4onN2, 'GM_M4_N2',0,Nr,2,bi,bj,myThid)
1133 CALL DIAGNOSTICS_FILL(slopeC, 'GM_SLOPE',0,Nr,2,bi,bj,myThid)
1134 CALL DIAGNOSTICS_FILL(Renorm, 'GM_RENRM',0, 1,2,bi,bj,myThid)
05118ac017 Jean*1135 #ifdef GM_BATES_PASSIVE
74e46366ba Davi*1136 CALL DIAGNOSTICS_FILL(psistar,'GM_PSTAR',0,Nr,2,bi,bj,myThid)
1137 #endif
0d1e4b948d Mich*1138 ENDIF
1139 #endif
1140
05118ac017 Jean*1141
1142
1143 IF (GM_Bates_constRedi) THEN
952f8e8fd1 Mich*1144 DO k=1,Nr
4578baf364 Jean*1145 DO j=1-OLy,sNy+OLy
1146 DO i=1-OLx,sNx+OLx
05118ac017 Jean*1147 GM_BatesK3d(i,j,k,bi,bj) = GM_Bates_constK
952f8e8fd1 Mich*1148 ENDDO
1149 ENDDO
1150 ENDDO
1151 ENDIF
1152
40312237e2 Mich*1153 #ifdef ALLOW_DIAGNOSTICS
0ff5c71d8d Jean*1154 IF ( useDiagnostics )
05118ac017 Jean*1155 & CALL DIAGNOSTICS_FILL( GM_BatesK3d, 'GM_BaK_T',
1156 I 0, Nr, 1, bi, bj, myThid )
40312237e2 Mich*1157 #endif
1158
05118ac017 Jean*1159 #endif /* GM_BATES_K3D */
0d1e4b948d Mich*1160 RETURN
1161 END