1 |
C $Header: /u/gcmpack/MITgcm/model/src/integr_continuity.F,v 1.20 2007/10/15 15:28:24 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: INTEGR_CONTINUITY |
9 |
C !INTERFACE: |
10 |
SUBROUTINE INTEGR_CONTINUITY( |
11 |
I bi, bj, uFld, vFld, |
12 |
I myTime, myIter, myThid ) |
13 |
C !DESCRIPTION: \bv |
14 |
C *==========================================================* |
15 |
C | SUBROUTINE INTEGR_CONTINUITY |
16 |
C | o Integrate the continuity Eq : compute vertical velocity |
17 |
C | and free surface "r-anomaly" (etaN) to satisfy |
18 |
C | exactly the convervation of the Total Volume |
19 |
C *==========================================================* |
20 |
C \ev |
21 |
|
22 |
C !USES: |
23 |
IMPLICIT NONE |
24 |
C == Global variables |
25 |
#include "SIZE.h" |
26 |
#include "EEPARAMS.h" |
27 |
#include "PARAMS.h" |
28 |
#include "DYNVARS.h" |
29 |
#include "GRID.h" |
30 |
#include "SURFACE.h" |
31 |
#include "FFIELDS.h" |
32 |
|
33 |
C !INPUT/OUTPUT PARAMETERS: |
34 |
C == Routine arguments == |
35 |
C uFld :: Zonal velocity ( m/s ) |
36 |
C vFld :: Meridional velocity ( m/s ) |
37 |
C bi,bj :: tile index |
38 |
C myTime :: Current time in simulation |
39 |
C myIter :: Current iteration number in simulation |
40 |
C myThid :: Thread number for this instance of the routine. |
41 |
_RL myTime |
42 |
INTEGER myIter |
43 |
INTEGER myThid |
44 |
INTEGER bi,bj |
45 |
_RL uFld(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
46 |
_RL vFld(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
47 |
|
48 |
C !LOCAL VARIABLES: |
49 |
C Local variables in common block |
50 |
|
51 |
C Local variables |
52 |
C i,j,k :: Loop counters |
53 |
C uTrans :: Volume transports ( uVel.xA ) |
54 |
C vTrans :: Volume transports ( vVel.yA ) |
55 |
C hDivFlow :: Div. Barotropic Flow [transport unit m3/s] |
56 |
INTEGER k |
57 |
#ifdef EXACT_CONSERV |
58 |
INTEGER i,j, ks |
59 |
_RL uTrans(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
60 |
_RL vTrans(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
61 |
_RL hDivFlow(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
62 |
_RL facEmP, facMass |
63 |
#endif /* EXACT_CONSERV */ |
64 |
#ifndef ALLOW_ADDFLUID |
65 |
_RL addMass(1) |
66 |
#endif /* ndef ALLOW_ADDFLUID */ |
67 |
CEOP |
68 |
|
69 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
70 |
|
71 |
#ifdef EXACT_CONSERV |
72 |
IF (exactConserv) THEN |
73 |
|
74 |
facEmP = 0. |
75 |
IF ( fluidIsWater.AND.useRealFreshWaterFlux ) facEmP=mass2rUnit |
76 |
facMass = 0. |
77 |
IF ( selectAddFluid.GE.1 ) facMass = mass2rUnit |
78 |
|
79 |
C-- Compute the Divergence of The Barotropic Flow : |
80 |
|
81 |
C- Initialise |
82 |
DO j=1-Oly,sNy+Oly |
83 |
DO i=1-Olx,sNx+Olx |
84 |
hDivFlow(i,j) = 0. _d 0 |
85 |
utrans(i,j) = 0. _d 0 |
86 |
vtrans(i,j) = 0. _d 0 |
87 |
ENDDO |
88 |
ENDDO |
89 |
|
90 |
DO k=1,Nr |
91 |
|
92 |
C- Calculate velocity field "volume transports" through tracer cell faces |
93 |
C anelastic: uTrans,vTrans are scaled by rhoFacC (~ mass transport). |
94 |
DO j=1,sNy+1 |
95 |
DO i=1,sNx+1 |
96 |
uTrans(i,j) = uFld(i,j,k,bi,bj)*_dyG(i,j,bi,bj) |
97 |
& *deepFacC(k)*rhoFacC(k) |
98 |
& *drF(k)*_hFacW(i,j,k,bi,bj) |
99 |
vTrans(i,j) = vFld(i,j,k,bi,bj)*_dxG(i,j,bi,bj) |
100 |
& *deepFacC(k)*rhoFacC(k) |
101 |
& *drF(k)*_hFacS(i,j,k,bi,bj) |
102 |
ENDDO |
103 |
ENDDO |
104 |
|
105 |
C- Integrate vertically the Horizontal Divergence |
106 |
DO j=1,sNy |
107 |
DO i=1,sNx |
108 |
hDivFlow(i,j) = hDivFlow(i,j) |
109 |
& +maskC(i,j,k,bi,bj)*( uTrans(i+1,j)-uTrans(i,j) |
110 |
& +vTrans(i,j+1)-vTrans(i,j) ) |
111 |
#ifdef ALLOW_ADDFLUID |
112 |
& -facMass*addMass(i,j,k,bi,bj) |
113 |
#endif /* ALLOW_ADDFLUID */ |
114 |
ENDDO |
115 |
ENDDO |
116 |
|
117 |
C- End DO k=1,Nr |
118 |
ENDDO |
119 |
|
120 |
C------------------------------------ |
121 |
C note: deep-model not implemented for P-coordinate + realFreshWaterFlux ; |
122 |
C anelastic: always assumes that rhoFacF(1) = 1 |
123 |
IF ( myTime.EQ.startTime .AND. myTime.NE.baseTime |
124 |
& .AND. fluidIsWater .AND. useRealFreshWaterFlux ) THEN |
125 |
|
126 |
C needs previous time-step value of E-P-R, that has not been loaded |
127 |
C and was not in old pickup-file ; try to use etaN & etaH instead. |
128 |
IF ( usePickupBeforeC54 ) THEN |
129 |
DO j=1,sNy |
130 |
DO i=1,sNx |
131 |
dEtaHdt(i,j,bi,bj) = (etaN(i,j,bi,bj)-etaH(i,j,bi,bj)) |
132 |
& / (implicDiv2Dflow*deltaTfreesurf) |
133 |
ENDDO |
134 |
ENDDO |
135 |
ENDIF |
136 |
|
137 |
DO j=1,sNy |
138 |
DO i=1,sNx |
139 |
PmEpR(i,j,bi,bj) = dEtaHdt(i,j,bi,bj) |
140 |
& + hDivFlow(i,j)*recip_rA(i,j,bi,bj) |
141 |
& *recip_deepFac2F(1) |
142 |
PmEpR(i,j,bi,bj) = PmEpR(i,j,bi,bj)*rUnit2mass |
143 |
ENDDO |
144 |
ENDDO |
145 |
ELSEIF ( myTime.EQ.startTime ) THEN |
146 |
DO j=1,sNy |
147 |
DO i=1,sNx |
148 |
ks = ksurfC(I,J,bi,bj) |
149 |
PmEpR(i,j,bi,bj) = 0. _d 0 |
150 |
dEtaHdt(i,j,bi,bj) = -hDivFlow(i,j)*recip_rA(i,j,bi,bj) |
151 |
& *recip_deepFac2F(ks) |
152 |
ENDDO |
153 |
ENDDO |
154 |
ELSE |
155 |
C-- Needs to get valid PmEpR (for T,S forcing) also in overlap regions |
156 |
C (e.g., if using KPP) => set over full index range |
157 |
DO j=1-OLy,sNy+OLy |
158 |
DO i=1-OLx,sNx+OLx |
159 |
PmEpR(i,j,bi,bj) = -EmPmR(i,j,bi,bj) |
160 |
ENDDO |
161 |
ENDDO |
162 |
DO j=1,sNy |
163 |
DO i=1,sNx |
164 |
ks = ksurfC(I,J,bi,bj) |
165 |
dEtaHdt(i,j,bi,bj) = -hDivFlow(i,j)*recip_rA(i,j,bi,bj) |
166 |
& *recip_deepFac2F(ks) |
167 |
& -facEmP*EmPmR(i,j,bi,bj) |
168 |
ENDDO |
169 |
ENDDO |
170 |
ENDIF |
171 |
C------------------------------------ |
172 |
|
173 |
ENDIF |
174 |
|
175 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
176 |
|
177 |
IF (exactConserv .AND. myTime.NE.startTime) THEN |
178 |
C-- Update etaN at the end of the time step : |
179 |
C Incorporate the Implicit part of -Divergence(Barotropic_Flow) |
180 |
|
181 |
IF (implicDiv2Dflow.EQ. 0. _d 0) THEN |
182 |
DO j=1-Oly,sNy+Oly |
183 |
DO i=1-Olx,sNx+Olx |
184 |
etaN(i,j,bi,bj) = etaH(i,j,bi,bj) |
185 |
ENDDO |
186 |
ENDDO |
187 |
ELSE |
188 |
DO j=1,sNy |
189 |
DO i=1,sNx |
190 |
etaN(i,j,bi,bj) = etaH(i,j,bi,bj) |
191 |
& + implicDiv2Dflow*dEtaHdt(i,j,bi,bj)*deltaTfreesurf |
192 |
ENDDO |
193 |
ENDDO |
194 |
ENDIF |
195 |
|
196 |
#ifdef ALLOW_OBCS |
197 |
C-- Apply OBC to etaN if NonLin-FreeSurf, reset to zero otherwise: |
198 |
IF ( useOBCS ) CALL OBCS_APPLY_ETA( bi, bj, etaN, myThid ) |
199 |
#endif /* ALLOW_OBCS */ |
200 |
|
201 |
ENDIF |
202 |
|
203 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
204 |
|
205 |
# ifdef NONLIN_FRSURF |
206 |
IF (select_rStar .NE. 0) THEN |
207 |
# ifndef DISABLE_RSTAR_CODE |
208 |
DO j=1,sNy |
209 |
DO i=1,sNx |
210 |
rStarDhCDt(i,j,bi,bj) = |
211 |
& dEtaHdt(i,j,bi,bj)*recip_Rcol(i,j,bi,bj) |
212 |
ENDDO |
213 |
ENDDO |
214 |
# endif /* DISABLE_RSTAR_CODE */ |
215 |
ENDIF |
216 |
# endif /* NONLIN_FRSURF */ |
217 |
|
218 |
#endif /* EXACT_CONSERV */ |
219 |
|
220 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
221 |
|
222 |
DO k=Nr,1,-1 |
223 |
C-- Integrate continuity vertically for vertical velocity |
224 |
|
225 |
CALL INTEGRATE_FOR_W( |
226 |
I bi, bj, k, uFld, vFld, addMass, |
227 |
O wVel, |
228 |
I myThid ) |
229 |
|
230 |
#ifdef EXACT_CONSERV |
231 |
IF ( k.EQ.Nr .AND. myTime.NE.baseTime .AND. usingPCoords |
232 |
& .AND. fluidIsWater .AND. useRealFreshWaterFlux ) THEN |
233 |
|
234 |
DO j=1,sNy |
235 |
DO i=1,sNx |
236 |
wVel(i,j,k,bi,bj) = wVel(i,j,k,bi,bj) |
237 |
& +mass2rUnit*PmEpR(i,j,bi,bj)*maskC(i,j,k,bi,bj) |
238 |
ENDDO |
239 |
ENDDO |
240 |
|
241 |
ENDIF |
242 |
#endif /* EXACT_CONSERV */ |
243 |
|
244 |
#ifdef ALLOW_OBCS |
245 |
C-- Apply OBC to W if in N-H mode, reset to zero otherwise: |
246 |
IF ( useOBCS ) CALL OBCS_APPLY_W( bi, bj, k, wVel, myThid ) |
247 |
#endif /* ALLOW_OBCS */ |
248 |
|
249 |
C- End DO k=Nr,1,-1 |
250 |
ENDDO |
251 |
|
252 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
253 |
|
254 |
RETURN |
255 |
END |