/[MITgcm]/MITgcm/model/src/solve_for_pressure.F
ViewVC logotype

Contents of /MITgcm/model/src/solve_for_pressure.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.23 - (show annotations) (download)
Wed Jun 6 14:55:45 2001 UTC (22 years, 11 months ago) by adcroft
Branch: MAIN
Changes since 1.22: +10 -1 lines
Added a debugMode that uses same statistics stuff as monitor.F
Can be disabled with -DEXCLUDE_DEBUGMODE. Turn on at run-time
with debugMode=.true.  Default is enabled but off.

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/solve_for_pressure.F,v 1.22 2001/05/29 14:01:37 adcroft Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
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 IMPLICIT NONE
14
15 C == Global variables
16 #include "SIZE.h"
17 #include "EEPARAMS.h"
18 #include "PARAMS.h"
19 #include "DYNVARS.h"
20 #include "GRID.h"
21 #include "SURFACE.h"
22 #ifdef ALLOW_NONHYDROSTATIC
23 #include "CG3D.h"
24 #include "GW.h"
25 #endif
26 #ifdef ALLOW_OBCS
27 #include "OBCS.h"
28 #endif
29 #include "SOLVE_FOR_PRESSURE.h"
30
31 C == Routine arguments ==
32 C myThid - Number of this instance of SOLVE_FOR_PRESSURE
33 INTEGER myThid
34 CEndOfInterface
35
36 C == Local variables ==
37 INTEGER i,j,k,bi,bj
38 _RS uf(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
39 _RS vf(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
40 _RL firstResidual,lastResidual
41 INTEGER numIters
42
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 cg2d_x(i,j,bi,bj) = Bo_surf(i,j,bi,bj)*etaN(i,j,bi,bj)
50 cg2d_b(i,j,bi,bj) = 0.
51 #ifdef USE_NATURAL_BCS
52 & + freeSurfFac*_rA(i,j,bi,bj)*
53 & EmPmR(I,J,bi,bj)/deltaTMom
54 #endif
55 ENDDO
56 ENDDO
57 ENDDO
58 ENDDO
59
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 U cg2d_b,
75 I myThid)
76 ENDDO
77 ENDDO
78 ENDDO
79
80 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 #ifdef ALLOW_NONHYDROSTATIC
84 DO j=1,sNy
85 DO i=1,sNx
86 cg2d_b(i,j,bi,bj) = cg2d_b(i,j,bi,bj)
87 & -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 cg3d_b(i,j,1,bi,bj) = cg3d_b(i,j,1,bi,bj)
91 & -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 ENDDO
100 ENDDO
101 #else
102 DO j=1,sNy
103 DO i=1,sNx
104 cg2d_b(i,j,bi,bj) = cg2d_b(i,j,bi,bj)
105 & -freeSurfFac*_rA(i,j,bi,bj)/deltaTMom/deltaTMom
106 & * etaN(i,j,bi,bj)
107 ENDDO
108 ENDDO
109 #endif
110
111 #ifdef ALLOW_OBCS
112 IF (useOBCS) THEN
113 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 #ifndef EXCLUDE_DEBUGMODE
139 CALL DEBUG_STATS_RL(1,cg2d_b,'cg2d_b (SOLVE_FOR_PRESSURE)',
140 & myThid)
141 #endif
142
143 C-- Find the surface pressure using a two-dimensional conjugate
144 C-- gradient solver.
145 C see CG2D.h for the interface to this routine.
146 firstResidual=0.
147 lastResidual=0.
148 numIters=cg2dMaxIters
149 CALL CG2D(
150 U cg2d_b,
151 U cg2d_x,
152 O firstResidual,
153 O lastResidual,
154 U numIters,
155 I myThid )
156 _EXCH_XY_R8(cg2d_x, myThid )
157
158 #ifndef EXCLUDE_DEBUGMODE
159 CALL DEBUG_STATS_RL(1,cg2d_x,'cg2d_x (SOLVE_FOR_PRESSURE)',
160 & myThid)
161 #endif
162
163 _BEGIN_MASTER( myThid )
164 WRITE(*,'(A,I6,1PE30.14)') ' CG2D iters, err = ',
165 & 0, firstResidual
166 WRITE(*,'(A,I6,1PE30.14)') ' CG2D iters, err = ',
167 & numIters, lastResidual
168 _END_MASTER( )
169
170 C-- Transfert the 2D-solution to "etaN" :
171 DO bj=myByLo(myThid),myByHi(myThid)
172 DO bi=myBxLo(myThid),myBxHi(myThid)
173 DO j=1-OLy,sNy+OLy
174 DO i=1-OLx,sNx+OLx
175 etaN(i,j,bi,bj) = recip_Bo(i,j,bi,bj)*cg2d_x(i,j,bi,bj)
176 ENDDO
177 ENDDO
178 ENDDO
179 ENDDO
180
181 #ifdef ALLOW_NONHYDROSTATIC
182 IF ( nonHydrostatic ) THEN
183
184 C-- Solve for a three-dimensional pressure term (NH or IGW or both ).
185 C see CG3D.h for the interface to this routine.
186 DO bj=myByLo(myThid),myByHi(myThid)
187 DO bi=myBxLo(myThid),myBxHi(myThid)
188 DO j=1,sNy+1
189 DO i=1,sNx+1
190 uf(i,j)=-_recip_dxC(i,j,bi,bj)*
191 & (cg2d_x(i,j,bi,bj)-cg2d_x(i-1,j,bi,bj))
192 vf(i,j)=-_recip_dyC(i,j,bi,bj)*
193 & (cg2d_x(i,j,bi,bj)-cg2d_x(i,j-1,bi,bj))
194 ENDDO
195 ENDDO
196
197 #ifdef ALLOW_OBCS
198 IF (useOBCS) THEN
199 DO i=1,sNx+1
200 C Northern boundary
201 IF (OB_Jn(I,bi,bj).NE.0) THEN
202 vf(I,OB_Jn(I,bi,bj))=0.
203 ENDIF
204 C Southern boundary
205 IF (OB_Js(I,bi,bj).NE.0) THEN
206 vf(I,OB_Js(I,bi,bj)+1)=0.
207 ENDIF
208 ENDDO
209 DO j=1,sNy+1
210 C Eastern boundary
211 IF (OB_Ie(J,bi,bj).NE.0) THEN
212 uf(OB_Ie(J,bi,bj),J)=0.
213 ENDIF
214 C Western boundary
215 IF (OB_Iw(J,bi,bj).NE.0) THEN
216 uf(OB_Iw(J,bi,bj)+1,J)=0.
217 ENDIF
218 ENDDO
219 ENDIF
220 #endif
221
222 K=1
223 DO j=1,sNy
224 DO i=1,sNx
225 cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj)
226 & +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j)
227 & -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j)
228 & +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1)
229 & -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j )
230 & +( freeSurfFac*etaN(i,j,bi,bj)/deltaTMom
231 & -wVel(i,j,k+1,bi,bj)
232 & )*_rA(i,j,bi,bj)/deltaTmom
233 ENDDO
234 ENDDO
235 DO K=2,Nr-1
236 DO j=1,sNy
237 DO i=1,sNx
238 cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj)
239 & +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j)
240 & -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j)
241 & +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1)
242 & -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j )
243 & +( wVel(i,j,k ,bi,bj)
244 & -wVel(i,j,k+1,bi,bj)
245 & )*_rA(i,j,bi,bj)/deltaTmom
246
247 ENDDO
248 ENDDO
249 ENDDO
250 K=Nr
251 DO j=1,sNy
252 DO i=1,sNx
253 cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj)
254 & +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j)
255 & -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j)
256 & +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1)
257 & -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j )
258 & +( wVel(i,j,k ,bi,bj)
259 & )*_rA(i,j,bi,bj)/deltaTmom
260
261 ENDDO
262 ENDDO
263
264 #ifdef ALLOW_OBCS
265 IF (useOBCS) THEN
266 DO K=1,Nr
267 DO i=1,sNx
268 C Northern boundary
269 IF (OB_Jn(I,bi,bj).NE.0) THEN
270 cg3d_b(I,OB_Jn(I,bi,bj),K,bi,bj)=0.
271 ENDIF
272 C Southern boundary
273 IF (OB_Js(I,bi,bj).NE.0) THEN
274 cg3d_b(I,OB_Js(I,bi,bj),K,bi,bj)=0.
275 ENDIF
276 ENDDO
277 DO j=1,sNy
278 C Eastern boundary
279 IF (OB_Ie(J,bi,bj).NE.0) THEN
280 cg3d_b(OB_Ie(J,bi,bj),J,K,bi,bj)=0.
281 ENDIF
282 C Western boundary
283 IF (OB_Iw(J,bi,bj).NE.0) THEN
284 cg3d_b(OB_Iw(J,bi,bj),J,K,bi,bj)=0.
285 ENDIF
286 ENDDO
287 ENDDO
288 ENDIF
289 #endif
290
291 ENDDO ! bi
292 ENDDO ! bj
293
294 CALL CG3D( myThid )
295 _EXCH_XYZ_R8(cg3d_x, myThid )
296
297 ENDIF
298 #endif
299
300 RETURN
301 END

  ViewVC Help
Powered by ViewVC 1.1.22