1 |
adcroft |
1.4 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/dynamics.F,v 1.3 1998/04/29 21:31:09 adcroft Exp $ |
2 |
cnh |
1.1 |
|
3 |
|
|
#include "CPP_EEOPTIONS.h" |
4 |
|
|
|
5 |
|
|
SUBROUTINE DYNAMICS(myThid) |
6 |
|
|
C /==========================================================\ |
7 |
|
|
C | SUBROUTINE DYNAMICS | |
8 |
|
|
C | o Controlling routine for the explicit part of the model | |
9 |
|
|
C | dynamics. | |
10 |
|
|
C |==========================================================| |
11 |
|
|
C | This routine evaluates the "dynamics" terms for each | |
12 |
|
|
C | block of ocean in turn. Because the blocks of ocean have | |
13 |
|
|
C | overlap regions they are independent of one another. | |
14 |
|
|
C | If terms involving lateral integrals are needed in this | |
15 |
|
|
C | routine care will be needed. Similarly finite-difference | |
16 |
|
|
C | operations with stencils wider than the overlap region | |
17 |
|
|
C | require special consideration. | |
18 |
|
|
C | Notes | |
19 |
|
|
C | ===== | |
20 |
|
|
C | C*P* comments indicating place holders for which code is | |
21 |
|
|
C | presently being developed. | |
22 |
|
|
C \==========================================================/ |
23 |
|
|
|
24 |
|
|
C == Global variables === |
25 |
|
|
#include "SIZE.h" |
26 |
|
|
#include "EEPARAMS.h" |
27 |
|
|
#include "CG2D.h" |
28 |
adcroft |
1.3 |
#include "DYNVARS.h" |
29 |
cnh |
1.1 |
|
30 |
|
|
C == Routine arguments == |
31 |
|
|
C myThid - Thread number for this instance of the routine. |
32 |
|
|
INTEGER myThid |
33 |
|
|
|
34 |
|
|
C == Local variables |
35 |
|
|
C xA, yA - Per block temporaries holding face areas |
36 |
|
|
C uTrans, vTrans, wTrans - Per block temporaries holding flow transport |
37 |
|
|
C o uTrans: Zonal transport |
38 |
|
|
C o vTrans: Meridional transport |
39 |
|
|
C o wTrans: Vertical transport |
40 |
|
|
C maskC,maskUp o maskC: land/water mask for tracer cells |
41 |
|
|
C o maskUp: land/water mask for W points |
42 |
|
|
C aTerm, xTerm, cTerm - Work arrays for holding separate terms in |
43 |
|
|
C mTerm, pTerm, tendency equations. |
44 |
|
|
C fZon, fMer, fVer[STUV] o aTerm: Advection term |
45 |
|
|
C o xTerm: Mixing term |
46 |
|
|
C o cTerm: Coriolis term |
47 |
|
|
C o mTerm: Metric term |
48 |
|
|
C o pTerm: Pressure term |
49 |
|
|
C o fZon: Zonal flux term |
50 |
|
|
C o fMer: Meridional flux term |
51 |
|
|
C o fVer: Vertical flux term - note fVer |
52 |
|
|
C is "pipelined" in the vertical |
53 |
|
|
C so we need an fVer for each |
54 |
|
|
C variable. |
55 |
|
|
C iMin, iMax - Ranges and sub-block indices on which calculations |
56 |
|
|
C jMin, jMax are applied. |
57 |
|
|
C bi, bj |
58 |
|
|
C k, kUp, kDown, kM1 - Index for layer above and below. kUp and kDown |
59 |
|
|
C are switched with layer to be the appropriate index |
60 |
|
|
C into fVerTerm |
61 |
|
|
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
62 |
|
|
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
63 |
|
|
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
64 |
|
|
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
65 |
|
|
_RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
66 |
|
|
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
67 |
|
|
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
|
|
_RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
69 |
|
|
_RL xTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
|
|
_RL cTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
71 |
|
|
_RL mTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
72 |
|
|
_RL pTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
73 |
|
|
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
74 |
|
|
_RL fMer (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
75 |
|
|
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
76 |
|
|
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
77 |
|
|
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
78 |
|
|
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
79 |
|
|
_RL pH (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
80 |
adcroft |
1.3 |
_RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
81 |
|
|
_RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
82 |
adcroft |
1.4 |
_RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
83 |
|
|
_RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
84 |
cnh |
1.1 |
INTEGER iMin, iMax |
85 |
|
|
INTEGER jMin, jMax |
86 |
|
|
INTEGER bi, bj |
87 |
|
|
INTEGER i, j |
88 |
|
|
INTEGER k, kM1, kUp, kDown |
89 |
|
|
|
90 |
|
|
C-- Set up work arrays with valid (i.e. not NaN) values |
91 |
|
|
C These inital values do not alter the numerical results. They |
92 |
|
|
C just ensure that all memory references are to valid floating |
93 |
|
|
C point numbers. This prevents spurious hardware signals due to |
94 |
|
|
C uninitialised but inert locations. |
95 |
|
|
DO j=1-OLy,sNy+OLy |
96 |
|
|
DO i=1-OLx,sNx+OLx |
97 |
|
|
xA(i,j) = 0.*1. _d 37 |
98 |
|
|
yA(i,j) = 0.*1. _d 37 |
99 |
|
|
uTrans(i,j) = 0.*1. _d 37 |
100 |
|
|
vTrans(i,j) = 0.*1. _d 37 |
101 |
|
|
aTerm(i,j) = 0.*1. _d 37 |
102 |
|
|
xTerm(i,j) = 0.*1. _d 37 |
103 |
|
|
cTerm(i,j) = 0.*1. _d 37 |
104 |
|
|
mTerm(i,j) = 0.*1. _d 37 |
105 |
|
|
pTerm(i,j) = 0.*1. _d 37 |
106 |
|
|
fZon(i,j) = 0.*1. _d 37 |
107 |
|
|
fMer(i,j) = 0.*1. _d 37 |
108 |
|
|
DO K=1,nZ |
109 |
|
|
pH (i,j,k) = 0.*1. _d 37 |
110 |
|
|
ENDDO |
111 |
adcroft |
1.3 |
rhokm1(i,j) = 0. _d 0 |
112 |
|
|
rhokp1(i,j) = 0. _d 0 |
113 |
cnh |
1.1 |
ENDDO |
114 |
|
|
ENDDO |
115 |
|
|
C-- Set up work arrays that need valid initial values |
116 |
|
|
DO j=1-OLy,sNy+OLy |
117 |
|
|
DO i=1-OLx,sNx+OLx |
118 |
|
|
wTrans(i,j) = 0. _d 0 |
119 |
|
|
fVerT(i,j,1) = 0. _d 0 |
120 |
|
|
fVerT(i,j,2) = 0. _d 0 |
121 |
|
|
fVerS(i,j,1) = 0. _d 0 |
122 |
|
|
fVerS(i,j,2) = 0. _d 0 |
123 |
|
|
fVerU(i,j,1) = 0. _d 0 |
124 |
|
|
fVerU(i,j,2) = 0. _d 0 |
125 |
|
|
fVerV(i,j,1) = 0. _d 0 |
126 |
|
|
fVerV(i,j,2) = 0. _d 0 |
127 |
|
|
ENDDO |
128 |
|
|
ENDDO |
129 |
|
|
|
130 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
131 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
132 |
|
|
|
133 |
adcroft |
1.3 |
C-- Boundary condition on hydrostatic pressure is pH(z=0)=0 |
134 |
|
|
DO j=1-OLy,sNy+OLy |
135 |
|
|
DO i=1-OLx,sNx+OLx |
136 |
|
|
pH(i,j,1) = 0. _d 0 |
137 |
|
|
ENDDO |
138 |
|
|
ENDDO |
139 |
|
|
|
140 |
cnh |
1.1 |
iMin = 1-OLx+1 |
141 |
|
|
iMax = sNx+OLx |
142 |
|
|
jMin = 1-OLy+1 |
143 |
|
|
jMax = sNy+OLy |
144 |
|
|
|
145 |
adcroft |
1.4 |
C-- Calculate gradient of surface pressure |
146 |
|
|
CALL GRAD_PSURF( |
147 |
|
|
I bi,bj,iMin,iMax,jMin,jMax, |
148 |
|
|
O pSurfX,pSurfY, |
149 |
|
|
I myThid) |
150 |
|
|
|
151 |
|
|
C-- Update fields in top level according to tendency terms |
152 |
cnh |
1.1 |
CALL TIMESTEP( |
153 |
adcroft |
1.4 |
I bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid) |
154 |
cnh |
1.1 |
|
155 |
adcroft |
1.3 |
DO K=2,Nz |
156 |
adcroft |
1.4 |
C-- Update fields in Kth level according to tendency terms |
157 |
|
|
CALL TIMESTEP( |
158 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid) |
159 |
adcroft |
1.3 |
C Density of K-1 level (above W(K)) reference to K level |
160 |
|
|
CALL FIND_RHO( |
161 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, K-1, K, 'LINEAR', |
162 |
|
|
O rhoKm1, |
163 |
|
|
I myThid ) |
164 |
|
|
C Density of K level (below W(K)) reference to K level |
165 |
|
|
CALL FIND_RHO( |
166 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, K, K, 'LINEAR', |
167 |
|
|
O rhoKp1, |
168 |
|
|
I myThid ) |
169 |
cnh |
1.1 |
C-- Calculate static stability and mix where convectively unstable |
170 |
adcroft |
1.3 |
CALL CONVECT( |
171 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1,myThid) |
172 |
|
|
C Density of K-1 level (above W(K)) reference to K-1 level |
173 |
|
|
CALL FIND_RHO( |
174 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, K-1, K-1, 'LINEAR', |
175 |
|
|
O rhoKm1, |
176 |
|
|
I myThid ) |
177 |
|
|
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
178 |
|
|
CALL CALC_PH( |
179 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1, |
180 |
|
|
U pH, |
181 |
|
|
I myThid ) |
182 |
|
|
ENDDO ! K |
183 |
|
|
|
184 |
|
|
C Density of Nz level (bottom level) reference to Nz level |
185 |
|
|
CALL FIND_RHO( |
186 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, Nz, Nz, 'LINEAR', |
187 |
|
|
O rhoKm1, |
188 |
|
|
I myThid ) |
189 |
cnh |
1.1 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
190 |
adcroft |
1.3 |
CALL CALC_PH( |
191 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,Nz+1,rhoKm1, |
192 |
|
|
U pH, |
193 |
cnh |
1.1 |
I myThid ) |
194 |
|
|
|
195 |
|
|
DO K = Nz, 1, -1 |
196 |
|
|
kM1 =max(1,k-1) ! Points to level above k (=k-1) |
197 |
|
|
kUp =1+MOD(k+1,2) ! Cycles through 1,2 to point to layer above |
198 |
|
|
kDown=1+MOD(k,2) ! Cycles through 2,1 to point to current layer |
199 |
|
|
iMin = 1-OLx+2 |
200 |
|
|
iMax = sNx+OLx-1 |
201 |
|
|
jMin = 1-OLy+2 |
202 |
|
|
jMax = sNy+OLy-1 |
203 |
|
|
|
204 |
|
|
C-- Get temporary terms used by tendency routines |
205 |
|
|
CALL CALC_COMMON_FACTORS ( |
206 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
207 |
|
|
O xA,yA,uTrans,vTrans,wTrans,maskC,maskUp, |
208 |
|
|
I myThid) |
209 |
|
|
|
210 |
|
|
C-- Calculate accelerations in the momentum equations |
211 |
|
|
CALL CALC_MOM_RHS( |
212 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
213 |
|
|
I xA,yA,uTrans,vTrans,wTrans,maskC, |
214 |
|
|
I pH, |
215 |
|
|
U aTerm,xTerm,cTerm,mTerm,pTerm, |
216 |
|
|
U fZon, fMer, fVerU, fVerV, |
217 |
|
|
I myThid) |
218 |
|
|
|
219 |
|
|
C-- Calculate active tracer tendencies |
220 |
|
|
CALL CALC_GT( |
221 |
|
|
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
222 |
|
|
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
223 |
|
|
U aTerm,xTerm,fZon,fMer,fVerT, |
224 |
|
|
I myThid) |
225 |
|
|
Cdbg CALL CALC_GS( |
226 |
|
|
Cdbg I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
227 |
|
|
Cdbg I xA,yA,uTrans,vTrans,wTrans,maskUp, |
228 |
|
|
Cdbg U aTerm,xTerm,fZon,fMer,fVerS, |
229 |
|
|
Cdbg I myThid) |
230 |
|
|
|
231 |
|
|
ENDDO |
232 |
|
|
|
233 |
|
|
ENDDO |
234 |
|
|
ENDDO |
235 |
|
|
|
236 |
|
|
RETURN |
237 |
|
|
END |