1 |
C $Id$ |
C $Header$ |
2 |
|
|
3 |
#include "CPP_EEOPTIONS.h" |
#include "CPP_EEOPTIONS.h" |
4 |
|
|
5 |
SUBROUTINE DYNAMICS(myThid) |
SUBROUTINE DYNAMICS(myTime, myIter, myThid) |
6 |
C /==========================================================\ |
C /==========================================================\ |
7 |
C | SUBROUTINE DYNAMICS | |
C | SUBROUTINE DYNAMICS | |
8 |
C | o Controlling routine for the explicit part of the model | |
C | o Controlling routine for the explicit part of the model | |
25 |
#include "SIZE.h" |
#include "SIZE.h" |
26 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
27 |
#include "CG2D.h" |
#include "CG2D.h" |
28 |
|
#include "PARAMS.h" |
29 |
|
#include "DYNVARS.h" |
30 |
|
|
31 |
C == Routine arguments == |
C == Routine arguments == |
32 |
|
C myTime - Current time in simulation |
33 |
|
C myIter - Current iteration number in simulation |
34 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
35 |
INTEGER myThid |
INTEGER myThid |
36 |
|
_RL myTime |
37 |
|
INTEGER myIter |
38 |
|
|
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 |
82 |
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
83 |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
84 |
_RL pH (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
_RL pH (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
85 |
|
_RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
86 |
|
_RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
87 |
|
_RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
88 |
|
_RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
89 |
|
_RL K13 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
90 |
|
_RL K23 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
91 |
|
_RL K33 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
92 |
|
_RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
93 |
INTEGER iMin, iMax |
INTEGER iMin, iMax |
94 |
INTEGER jMin, jMax |
INTEGER jMin, jMax |
95 |
INTEGER bi, bj |
INTEGER bi, bj |
103 |
C uninitialised but inert locations. |
C uninitialised but inert locations. |
104 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
105 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
106 |
xA(i,j) = 0.*1. _d 37 |
xA(i,j) = 0. _d 0 |
107 |
yA(i,j) = 0.*1. _d 37 |
yA(i,j) = 0. _d 0 |
108 |
uTrans(i,j) = 0.*1. _d 37 |
uTrans(i,j) = 0. _d 0 |
109 |
vTrans(i,j) = 0.*1. _d 37 |
vTrans(i,j) = 0. _d 0 |
110 |
aTerm(i,j) = 0.*1. _d 37 |
aTerm(i,j) = 0. _d 0 |
111 |
xTerm(i,j) = 0.*1. _d 37 |
xTerm(i,j) = 0. _d 0 |
112 |
cTerm(i,j) = 0.*1. _d 37 |
cTerm(i,j) = 0. _d 0 |
113 |
mTerm(i,j) = 0.*1. _d 37 |
mTerm(i,j) = 0. _d 0 |
114 |
pTerm(i,j) = 0.*1. _d 37 |
pTerm(i,j) = 0. _d 0 |
115 |
fZon(i,j) = 0.*1. _d 37 |
fZon(i,j) = 0. _d 0 |
116 |
fMer(i,j) = 0.*1. _d 37 |
fMer(i,j) = 0. _d 0 |
117 |
DO K=1,nZ |
DO K=1,nZ |
118 |
pH (i,j,k) = 0.*1. _d 37 |
pH (i,j,k) = 0. _d 0 |
119 |
|
K13(i,j,k) = 0. _d 0 |
120 |
|
K23(i,j,k) = 0. _d 0 |
121 |
|
K33(i,j,k) = 0. _d 0 |
122 |
ENDDO |
ENDDO |
123 |
ENDDO |
rhokm1(i,j) = 0. _d 0 |
124 |
ENDDO |
rhokp1(i,j) = 0. _d 0 |
|
C-- Set up work arrays that need valid initial values |
|
|
DO j=1-OLy,sNy+OLy |
|
|
DO i=1-OLx,sNx+OLx |
|
|
wTrans(i,j) = 0. _d 0 |
|
|
fVerT(i,j,1) = 0. _d 0 |
|
|
fVerT(i,j,2) = 0. _d 0 |
|
|
fVerS(i,j,1) = 0. _d 0 |
|
|
fVerS(i,j,2) = 0. _d 0 |
|
|
fVerU(i,j,1) = 0. _d 0 |
|
|
fVerU(i,j,2) = 0. _d 0 |
|
|
fVerV(i,j,1) = 0. _d 0 |
|
|
fVerV(i,j,2) = 0. _d 0 |
|
125 |
ENDDO |
ENDDO |
126 |
ENDDO |
ENDDO |
127 |
|
|
128 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
129 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
130 |
|
|
131 |
|
C-- Boundary condition on hydrostatic pressure is pH(z=0)=0 |
132 |
|
DO j=1-OLy,sNy+OLy |
133 |
|
DO i=1-OLx,sNx+OLx |
134 |
|
pH(i,j,1) = 0. _d 0 |
135 |
|
K13(i,j,1) = 0. _d 0 |
136 |
|
K23(i,j,1) = 0. _d 0 |
137 |
|
K33(i,j,1) = 0. _d 0 |
138 |
|
KapGM(i,j) = 0. _d 0 |
139 |
|
ENDDO |
140 |
|
ENDDO |
141 |
|
|
142 |
|
C-- Set up work arrays that need valid initial values |
143 |
|
DO j=1-OLy,sNy+OLy |
144 |
|
DO i=1-OLx,sNx+OLx |
145 |
|
wTrans(i,j) = 0. _d 0 |
146 |
|
fVerT(i,j,1) = 0. _d 0 |
147 |
|
fVerT(i,j,2) = 0. _d 0 |
148 |
|
fVerS(i,j,1) = 0. _d 0 |
149 |
|
fVerS(i,j,2) = 0. _d 0 |
150 |
|
fVerU(i,j,1) = 0. _d 0 |
151 |
|
fVerU(i,j,2) = 0. _d 0 |
152 |
|
fVerV(i,j,1) = 0. _d 0 |
153 |
|
fVerV(i,j,2) = 0. _d 0 |
154 |
|
ENDDO |
155 |
|
ENDDO |
156 |
|
|
157 |
iMin = 1-OLx+1 |
iMin = 1-OLx+1 |
158 |
iMax = sNx+OLx |
iMax = sNx+OLx |
159 |
jMin = 1-OLy+1 |
jMin = 1-OLy+1 |
160 |
jMax = sNy+OLy |
jMax = sNy+OLy |
161 |
|
|
162 |
C-- Update fields according to tendency terms |
C-- Calculate gradient of surface pressure |
163 |
|
CALL GRAD_PSURF( |
164 |
|
I bi,bj,iMin,iMax,jMin,jMax, |
165 |
|
O pSurfX,pSurfY, |
166 |
|
I myThid) |
167 |
|
|
168 |
|
C-- Update fields in top level according to tendency terms |
169 |
CALL TIMESTEP( |
CALL TIMESTEP( |
170 |
I bi,bj,iMin,iMax,jMin,jMax,myThid) |
I bi,bj,iMin,iMax,jMin,jMax,1,pSurfX,pSurfY,myThid) |
171 |
|
|
172 |
C-- Calculate rho with the appropriate equation of state |
C-- Density of 1st level (below W(1)) reference to level 1 |
173 |
CALL FIND_RHO( |
CALL FIND_RHO( |
174 |
I bi,bj,iMin,iMax,jMin,jMax,myThid) |
I bi, bj, iMin, iMax, jMin, jMax, 1, 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,1,rhoKm1,rhoKm1, |
180 |
|
U pH, |
181 |
|
I myThid ) |
182 |
|
|
183 |
|
DO K=2,Nz |
184 |
|
C-- Update fields in Kth level according to tendency terms |
185 |
|
CALL TIMESTEP( |
186 |
|
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid) |
187 |
|
C-- Density of K-1 level (above W(K)) reference to K level |
188 |
|
CALL FIND_RHO( |
189 |
|
I bi, bj, iMin, iMax, jMin, jMax, K-1, K, 'LINEAR', |
190 |
|
O rhoKm1, |
191 |
|
I myThid ) |
192 |
|
C-- Density of K level (below W(K)) reference to K level |
193 |
|
CALL FIND_RHO( |
194 |
|
I bi, bj, iMin, iMax, jMin, jMax, K, K, 'LINEAR', |
195 |
|
O rhoKp1, |
196 |
|
I myThid ) |
197 |
|
C-- Calculate iso-neutral slopes for the GM/Redi parameterisation |
198 |
|
CALL CALC_ISOSLOPES( |
199 |
|
I bi, bj, iMin, iMax, jMin, jMax, K, |
200 |
|
I rhoKm1, rhoKp1, |
201 |
|
O K13, K23, K33, KapGM, |
202 |
|
I myThid ) |
203 |
C-- Calculate static stability and mix where convectively unstable |
C-- Calculate static stability and mix where convectively unstable |
204 |
CALL CONVECT( |
CALL CONVECT( |
205 |
I bi,bj,iMin,iMax,jMin,jMax,myThid) |
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1, |
206 |
|
I myTime,myIter,myThid) |
207 |
|
C-- Density of K-1 level (above W(K)) reference to K-1 level |
208 |
|
CALL FIND_RHO( |
209 |
|
I bi, bj, iMin, iMax, jMin, jMax, K-1, K-1, 'LINEAR', |
210 |
|
O rhoKm1, |
211 |
|
I myThid ) |
212 |
|
C-- Density of K level (below W(K)) referenced to K level |
213 |
|
CALL FIND_RHO( |
214 |
|
I bi, bj, iMin, iMax, jMin, jMax, K, K, 'LINEAR', |
215 |
|
O rhoKp1, |
216 |
|
I myThid ) |
217 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
218 |
CALL CALC_PH( |
CALL CALC_PH( |
219 |
I bi,bj,iMin,iMax,jMin,jMax, |
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKp1, |
220 |
O pH, |
U pH, |
221 |
I myThid ) |
I myThid ) |
222 |
|
|
223 |
|
ENDDO |
224 |
|
|
225 |
DO K = Nz, 1, -1 |
DO K = Nz, 1, -1 |
226 |
kM1 =max(1,k-1) ! Points to level above k (=k-1) |
kM1 =max(1,k-1) ! Points to level above k (=k-1) |
250 |
CALL CALC_GT( |
CALL CALC_GT( |
251 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
252 |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
253 |
|
I K13,K23,K33,KapGM, |
254 |
U aTerm,xTerm,fZon,fMer,fVerT, |
U aTerm,xTerm,fZon,fMer,fVerT, |
255 |
I myThid) |
I myThid) |
256 |
Cdbg CALL CALC_GS( |
Cdbg CALL CALC_GS( |
257 |
Cdbg I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
Cdbg I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
258 |
Cdbg I xA,yA,uTrans,vTrans,wTrans,maskUp, |
Cdbg I xA,yA,uTrans,vTrans,wTrans,maskUp, |
259 |
|
Cdbg I K13,K23,K33,KapGM, |
260 |
Cdbg U aTerm,xTerm,fZon,fMer,fVerS, |
Cdbg U aTerm,xTerm,fZon,fMer,fVerS, |
261 |
Cdbg I myThid) |
Cdbg I myThid) |
262 |
|
|
265 |
ENDDO |
ENDDO |
266 |
ENDDO |
ENDDO |
267 |
|
|
268 |
|
!dbg write(0,*) 'dynamics: pS',minval(cg2d_x),maxval(cg2d_x) |
269 |
|
!dbg write(0,*) 'dynamics: U',minval(uVel(1:sNx,1:sNy,:,:,:)), |
270 |
|
!dbg & maxval(uVel(1:sNx,1:sNy,:,:,:)) |
271 |
|
!dbg write(0,*) 'dynamics: V',minval(vVel(1:sNx,1:sNy,:,:,:)), |
272 |
|
!dbg & maxval(vVel(1:sNx,1:sNy,:,:,:)) |
273 |
|
!dbg write(0,*) 'dynamics: gT',minval(gT(1:sNx,1:sNy,:,:,:)), |
274 |
|
!dbg & maxval(gT(1:sNx,1:sNy,:,:,:)) |
275 |
|
!dbg write(0,*) 'dynamics: T',minval(Theta(1:sNx,1:sNy,:,:,:)), |
276 |
|
!dbg & maxval(Theta(1:sNx,1:sNy,:,:,:)) |
277 |
|
!dbg write(0,*) 'dynamics: pH',minval(pH/(Gravity*Rhonil)), |
278 |
|
!dbg & maxval(pH/(Gravity*Rhonil)) |
279 |
|
|
280 |
RETURN |
RETURN |
281 |
END |
END |