1 |
adcroft |
1.22 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/solve_for_pressure.F,v 1.19.2.4 2001/05/16 21:05:10 jmc Exp $ |
2 |
heimbach |
1.21 |
C $Name: $ |
3 |
cnh |
1.1 |
|
4 |
adcroft |
1.5 |
#include "CPP_OPTIONS.h" |
5 |
cnh |
1.1 |
|
6 |
|
|
CStartOfInterface |
7 |
|
|
SUBROUTINE SOLVE_FOR_PRESSURE( myThid ) |
8 |
|
|
C /==========================================================\ |
9 |
|
|
C | SUBROUTINE SOLVE_FOR_PRESSURE | |
10 |
|
|
C | o Controls inversion of two and/or three-dimensional | |
11 |
|
|
C | elliptic problems for the pressure field. | |
12 |
|
|
C \==========================================================/ |
13 |
adcroft |
1.8 |
IMPLICIT NONE |
14 |
cnh |
1.1 |
|
15 |
cnh |
1.4 |
C == Global variables |
16 |
|
|
#include "SIZE.h" |
17 |
|
|
#include "EEPARAMS.h" |
18 |
|
|
#include "PARAMS.h" |
19 |
|
|
#include "DYNVARS.h" |
20 |
adcroft |
1.12 |
#include "GRID.h" |
21 |
jmc |
1.17 |
#include "SURFACE.h" |
22 |
adcroft |
1.9 |
#ifdef ALLOW_NONHYDROSTATIC |
23 |
|
|
#include "CG3D.h" |
24 |
|
|
#include "GW.h" |
25 |
adcroft |
1.12 |
#endif |
26 |
adcroft |
1.11 |
#ifdef ALLOW_OBCS |
27 |
adcroft |
1.9 |
#include "OBCS.h" |
28 |
adcroft |
1.11 |
#endif |
29 |
adcroft |
1.22 |
#include "SOLVE_FOR_PRESSURE.h" |
30 |
cnh |
1.4 |
|
31 |
cnh |
1.1 |
C == Routine arguments == |
32 |
|
|
C myThid - Number of this instance of SOLVE_FOR_PRESSURE |
33 |
|
|
INTEGER myThid |
34 |
|
|
CEndOfInterface |
35 |
cnh |
1.4 |
|
36 |
adcroft |
1.22 |
C == Local variables == |
37 |
cnh |
1.6 |
INTEGER i,j,k,bi,bj |
38 |
adcroft |
1.9 |
_RS uf(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
39 |
|
|
_RS vf(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
40 |
adcroft |
1.22 |
_RL firstResidual,lastResidual |
41 |
adcroft |
1.19 |
INTEGER numIters |
42 |
jmc |
1.17 |
|
43 |
|
|
C-- Save previous solution & Initialise Vector solution and source term : |
44 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
45 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
46 |
|
|
DO j=1-OLy,sNy+OLy |
47 |
|
|
DO i=1-OLx,sNx+OLx |
48 |
|
|
etaNm1(i,j,bi,bj) = etaN(i,j,bi,bj) |
49 |
jmc |
1.18 |
cg2d_x(i,j,bi,bj) = Bo_surf(i,j,bi,bj)*etaN(i,j,bi,bj) |
50 |
jmc |
1.17 |
cg2d_b(i,j,bi,bj) = 0. |
51 |
|
|
#ifdef USE_NATURAL_BCS |
52 |
jmc |
1.18 |
& + freeSurfFac*_rA(i,j,bi,bj)* |
53 |
jmc |
1.17 |
& EmPmR(I,J,bi,bj)/deltaTMom |
54 |
|
|
#endif |
55 |
|
|
ENDDO |
56 |
|
|
ENDDO |
57 |
|
|
ENDDO |
58 |
|
|
ENDDO |
59 |
adcroft |
1.12 |
|
60 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
61 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
62 |
|
|
DO K=Nr,1,-1 |
63 |
|
|
DO j=1,sNy+1 |
64 |
|
|
DO i=1,sNx+1 |
65 |
|
|
uf(i,j) = _dyG(i,j,bi,bj) |
66 |
|
|
& *drF(k)*_hFacW(i,j,k,bi,bj) |
67 |
|
|
vf(i,j) = _dxG(i,j,bi,bj) |
68 |
|
|
& *drF(k)*_hFacS(i,j,k,bi,bj) |
69 |
|
|
ENDDO |
70 |
|
|
ENDDO |
71 |
|
|
CALL CALC_DIV_GHAT( |
72 |
|
|
I bi,bj,1,sNx,1,sNy,K, |
73 |
|
|
I uf,vf, |
74 |
jmc |
1.17 |
U cg2d_b, |
75 |
adcroft |
1.12 |
I myThid) |
76 |
|
|
ENDDO |
77 |
|
|
ENDDO |
78 |
|
|
ENDDO |
79 |
cnh |
1.4 |
|
80 |
adcroft |
1.12 |
C-- Add source term arising from w=d/dt (p_s + p_nh) |
81 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
82 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
83 |
adcroft |
1.13 |
#ifdef ALLOW_NONHYDROSTATIC |
84 |
adcroft |
1.12 |
DO j=1,sNy |
85 |
|
|
DO i=1,sNx |
86 |
|
|
cg2d_b(i,j,bi,bj) = cg2d_b(i,j,bi,bj) |
87 |
jmc |
1.18 |
& -freeSurfFac*_rA(i,j,bi,bj)/deltaTMom/deltaTMom |
88 |
|
|
& *( etaN(i,j,bi,bj) |
89 |
|
|
& +cg3d_x(i,j,1,bi,bj)*horiVertRatio/gravity ) |
90 |
adcroft |
1.13 |
cg3d_b(i,j,1,bi,bj) = cg3d_b(i,j,1,bi,bj) |
91 |
jmc |
1.18 |
& -freeSurfFac*_rA(i,j,bi,bj)/deltaTMom/deltaTMom |
92 |
|
|
& *( etaN(i,j,bi,bj) |
93 |
|
|
& +cg3d_x(i,j,1,bi,bj)*horiVertRatio/gravity ) |
94 |
|
|
C-jmc |
95 |
|
|
c & -freeSurfFac*_rA(i,j,bi,bj)*recip_Bo(i,j,bi,bj) |
96 |
|
|
c & *( cg2d_x(i,j,bi,bj) + cg3d_x(i,j,1,bi,bj) ) |
97 |
|
|
c & /deltaTMom/deltaTMom |
98 |
|
|
C-jmc |
99 |
adcroft |
1.12 |
ENDDO |
100 |
|
|
ENDDO |
101 |
adcroft |
1.13 |
#else |
102 |
adcroft |
1.12 |
DO j=1,sNy |
103 |
|
|
DO i=1,sNx |
104 |
adcroft |
1.13 |
cg2d_b(i,j,bi,bj) = cg2d_b(i,j,bi,bj) |
105 |
jmc |
1.18 |
& -freeSurfFac*_rA(i,j,bi,bj)/deltaTMom/deltaTMom |
106 |
|
|
& * etaN(i,j,bi,bj) |
107 |
adcroft |
1.12 |
ENDDO |
108 |
|
|
ENDDO |
109 |
|
|
#endif |
110 |
|
|
|
111 |
|
|
#ifdef ALLOW_OBCS |
112 |
adcroft |
1.14 |
IF (useOBCS) THEN |
113 |
adcroft |
1.12 |
DO i=1,sNx |
114 |
|
|
C Northern boundary |
115 |
|
|
IF (OB_Jn(I,bi,bj).NE.0) THEN |
116 |
|
|
cg2d_b(I,OB_Jn(I,bi,bj),bi,bj)=0. |
117 |
|
|
ENDIF |
118 |
|
|
C Southern boundary |
119 |
|
|
IF (OB_Js(I,bi,bj).NE.0) THEN |
120 |
|
|
cg2d_b(I,OB_Js(I,bi,bj),bi,bj)=0. |
121 |
|
|
ENDIF |
122 |
|
|
ENDDO |
123 |
|
|
DO j=1,sNy |
124 |
|
|
C Eastern boundary |
125 |
|
|
IF (OB_Ie(J,bi,bj).NE.0) THEN |
126 |
|
|
cg2d_b(OB_Ie(J,bi,bj),J,bi,bj)=0. |
127 |
|
|
ENDIF |
128 |
|
|
C Western boundary |
129 |
|
|
IF (OB_Iw(J,bi,bj).NE.0) THEN |
130 |
|
|
cg2d_b(OB_Iw(J,bi,bj),J,bi,bj)=0. |
131 |
|
|
ENDIF |
132 |
|
|
ENDDO |
133 |
|
|
ENDIF |
134 |
|
|
#endif |
135 |
|
|
ENDDO |
136 |
|
|
ENDDO |
137 |
|
|
|
138 |
|
|
|
139 |
cnh |
1.1 |
C-- Find the surface pressure using a two-dimensional conjugate |
140 |
|
|
C-- gradient solver. |
141 |
adcroft |
1.22 |
C see CG2D.h for the interface to this routine. |
142 |
|
|
firstResidual=0. |
143 |
|
|
lastResidual=0. |
144 |
adcroft |
1.19 |
numIters=cg2dMaxIters |
145 |
cnh |
1.1 |
CALL CG2D( |
146 |
adcroft |
1.22 |
U cg2d_b, |
147 |
cnh |
1.6 |
U cg2d_x, |
148 |
adcroft |
1.22 |
O firstResidual, |
149 |
|
|
O lastResidual, |
150 |
adcroft |
1.19 |
U numIters, |
151 |
cnh |
1.1 |
I myThid ) |
152 |
adcroft |
1.19 |
_EXCH_XY_R8(cg2d_x, myThid ) |
153 |
cnh |
1.1 |
|
154 |
adcroft |
1.19 |
_BEGIN_MASTER( myThid ) |
155 |
heimbach |
1.21 |
WRITE(*,'(A,I6,1PE30.14)') ' CG2D iters, err = ', |
156 |
adcroft |
1.22 |
& 0, firstResidual |
157 |
heimbach |
1.21 |
WRITE(*,'(A,I6,1PE30.14)') ' CG2D iters, err = ', |
158 |
adcroft |
1.22 |
& numIters, lastResidual |
159 |
adcroft |
1.19 |
_END_MASTER( ) |
160 |
jmc |
1.17 |
|
161 |
|
|
C-- Transfert the 2D-solution to "etaN" : |
162 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
163 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
164 |
|
|
DO j=1-OLy,sNy+OLy |
165 |
|
|
DO i=1-OLx,sNx+OLx |
166 |
jmc |
1.18 |
etaN(i,j,bi,bj) = recip_Bo(i,j,bi,bj)*cg2d_x(i,j,bi,bj) |
167 |
jmc |
1.17 |
ENDDO |
168 |
|
|
ENDDO |
169 |
|
|
ENDDO |
170 |
|
|
ENDDO |
171 |
adcroft |
1.10 |
|
172 |
adcroft |
1.9 |
#ifdef ALLOW_NONHYDROSTATIC |
173 |
|
|
IF ( nonHydrostatic ) THEN |
174 |
|
|
|
175 |
|
|
C-- Solve for a three-dimensional pressure term (NH or IGW or both ). |
176 |
|
|
C see CG3D.h for the interface to this routine. |
177 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
178 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
179 |
|
|
DO j=1,sNy+1 |
180 |
|
|
DO i=1,sNx+1 |
181 |
jmc |
1.18 |
uf(i,j)=-_recip_dxC(i,j,bi,bj)* |
182 |
adcroft |
1.9 |
& (cg2d_x(i,j,bi,bj)-cg2d_x(i-1,j,bi,bj)) |
183 |
jmc |
1.18 |
vf(i,j)=-_recip_dyC(i,j,bi,bj)* |
184 |
adcroft |
1.9 |
& (cg2d_x(i,j,bi,bj)-cg2d_x(i,j-1,bi,bj)) |
185 |
|
|
ENDDO |
186 |
|
|
ENDDO |
187 |
|
|
|
188 |
adcroft |
1.12 |
#ifdef ALLOW_OBCS |
189 |
adcroft |
1.14 |
IF (useOBCS) THEN |
190 |
adcroft |
1.9 |
DO i=1,sNx+1 |
191 |
|
|
C Northern boundary |
192 |
|
|
IF (OB_Jn(I,bi,bj).NE.0) THEN |
193 |
|
|
vf(I,OB_Jn(I,bi,bj))=0. |
194 |
|
|
ENDIF |
195 |
|
|
C Southern boundary |
196 |
|
|
IF (OB_Js(I,bi,bj).NE.0) THEN |
197 |
|
|
vf(I,OB_Js(I,bi,bj)+1)=0. |
198 |
|
|
ENDIF |
199 |
|
|
ENDDO |
200 |
|
|
DO j=1,sNy+1 |
201 |
|
|
C Eastern boundary |
202 |
|
|
IF (OB_Ie(J,bi,bj).NE.0) THEN |
203 |
|
|
uf(OB_Ie(J,bi,bj),J)=0. |
204 |
|
|
ENDIF |
205 |
|
|
C Western boundary |
206 |
|
|
IF (OB_Iw(J,bi,bj).NE.0) THEN |
207 |
|
|
uf(OB_Iw(J,bi,bj)+1,J)=0. |
208 |
|
|
ENDIF |
209 |
|
|
ENDDO |
210 |
|
|
ENDIF |
211 |
adcroft |
1.12 |
#endif |
212 |
adcroft |
1.9 |
|
213 |
adcroft |
1.12 |
K=1 |
214 |
|
|
DO j=1,sNy |
215 |
|
|
DO i=1,sNx |
216 |
|
|
cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj) |
217 |
|
|
& +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j) |
218 |
|
|
& -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j) |
219 |
|
|
& +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1) |
220 |
|
|
& -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j ) |
221 |
jmc |
1.18 |
& +( freeSurfFac*etaN(i,j,bi,bj)/deltaTMom |
222 |
|
|
& -wVel(i,j,k+1,bi,bj) |
223 |
adcroft |
1.12 |
& )*_rA(i,j,bi,bj)/deltaTmom |
224 |
|
|
ENDDO |
225 |
|
|
ENDDO |
226 |
|
|
DO K=2,Nr-1 |
227 |
adcroft |
1.9 |
DO j=1,sNy |
228 |
|
|
DO i=1,sNx |
229 |
|
|
cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj) |
230 |
|
|
& +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j) |
231 |
|
|
& -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j) |
232 |
|
|
& +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1) |
233 |
|
|
& -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j ) |
234 |
adcroft |
1.12 |
& +( wVel(i,j,k ,bi,bj) |
235 |
|
|
& -wVel(i,j,k+1,bi,bj) |
236 |
|
|
& )*_rA(i,j,bi,bj)/deltaTmom |
237 |
|
|
|
238 |
adcroft |
1.9 |
ENDDO |
239 |
|
|
ENDDO |
240 |
|
|
ENDDO |
241 |
adcroft |
1.12 |
K=Nr |
242 |
|
|
DO j=1,sNy |
243 |
|
|
DO i=1,sNx |
244 |
|
|
cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj) |
245 |
|
|
& +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j) |
246 |
|
|
& -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j) |
247 |
|
|
& +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1) |
248 |
|
|
& -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j ) |
249 |
|
|
& +( wVel(i,j,k ,bi,bj) |
250 |
|
|
& )*_rA(i,j,bi,bj)/deltaTmom |
251 |
|
|
|
252 |
|
|
ENDDO |
253 |
|
|
ENDDO |
254 |
|
|
|
255 |
|
|
#ifdef ALLOW_OBCS |
256 |
adcroft |
1.14 |
IF (useOBCS) THEN |
257 |
adcroft |
1.12 |
DO K=1,Nr |
258 |
|
|
DO i=1,sNx |
259 |
|
|
C Northern boundary |
260 |
|
|
IF (OB_Jn(I,bi,bj).NE.0) THEN |
261 |
|
|
cg3d_b(I,OB_Jn(I,bi,bj),K,bi,bj)=0. |
262 |
|
|
ENDIF |
263 |
|
|
C Southern boundary |
264 |
|
|
IF (OB_Js(I,bi,bj).NE.0) THEN |
265 |
|
|
cg3d_b(I,OB_Js(I,bi,bj),K,bi,bj)=0. |
266 |
|
|
ENDIF |
267 |
|
|
ENDDO |
268 |
|
|
DO j=1,sNy |
269 |
|
|
C Eastern boundary |
270 |
|
|
IF (OB_Ie(J,bi,bj).NE.0) THEN |
271 |
|
|
cg3d_b(OB_Ie(J,bi,bj),J,K,bi,bj)=0. |
272 |
|
|
ENDIF |
273 |
|
|
C Western boundary |
274 |
|
|
IF (OB_Iw(J,bi,bj).NE.0) THEN |
275 |
|
|
cg3d_b(OB_Iw(J,bi,bj),J,K,bi,bj)=0. |
276 |
|
|
ENDIF |
277 |
|
|
ENDDO |
278 |
|
|
ENDDO |
279 |
|
|
ENDIF |
280 |
|
|
#endif |
281 |
adcroft |
1.9 |
|
282 |
|
|
ENDDO ! bi |
283 |
|
|
ENDDO ! bj |
284 |
|
|
|
285 |
|
|
CALL CG3D( myThid ) |
286 |
adcroft |
1.10 |
_EXCH_XYZ_R8(cg3d_x, myThid ) |
287 |
adcroft |
1.9 |
|
288 |
|
|
ENDIF |
289 |
|
|
#endif |
290 |
cnh |
1.1 |
|
291 |
|
|
RETURN |
292 |
|
|
END |