39 |
C == Local variables |
C == Local variables |
40 |
C xA, yA - Per block temporaries holding face areas |
C xA, yA - Per block temporaries holding face areas |
41 |
C uTrans, vTrans, wTrans - Per block temporaries holding flow transport |
C uTrans, vTrans, wTrans - Per block temporaries holding flow transport |
42 |
C o uTrans: Zonal transport |
C wVel o uTrans: Zonal transport |
43 |
C o vTrans: Meridional transport |
C o vTrans: Meridional transport |
44 |
C o wTrans: Vertical transport |
C o wTrans: Vertical transport |
45 |
|
C o wVel: Vertical velocity at upper and lower |
46 |
|
C cell faces. |
47 |
C maskC,maskUp o maskC: land/water mask for tracer cells |
C maskC,maskUp o maskC: land/water mask for tracer cells |
48 |
C o maskUp: land/water mask for W points |
C o maskUp: land/water mask for W points |
49 |
C aTerm, xTerm, cTerm - Work arrays for holding separate terms in |
C aTerm, xTerm, cTerm - Work arrays for holding separate terms in |
70 |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
71 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
72 |
_RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
73 |
|
_RL wVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
74 |
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
75 |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
76 |
_RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
94 |
_RL K23 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
_RL K23 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
95 |
_RL K33 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
_RL K33 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
96 |
_RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
97 |
|
_RL KappaZT(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nz) |
98 |
|
|
99 |
INTEGER iMin, iMax |
INTEGER iMin, iMax |
100 |
INTEGER jMin, jMax |
INTEGER jMin, jMax |
101 |
INTEGER bi, bj |
INTEGER bi, bj |
102 |
INTEGER i, j |
INTEGER i, j |
103 |
INTEGER k, kM1, kUp, kDown |
INTEGER k, kM1, kUp, kDown |
104 |
|
|
105 |
|
C--- The algorithm... |
106 |
|
C |
107 |
|
C "Correction Step" |
108 |
|
C ================= |
109 |
|
C Here we update the horizontal velocities with the surface |
110 |
|
C pressure such that the resulting flow is either consistent |
111 |
|
C with the free-surface evolution or the rigid-lid: |
112 |
|
C U[n] = U* + dt x d/dx P |
113 |
|
C V[n] = V* + dt x d/dy P |
114 |
|
C |
115 |
|
C "Calculation of Gs" |
116 |
|
C =================== |
117 |
|
C This is where all the accelerations and tendencies (ie. |
118 |
|
C physics, parameterizations etc...) are calculated |
119 |
|
C w = sum_z ( div. u[n] ) |
120 |
|
C rho = rho ( theta[n], salt[n] ) |
121 |
|
C K31 = K31 ( rho ) |
122 |
|
C Gu[n] = Gu( u[n], v[n], w, rho, Ph, ... ) |
123 |
|
C Gv[n] = Gv( u[n], v[n], w, rho, Ph, ... ) |
124 |
|
C Gt[n] = Gt( theta[n], u[n], v[n], w, K31, ... ) |
125 |
|
C Gs[n] = Gs( salt[n], u[n], v[n], w, K31, ... ) |
126 |
|
C |
127 |
|
C "Time-stepping" or "Prediction" |
128 |
|
C ================================ |
129 |
|
C The models variables are stepped forward with the appropriate |
130 |
|
C time-stepping scheme (currently we use Adams-Bashforth II) |
131 |
|
C - For momentum, the result is always *only* a "prediction" |
132 |
|
C in that the flow may be divergent and will be "corrected" |
133 |
|
C later with a surface pressure gradient. |
134 |
|
C - Normally for tracers the result is the new field at time |
135 |
|
C level [n+1} *BUT* in the case of implicit diffusion the result |
136 |
|
C is also *only* a prediction. |
137 |
|
C - We denote "predictors" with an asterisk (*). |
138 |
|
C U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] ) |
139 |
|
C V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] ) |
140 |
|
C theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
141 |
|
C salt[n+1] = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
142 |
|
C With implicit diffusion: |
143 |
|
C theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
144 |
|
C salt* = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
145 |
|
C (1 + dt * K * d_zz) theta[n] = theta* |
146 |
|
C (1 + dt * K * d_zz) salt[n] = salt* |
147 |
|
C--- |
148 |
|
|
149 |
C-- Set up work arrays with valid (i.e. not NaN) values |
C-- Set up work arrays with valid (i.e. not NaN) values |
150 |
C These inital values do not alter the numerical results. They |
C These inital values do not alter the numerical results. They |
151 |
C just ensure that all memory references are to valid floating |
C just ensure that all memory references are to valid floating |
169 |
K13(i,j,k) = 0. _d 0 |
K13(i,j,k) = 0. _d 0 |
170 |
K23(i,j,k) = 0. _d 0 |
K23(i,j,k) = 0. _d 0 |
171 |
K33(i,j,k) = 0. _d 0 |
K33(i,j,k) = 0. _d 0 |
172 |
|
KappaZT(i,j,k) = 0. _d 0 |
173 |
ENDDO |
ENDDO |
174 |
rhokm1(i,j) = 0. _d 0 |
rhokm1(i,j) = 0. _d 0 |
175 |
rhokp1(i,j) = 0. _d 0 |
rhokp1(i,j) = 0. _d 0 |
180 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
181 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
182 |
|
|
|
C-- Boundary condition on hydrostatic pressure is pH(z=0)=0 |
|
|
DO j=1-OLy,sNy+OLy |
|
|
DO i=1-OLx,sNx+OLx |
|
|
pH(i,j,1) = 0. _d 0 |
|
|
K13(i,j,1) = 0. _d 0 |
|
|
K23(i,j,1) = 0. _d 0 |
|
|
K33(i,j,1) = 0. _d 0 |
|
|
KapGM(i,j) = 0. _d 0 |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
183 |
C-- Set up work arrays that need valid initial values |
C-- Set up work arrays that need valid initial values |
184 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
185 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
186 |
wTrans(i,j) = 0. _d 0 |
wTrans(i,j) = 0. _d 0 |
187 |
|
wVel (i,j,1) = 0. _d 0 |
188 |
|
wVel (i,j,2) = 0. _d 0 |
189 |
fVerT(i,j,1) = 0. _d 0 |
fVerT(i,j,1) = 0. _d 0 |
190 |
fVerT(i,j,2) = 0. _d 0 |
fVerT(i,j,2) = 0. _d 0 |
191 |
fVerS(i,j,1) = 0. _d 0 |
fVerS(i,j,1) = 0. _d 0 |
194 |
fVerU(i,j,2) = 0. _d 0 |
fVerU(i,j,2) = 0. _d 0 |
195 |
fVerV(i,j,1) = 0. _d 0 |
fVerV(i,j,1) = 0. _d 0 |
196 |
fVerV(i,j,2) = 0. _d 0 |
fVerV(i,j,2) = 0. _d 0 |
197 |
|
pH(i,j,1) = 0. _d 0 |
198 |
|
K13(i,j,1) = 0. _d 0 |
199 |
|
K23(i,j,1) = 0. _d 0 |
200 |
|
K33(i,j,1) = 0. _d 0 |
201 |
|
KapGM(i,j) = 0. _d 0 |
202 |
ENDDO |
ENDDO |
203 |
ENDDO |
ENDDO |
204 |
|
|
214 |
I myThid) |
I myThid) |
215 |
|
|
216 |
C-- Update fields in top level according to tendency terms |
C-- Update fields in top level according to tendency terms |
217 |
CALL TIMESTEP( |
CALL CORRECTION_STEP( |
218 |
I bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid) |
I bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid) |
219 |
|
|
220 |
C-- Density of 1st level (below W(1)) reference to level 1 |
C-- Density of 1st level (below W(1)) reference to level 1 |
227 |
I bi,bj,iMin,iMax,jMin,jMax,1,rhoKm1,rhoKm1, |
I bi,bj,iMin,iMax,jMin,jMax,1,rhoKm1,rhoKm1, |
228 |
U pH, |
U pH, |
229 |
I myThid ) |
I myThid ) |
230 |
DO J=1-Oly,sNy+Oly |
DO J=jMin,jMax |
231 |
DO I=1-Olx,sNx+Olx |
DO I=iMin,iMax |
232 |
rhoKp1(I,J)=rhoKm1(I,J) |
rhoKp1(I,J)=rhoKm1(I,J) |
233 |
ENDDO |
ENDDO |
234 |
ENDDO |
ENDDO |
235 |
|
|
236 |
DO K=2,Nz |
DO K=2,Nz |
237 |
C-- Update fields in Kth level according to tendency terms |
C-- Update fields in Kth level according to tendency terms |
238 |
CALL TIMESTEP( |
CALL CORRECTION_STEP( |
239 |
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid) |
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid) |
240 |
C-- Density of K-1 level (above W(K)) reference to K-1 level |
C-- Density of K-1 level (above W(K)) reference to K-1 level |
241 |
copt CALL FIND_RHO( |
copt CALL FIND_RHO( |
243 |
copt O rhoKm1, |
copt O rhoKm1, |
244 |
copt I myThid ) |
copt I myThid ) |
245 |
C rhoKm1=rhoKp1 |
C rhoKm1=rhoKp1 |
246 |
DO J=1-Oly,sNy+Oly |
DO J=jMin,jMax |
247 |
DO I=1-Olx,sNx+Olx |
DO I=iMin,iMax |
248 |
rhoKm1(I,J)=rhoKp1(I,J) |
rhoKm1(I,J)=rhoKp1(I,J) |
249 |
ENDDO |
ENDDO |
250 |
ENDDO |
ENDDO |
266 |
I myThid ) |
I myThid ) |
267 |
C-- Calculate static stability and mix where convectively unstable |
C-- Calculate static stability and mix where convectively unstable |
268 |
CALL CONVECT( |
CALL CONVECT( |
269 |
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1, |
I bi,bj,iMin,iMax,jMin,jMax,K,rhotmp,rhoKp1, |
270 |
I myTime,myIter,myThid) |
I myTime,myIter,myThid) |
271 |
C-- Density of K-1 level (above W(K)) reference to K-1 level |
C-- Density of K-1 level (above W(K)) reference to K-1 level |
272 |
CALL FIND_RHO( |
CALL FIND_RHO( |
284 |
U pH, |
U pH, |
285 |
I myThid ) |
I myThid ) |
286 |
|
|
287 |
|
ENDDO ! K |
288 |
|
|
289 |
|
C-- Initial boundary condition on barotropic divergence integral |
290 |
|
DO j=1-OLy,sNy+OLy |
291 |
|
DO i=1-OLx,sNx+OLx |
292 |
|
cg2d_b(i,j,bi,bj) = 0. _d 0 |
293 |
|
ENDDO |
294 |
ENDDO |
ENDDO |
295 |
|
|
296 |
DO K = Nz, 1, -1 |
DO K = Nz, 1, -1 |
305 |
C-- Get temporary terms used by tendency routines |
C-- Get temporary terms used by tendency routines |
306 |
CALL CALC_COMMON_FACTORS ( |
CALL CALC_COMMON_FACTORS ( |
307 |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
308 |
O xA,yA,uTrans,vTrans,wTrans,maskC,maskUp, |
O xA,yA,uTrans,vTrans,wTrans,wVel,maskC,maskUp, |
309 |
|
I myThid) |
310 |
|
|
311 |
|
C-- Calculate the total vertical diffusivity |
312 |
|
CALL CALC_DIFFUSIVITY( |
313 |
|
I bi,bj,iMin,iMax,jMin,jMax,K, |
314 |
|
I maskC,maskUp,KapGM,K33, |
315 |
|
O KappaZT, |
316 |
I myThid) |
I myThid) |
317 |
|
|
318 |
C-- Calculate accelerations in the momentum equations |
C-- Calculate accelerations in the momentum equations |
319 |
IF ( momStepping ) THEN |
IF ( momStepping ) THEN |
320 |
CALL CALC_MOM_RHS( |
CALL CALC_MOM_RHS( |
321 |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
322 |
I xA,yA,uTrans,vTrans,wTrans,maskC, |
I xA,yA,uTrans,vTrans,wTrans,wVel,maskC, |
323 |
I pH, |
I pH, |
324 |
U aTerm,xTerm,cTerm,mTerm,pTerm, |
U aTerm,xTerm,cTerm,mTerm,pTerm, |
325 |
U fZon, fMer, fVerU, fVerV, |
U fZon, fMer, fVerU, fVerV, |
331 |
CALL CALC_GT( |
CALL CALC_GT( |
332 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
333 |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
334 |
I K13,K23,K33,KapGM, |
I K13,K23,KappaZT,KapGM, |
335 |
U aTerm,xTerm,fZon,fMer,fVerT, |
U aTerm,xTerm,fZon,fMer,fVerT, |
336 |
I myThid) |
I myThid) |
337 |
ENDIF |
ENDIF |
342 |
Cdbg U aTerm,xTerm,fZon,fMer,fVerS, |
Cdbg U aTerm,xTerm,fZon,fMer,fVerS, |
343 |
Cdbg I myThid) |
Cdbg I myThid) |
344 |
|
|
345 |
ENDDO |
C-- Prediction step (step forward all model variables) |
346 |
|
CALL TIMESTEP( |
347 |
|
I bi,bj,iMin,iMax,jMin,jMax,K, |
348 |
|
I myThid) |
349 |
|
|
350 |
|
C-- Diagnose barotropic divergence of predicted fields |
351 |
|
CALL DIV_G( |
352 |
|
I bi,bj,iMin,iMax,jMin,jMax,K, |
353 |
|
I xA,yA, |
354 |
|
I myThid) |
355 |
|
|
356 |
|
ENDDO ! K |
357 |
|
|
358 |
|
C-- Implicit diffusion |
359 |
|
IF (implicitDiffusion) THEN |
360 |
|
CALL IMPLDIFF( bi, bj, iMin, iMax, jMin, jMax, |
361 |
|
I KappaZT, |
362 |
|
I myThid ) |
363 |
|
ENDIF |
364 |
|
|
365 |
ENDDO |
ENDDO |
366 |
ENDDO |
ENDDO |
367 |
|
|
368 |
!dbg write(0,*) 'dynamics: pS',minval(cg2d_x),maxval(cg2d_x) |
write(0,*) 'dynamics: pS ',minval(cg2d_x(1:sNx,1:sNy,:,:)), |
369 |
!dbg write(0,*) 'dynamics: U',minval(uVel(1:sNx,1:sNy,:,:,:)), |
& maxval(cg2d_x(1:sNx,1:sNy,:,:)) |
370 |
!dbg & maxval(uVel(1:sNx,1:sNy,:,:,:)) |
write(0,*) 'dynamics: U ',minval(uVel(1:sNx,1:sNy,:,:,:)), |
371 |
!dbg write(0,*) 'dynamics: V',minval(vVel(1:sNx,1:sNy,:,:,:)), |
& maxval(uVel(1:sNx,1:sNy,:,:,:)) |
372 |
!dbg & maxval(vVel(1:sNx,1:sNy,:,:,:)) |
write(0,*) 'dynamics: V ',minval(vVel(1:sNx,1:sNy,:,:,:)), |
373 |
!dbg write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)), |
& maxval(vVel(1:sNx,1:sNy,:,:,:)) |
374 |
!dbg & maxval(K13(1:sNx,1:sNy,:)) |
cblk write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)), |
375 |
!dbg write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)), |
cblk & maxval(K13(1:sNx,1:sNy,:)) |
376 |
!dbg & maxval(K23(1:sNx,1:sNy,:)) |
cblk write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)), |
377 |
!dbg write(0,*) 'dynamics: K33',minval(K33(1:sNx,1:sNy,:)), |
cblk & maxval(K23(1:sNx,1:sNy,:)) |
378 |
!dbg & maxval(K33(1:sNx,1:sNy,:)) |
cblk write(0,*) 'dynamics: K33',minval(K33(1:sNx,1:sNy,:)), |
379 |
!dbg write(0,*) 'dynamics: gT',minval(gT(1:sNx,1:sNy,:,:,:)), |
cblk & maxval(K33(1:sNx,1:sNy,:)) |
380 |
!dbg & maxval(gT(1:sNx,1:sNy,:,:,:)) |
write(0,*) 'dynamics: gT ',minval(gT(1:sNx,1:sNy,:,:,:)), |
381 |
!dbg write(0,*) 'dynamics: T',minval(Theta(1:sNx,1:sNy,:,:,:)), |
& maxval(gT(1:sNx,1:sNy,:,:,:)) |
382 |
!dbg & maxval(Theta(1:sNx,1:sNy,:,:,:)) |
write(0,*) 'dynamics: T ',minval(Theta(1:sNx,1:sNy,:,:,:)), |
383 |
!dbg write(0,*) 'dynamics: pH',minval(pH/(Gravity*Rhonil)), |
& maxval(Theta(1:sNx,1:sNy,:,:,:)) |
384 |
!dbg & maxval(pH/(Gravity*Rhonil)) |
cblk write(0,*) 'dynamics: pH ',minval(pH/(Gravity*Rhonil)), |
385 |
|
cblk & maxval(pH/(Gravity*Rhonil)) |
386 |
|
|
387 |
RETURN |
RETURN |
388 |
END |
END |