/[MITgcm]/MITgcm/model/src/calc_gw.F
ViewVC logotype

Annotation of /MITgcm/model/src/calc_gw.F

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


Revision 1.24 - (hide annotations) (download)
Thu Dec 15 02:06:06 2005 UTC (18 years, 5 months ago) by jmc
Branch: MAIN
Changes since 1.23: +2 -2 lines
cycle gW,gwNm1 like other tendencies (gU,gT ...) and write gwNm1 to pickup file

1 jmc 1.24 C $Header: /u/gcmpack/MITgcm/model/src/calc_gw.F,v 1.23 2005/12/13 23:16:52 jmc Exp $
2 cnh 1.9 C !DESCRIPTION: \bv
3 jmc 1.7 C $Name: $
4 edhill 1.10
5     #include "PACKAGES_CONFIG.h"
6 adcroft 1.1 #include "CPP_OPTIONS.h"
7    
8 cnh 1.9 CBOP
9     C !ROUTINE: CALC_GW
10     C !INTERFACE:
11 adcroft 1.1 SUBROUTINE CALC_GW(
12 jmc 1.20 I myTime, myIter, myThid )
13 cnh 1.9 C !DESCRIPTION: \bv
14     C *==========================================================*
15     C | S/R CALC_GW
16     C | o Calculate vert. velocity tendency terms ( NH, QH only )
17     C *==========================================================*
18     C | In NH and QH, the vertical momentum tendency must be
19     C | calculated explicitly and included as a source term
20     C | for a 3d pressure eqn. Calculate that term here.
21     C | This routine is not used in HYD calculations.
22     C *==========================================================*
23     C \ev
24    
25     C !USES:
26 adcroft 1.1 IMPLICIT NONE
27     C == Global variables ==
28     #include "SIZE.h"
29     #include "EEPARAMS.h"
30     #include "PARAMS.h"
31     #include "GRID.h"
32 jmc 1.22 #include "DYNVARS.h"
33     #include "NH_VARS.h"
34 adcroft 1.1
35 cnh 1.9 C !INPUT/OUTPUT PARAMETERS:
36 adcroft 1.1 C == Routine arguments ==
37 jmc 1.20 C myTime :: Current time in simulation
38     C myIter :: Current iteration number in simulation
39     C myThid :: Thread number for this instance of the routine.
40     _RL myTime
41     INTEGER myIter
42 adcroft 1.1 INTEGER myThid
43    
44 adcroft 1.3 #ifdef ALLOW_NONHYDROSTATIC
45    
46 cnh 1.9 C !LOCAL VARIABLES:
47 adcroft 1.1 C == Local variables ==
48 cnh 1.9 C bi, bj, :: Loop counters
49     C iMin, iMax,
50     C jMin, jMax
51     C flx_NS :: Temp. used for fVol meridional terms.
52     C flx_EW :: Temp. used for fVol zonal terms.
53     C flx_Up :: Temp. used for fVol vertical terms.
54     C flx_Dn :: Temp. used for fVol vertical terms.
55 adcroft 1.1 INTEGER bi,bj,iMin,iMax,jMin,jMax
56     _RL flx_NS(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
57     _RL flx_EW(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
58     _RL flx_Dn(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
59     _RL flx_Up(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
60 mlosch 1.18 _RL fZon(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
61     _RL fMer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
62     _RL del2w(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
63 jmc 1.21 C i,j,k - Loop counters
64     INTEGER i,j,k, kP1
65 adcroft 1.1 _RL wOverride
66 mlosch 1.15 _RS hFacWtmp
67     _RS hFacStmp
68 mlosch 1.18 _RS hFacCtmp
69     _RS recip_hFacCtmp
70 adcroft 1.1 _RL ab15,ab05
71 jmc 1.12 _RL slipSideFac
72 adcroft 1.1 _RL tmp_VbarZ, tmp_UbarZ, tmp_WbarZ
73    
74     _RL Half
75     PARAMETER(Half=0.5D0)
76 cnh 1.9 CEOP
77 edhill 1.10
78 mlosch 1.14 iMin = 1
79     iMax = sNx
80     jMin = 1
81     jMax = sNy
82    
83 adcroft 1.1 C Adams-Bashforth timestepping weights
84 jmc 1.23 IF (myIter .EQ. 0) THEN
85     ab15 = 1.0 _d 0
86     ab05 = 0.0 _d 0
87     ELSE
88     ab15 = 1.5 _d 0 + abeps
89     ab05 = -0.5 _d 0 - abeps
90     ENDIF
91 jmc 1.11
92     C Lateral friction (no-slip, free slip, or half slip):
93     IF ( no_slip_sides ) THEN
94 mlosch 1.15 slipSideFac = -1. _d 0
95 jmc 1.11 ELSE
96 mlosch 1.15 slipSideFac = 1. _d 0
97 jmc 1.11 ENDIF
98 mlosch 1.18 CML half slip was used before ; keep the line for now, but half slip is
99     CML not used anywhere in the code as far as I can see.
100 mlosch 1.14 C slipSideFac = 0. _d 0
101 jmc 1.11
102 adcroft 1.1 DO bj=myByLo(myThid),myByHi(myThid)
103     DO bi=myBxLo(myThid),myBxHi(myThid)
104     DO K=1,Nr
105     DO j=1-OLy,sNy+OLy
106     DO i=1-OLx,sNx+OLx
107     gW(i,j,k,bi,bj) = 0.
108     ENDDO
109     ENDDO
110     ENDDO
111     ENDDO
112     ENDDO
113    
114     C Catch barotropic mode
115     IF ( Nr .LT. 2 ) RETURN
116    
117     C For each tile
118     DO bj=myByLo(myThid),myByHi(myThid)
119     DO bi=myBxLo(myThid),myBxHi(myThid)
120    
121     C Boundaries condition at top
122 mlosch 1.14 DO J=jMin,jMax
123     DO I=iMin,iMax
124 adcroft 1.1 Flx_Dn(I,J,bi,bj)=0.
125     ENDDO
126     ENDDO
127    
128     C Sweep down column
129     DO K=2,Nr
130     Kp1=K+1
131     wOverRide=1.
132     if (K.EQ.Nr) then
133     Kp1=Nr
134     wOverRide=0.
135     endif
136 mlosch 1.18 C horizontal bi-harmonic dissipation
137     IF (momViscosity .AND. viscA4W.NE.0. ) THEN
138     C calculate the horizontal Laplacian of vertical flow
139     C Zonal flux d/dx W
140     DO j=1-Oly,sNy+Oly
141     fZon(1-Olx,j)=0.
142     DO i=1-Olx+1,sNx+Olx
143     fZon(i,j) = drF(k)*_hFacC(i,j,k,bi,bj)
144     & *_dyG(i,j,bi,bj)
145     & *_recip_dxC(i,j,bi,bj)
146     & *(wVel(i,j,k,bi,bj)-wVel(i-1,j,k,bi,bj))
147     #ifdef COSINEMETH_III
148     & *sqcosFacU(J,bi,bj)
149     #endif
150     ENDDO
151     ENDDO
152     C Meridional flux d/dy W
153     DO i=1-Olx,sNx+Olx
154     fMer(I,1-Oly)=0.
155     ENDDO
156     DO j=1-Oly+1,sNy+Oly
157     DO i=1-Olx,sNx+Olx
158     fMer(i,j) = drF(k)*_hFacC(i,j,k,bi,bj)
159     & *_dxG(i,j,bi,bj)
160     & *_recip_dyC(i,j,bi,bj)
161     & *(wVel(i,j,k,bi,bj)-wVel(i,j-1,k,bi,bj))
162     #ifdef ISOTROPIC_COS_SCALING
163     #ifdef COSINEMETH_III
164     & *sqCosFacV(j,bi,bj)
165     #endif
166     #endif
167     ENDDO
168     ENDDO
169    
170     C del^2 W
171     C Difference of zonal fluxes ...
172     DO j=1-Oly,sNy+Oly
173     DO i=1-Olx,sNx+Olx-1
174     del2w(i,j)=fZon(i+1,j)-fZon(i,j)
175     ENDDO
176     del2w(sNx+Olx,j)=0.
177     ENDDO
178    
179     C ... add difference of meridional fluxes and divide by volume
180     DO j=1-Oly,sNy+Oly-1
181     DO i=1-Olx,sNx+Olx
182     C First compute the fraction of open water for the w-control volume
183     C at the southern face
184     hFacCtmp=max(hFacC(I,J,K-1,bi,bj)-Half,0. _d 0)
185     & + min(hFacC(I,J,K ,bi,bj),Half)
186     IF (hFacCtmp .GT. 0.) THEN
187     recip_hFacCtmp = 1./hFacCtmp
188     ELSE
189     recip_hFacCtmp = 0. _d 0
190     ENDIF
191     del2w(i,j)=recip_rA(i,j,bi,bj)
192     & *recip_drC(k)*recip_hFacCtmp
193     & *(
194     & del2w(i,j)
195     & +( fMer(i,j+1)-fMer(i,j) )
196     & )
197     ENDDO
198     ENDDO
199     C-- No-slip BCs impose a drag at walls...
200     CML ************************************************************
201     CML No-slip Boundary conditions for bi-harmonic dissipation
202     CML need to be implemented here!
203     CML ************************************************************
204 jmc 1.21 ELSE
205     C- Initialize del2w to zero:
206     DO j=1-Oly,sNy+Oly
207     DO i=1-Olx,sNx+Olx
208     del2w(i,j) = 0. _d 0
209     ENDDO
210     ENDDO
211 mlosch 1.18 ENDIF
212    
213 adcroft 1.1 C Flux on Southern face
214 mlosch 1.14 DO J=jMin,jMax+1
215     DO I=iMin,iMax
216 mlosch 1.15 C First compute the fraction of open water for the w-control volume
217     C at the southern face
218 edhill 1.16 hFacStmp=max(hFacS(I,J,K-1,bi,bj)-Half,0. _d 0)
219 mlosch 1.15 & + min(hFacS(I,J,K ,bi,bj),Half)
220 adcroft 1.1 tmp_VbarZ=Half*(
221     & _hFacS(I,J,K-1,bi,bj)*vVel( I ,J,K-1,bi,bj)
222     & +_hFacS(I,J, K ,bi,bj)*vVel( I ,J, K ,bi,bj))
223     Flx_NS(I,J,bi,bj)=
224     & tmp_VbarZ*Half*(wVel(I,J,K,bi,bj)+wVel(I,J-1,K,bi,bj))
225 mlosch 1.17 & -viscAhW*_recip_dyC(I,J,bi,bj)
226 mlosch 1.15 & *(hFacStmp*(wVel(I,J,K,bi,bj)-wVel(I,J-1,K,bi,bj))
227     & +(1. _d 0 - hFacStmp)*(1. _d 0 - slipSideFac)
228     & *wVel(I,J,K,bi,bj))
229 mlosch 1.18 & +viscA4W*_recip_dyC(I,J,bi,bj)*(del2w(I,J)-del2w(I,J-1))
230     #ifdef ISOTROPIC_COS_SCALING
231     #ifdef COSINEMETH_III
232     & *sqCosFacV(j,bi,bj)
233     #else
234     & *CosFacV(j,bi,bj)
235     #endif
236     #endif
237 mlosch 1.15 C The last term is the weighted average of the viscous stress at the open
238     C fraction of the w control volume and at the closed fraction of the
239     C the control volume. A more compact but less intelligible version
240     C of the last three lines is:
241     CML & *( (1 _d 0 - slipSideFac*(1 _d 0 - hFacStmp))
242     CML & *wVel(I,J,K,bi,bi) + hFacStmp*wVel(I,J-1,K,bi,bj) )
243 adcroft 1.1 ENDDO
244     ENDDO
245     C Flux on Western face
246 mlosch 1.14 DO J=jMin,jMax
247     DO I=iMin,iMax+1
248 mlosch 1.15 C First compute the fraction of open water for the w-control volume
249     C at the western face
250 edhill 1.16 hFacWtmp=max(hFacW(I,J,K-1,bi,bj)-Half,0. _d 0)
251 mlosch 1.15 & + min(hFacW(I,J,K ,bi,bj),Half)
252 jmc 1.21 tmp_UbarZ=Half*(
253 adcroft 1.1 & _hFacW(I,J,K-1,bi,bj)*uVel( I ,J,K-1,bi,bj)
254     & +_hFacW(I,J, K ,bi,bj)*uVel( I ,J, K ,bi,bj))
255     Flx_EW(I,J,bi,bj)=
256     & tmp_UbarZ*Half*(wVel(I,J,K,bi,bj)+wVel(I-1,J,K,bi,bj))
257 mlosch 1.17 & -viscAhW*_recip_dxC(I,J,bi,bj)
258 mlosch 1.15 & *(hFacWtmp*(wVel(I,J,K,bi,bj)-wVel(I-1,J,K,bi,bj))
259     & +(1 _d 0 - hFacWtmp)*(1 _d 0 - slipSideFac)
260     & *wVel(I,J,K,bi,bj) )
261 mlosch 1.18 & +viscA4W*_recip_dxC(I,J,bi,bj)*(del2w(I,J)-del2w(I-1,J))
262     #ifdef COSINEMETH_III
263     & *sqCosFacU(j,bi,bj)
264     #else
265     & *CosFacU(j,bi,bj)
266     #endif
267 mlosch 1.15 C The last term is the weighted average of the viscous stress at the open
268     C fraction of the w control volume and at the closed fraction of the
269     C the control volume. A more compact but less intelligible version
270     C of the last three lines is:
271     CML & *( (1 _d 0 - slipSideFac*(1 _d 0 - hFacWtmp))
272     CML & *wVel(I,J,K,bi,bi) + hFacWtmp*wVel(I-1,J,K,bi,bj) )
273 adcroft 1.1 ENDDO
274     ENDDO
275     C Flux on Lower face
276 mlosch 1.14 DO J=jMin,jMax
277     DO I=iMin,iMax
278 adcroft 1.1 Flx_Up(I,J,bi,bj)=Flx_Dn(I,J,bi,bj)
279 mlosch 1.14 tmp_WbarZ=Half*(wVel(I,J,K,bi,bj)
280     & +wOverRide*wVel(I,J,Kp1,bi,bj))
281 adcroft 1.1 Flx_Dn(I,J,bi,bj)=
282     & tmp_WbarZ*tmp_WbarZ
283 jmc 1.11 & -viscAr*recip_drF(K)
284     & *( wVel(I,J,K,bi,bj)-wOverRide*wVel(I,J,Kp1,bi,bj) )
285 adcroft 1.1 ENDDO
286     ENDDO
287     C Divergence of fluxes
288 mlosch 1.14 DO J=jMin,jMax
289     DO I=iMin,iMax
290 adcroft 1.1 gW(I,J,K,bi,bj) = 0.
291     & -(
292     & +_recip_dxF(I,J,bi,bj)*(
293     & Flx_EW(I+1,J,bi,bj)-Flx_EW(I,J,bi,bj) )
294     & +_recip_dyF(I,J,bi,bj)*(
295     & Flx_NS(I,J+1,bi,bj)-Flx_NS(I,J,bi,bj) )
296     & +recip_drC(K) *(
297     & Flx_Up(I,J,bi,bj) -Flx_Dn(I,J,bi,bj) )
298     & )
299     caja * recip_hFacU(I,J,K,bi,bj)
300     caja NOTE: This should be included
301     caja but we need an hFacUW (above U points)
302     caja and an hFacUS (above V points) too...
303     ENDDO
304     ENDDO
305     ENDDO
306     ENDDO
307     ENDDO
308    
309 jmc 1.21
310 adcroft 1.1 DO bj=myByLo(myThid),myByHi(myThid)
311     DO bi=myBxLo(myThid),myBxHi(myThid)
312     DO K=2,Nr
313 mlosch 1.14 DO j=jMin,jMax
314     DO i=iMin,iMax
315 adcroft 1.1 wVel(i,j,k,bi,bj) = wVel(i,j,k,bi,bj)
316 adcroft 1.19 & +deltatMom*nh_Am2*( ab15*gW(i,j,k,bi,bj)
317 jmc 1.21 & +ab05*gwNm1(i,j,k,bi,bj) )
318 adcroft 1.1 IF (hFacC(I,J,K,bi,bj).EQ.0.) wVel(i,j,k,bi,bj)=0.
319 jmc 1.24 gwNm1(i,j,k,bi,bj) = gW(i,j,k,bi,bj)
320 adcroft 1.1 ENDDO
321     ENDDO
322 adcroft 1.4 ENDDO
323     ENDDO
324     ENDDO
325    
326 adcroft 1.5 #ifdef ALLOW_OBCS
327     IF (useOBCS) THEN
328 adcroft 1.4 C-- This call is aesthetic: it makes the W field
329     C consistent with the OBs but this has no algorithmic
330     C impact. This is purely for diagnostic purposes.
331 adcroft 1.5 DO bj=myByLo(myThid),myByHi(myThid)
332     DO bi=myBxLo(myThid),myBxHi(myThid)
333     DO K=1,Nr
334     CALL OBCS_APPLY_W( bi, bj, K, wVel, myThid )
335     ENDDO
336 adcroft 1.1 ENDDO
337     ENDDO
338 adcroft 1.5 ENDIF
339     #endif /* ALLOW_OBCS */
340 adcroft 1.1
341     #endif /* ALLOW_NONHYDROSTATIC */
342    
343     RETURN
344     END

  ViewVC Help
Powered by ViewVC 1.1.22