1 |
C $Header: dynamics.F,v 1.1.1.1 1998/04/22 19:15:30 cnh Exp $ |
2 |
|
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 |
|
29 |
C == Routine arguments == |
30 |
C myThid - Thread number for this instance of the routine. |
31 |
INTEGER myThid |
32 |
|
33 |
C == Local variables |
34 |
C xA, yA - Per block temporaries holding face areas |
35 |
C uTrans, vTrans, wTrans - Per block temporaries holding flow transport |
36 |
C o uTrans: Zonal transport |
37 |
C o vTrans: Meridional transport |
38 |
C o wTrans: Vertical transport |
39 |
C maskC,maskUp o maskC: land/water mask for tracer cells |
40 |
C o maskUp: land/water mask for W points |
41 |
C aTerm, xTerm, cTerm - Work arrays for holding separate terms in |
42 |
C mTerm, pTerm, tendency equations. |
43 |
C fZon, fMer, fVer[STUV] o aTerm: Advection term |
44 |
C o xTerm: Mixing term |
45 |
C o cTerm: Coriolis term |
46 |
C o mTerm: Metric term |
47 |
C o pTerm: Pressure term |
48 |
C o fZon: Zonal flux term |
49 |
C o fMer: Meridional flux term |
50 |
C o fVer: Vertical flux term - note fVer |
51 |
C is "pipelined" in the vertical |
52 |
C so we need an fVer for each |
53 |
C variable. |
54 |
C iMin, iMax - Ranges and sub-block indices on which calculations |
55 |
C jMin, jMax are applied. |
56 |
C bi, bj |
57 |
C k, kUp, kDown, kM1 - Index for layer above and below. kUp and kDown |
58 |
C are switched with layer to be the appropriate index |
59 |
C into fVerTerm |
60 |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
61 |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
62 |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
63 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
64 |
_RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
65 |
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
66 |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
67 |
_RL aTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
_RL xTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
69 |
_RL cTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
_RL mTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
71 |
_RL pTerm (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
72 |
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
73 |
_RL fMer (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
74 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
75 |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
76 |
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
77 |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
78 |
_RL pH (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
79 |
INTEGER iMin, iMax |
80 |
INTEGER jMin, jMax |
81 |
INTEGER bi, bj |
82 |
INTEGER i, j |
83 |
INTEGER k, kM1, kUp, kDown |
84 |
|
85 |
C-- Set up work arrays with valid (i.e. not NaN) values |
86 |
C These inital values do not alter the numerical results. They |
87 |
C just ensure that all memory references are to valid floating |
88 |
C point numbers. This prevents spurious hardware signals due to |
89 |
C uninitialised but inert locations. |
90 |
DO j=1-OLy,sNy+OLy |
91 |
DO i=1-OLx,sNx+OLx |
92 |
xA(i,j) = 0.*1. _d 37 |
93 |
yA(i,j) = 0.*1. _d 37 |
94 |
uTrans(i,j) = 0.*1. _d 37 |
95 |
vTrans(i,j) = 0.*1. _d 37 |
96 |
aTerm(i,j) = 0.*1. _d 37 |
97 |
xTerm(i,j) = 0.*1. _d 37 |
98 |
cTerm(i,j) = 0.*1. _d 37 |
99 |
mTerm(i,j) = 0.*1. _d 37 |
100 |
pTerm(i,j) = 0.*1. _d 37 |
101 |
fZon(i,j) = 0.*1. _d 37 |
102 |
fMer(i,j) = 0.*1. _d 37 |
103 |
DO K=1,nZ |
104 |
pH (i,j,k) = 0.*1. _d 37 |
105 |
ENDDO |
106 |
ENDDO |
107 |
ENDDO |
108 |
C-- Set up work arrays that need valid initial values |
109 |
DO j=1-OLy,sNy+OLy |
110 |
DO i=1-OLx,sNx+OLx |
111 |
wTrans(i,j) = 0. _d 0 |
112 |
fVerT(i,j,1) = 0. _d 0 |
113 |
fVerT(i,j,2) = 0. _d 0 |
114 |
fVerS(i,j,1) = 0. _d 0 |
115 |
fVerS(i,j,2) = 0. _d 0 |
116 |
fVerU(i,j,1) = 0. _d 0 |
117 |
fVerU(i,j,2) = 0. _d 0 |
118 |
fVerV(i,j,1) = 0. _d 0 |
119 |
fVerV(i,j,2) = 0. _d 0 |
120 |
ENDDO |
121 |
ENDDO |
122 |
|
123 |
DO bj=myByLo(myThid),myByHi(myThid) |
124 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
125 |
|
126 |
iMin = 1-OLx+1 |
127 |
iMax = sNx+OLx |
128 |
jMin = 1-OLy+1 |
129 |
jMax = sNy+OLy |
130 |
|
131 |
C-- Update fields according to tendency terms |
132 |
CALL TIMESTEP( |
133 |
I bi,bj,iMin,iMax,jMin,jMax,myThid) |
134 |
|
135 |
C-- Calculate rho with the appropriate equation of state |
136 |
CALL FIND_RHO( |
137 |
I bi,bj,iMin,iMax,jMin,jMax,myThid) |
138 |
|
139 |
C-- Calculate static stability and mix where convectively unstable |
140 |
CALL CONVECT( |
141 |
I bi,bj,iMin,iMax,jMin,jMax,myThid) |
142 |
|
143 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
144 |
CALL CALC_PH( |
145 |
I bi,bj,iMin,iMax,jMin,jMax, |
146 |
O pH, |
147 |
I myThid ) |
148 |
|
149 |
DO K = Nz, 1, -1 |
150 |
kM1 =max(1,k-1) ! Points to level above k (=k-1) |
151 |
kUp =1+MOD(k+1,2) ! Cycles through 1,2 to point to layer above |
152 |
kDown=1+MOD(k,2) ! Cycles through 2,1 to point to current layer |
153 |
iMin = 1-OLx+2 |
154 |
iMax = sNx+OLx-1 |
155 |
jMin = 1-OLy+2 |
156 |
jMax = sNy+OLy-1 |
157 |
|
158 |
C-- Get temporary terms used by tendency routines |
159 |
CALL CALC_COMMON_FACTORS ( |
160 |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
161 |
O xA,yA,uTrans,vTrans,wTrans,maskC,maskUp, |
162 |
I myThid) |
163 |
|
164 |
C-- Calculate accelerations in the momentum equations |
165 |
CALL CALC_MOM_RHS( |
166 |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
167 |
I xA,yA,uTrans,vTrans,wTrans,maskC, |
168 |
I pH, |
169 |
U aTerm,xTerm,cTerm,mTerm,pTerm, |
170 |
U fZon, fMer, fVerU, fVerV, |
171 |
I myThid) |
172 |
|
173 |
C-- Calculate active tracer tendencies |
174 |
CALL CALC_GT( |
175 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
176 |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
177 |
U aTerm,xTerm,fZon,fMer,fVerT, |
178 |
I myThid) |
179 |
Cdbg CALL CALC_GS( |
180 |
Cdbg I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
181 |
Cdbg I xA,yA,uTrans,vTrans,wTrans,maskUp, |
182 |
Cdbg U aTerm,xTerm,fZon,fMer,fVerS, |
183 |
Cdbg I myThid) |
184 |
|
185 |
ENDDO |
186 |
|
187 |
ENDDO |
188 |
ENDDO |
189 |
|
190 |
RETURN |
191 |
END |