/[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.15 - (show annotations) (download)
Sun Feb 4 14:38:48 2001 UTC (23 years, 3 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint35
Changes since 1.14: +2 -1 lines
Made sure each .F and .h file had
the CVS keywords Header and Name at its start.
Most had header but very few currently have Name, so
lots of changes!

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/solve_for_pressure.F,v 1.14 2001/02/02 21:04:48 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 "CG2D.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
30 C == Routine arguments ==
31 C myThid - Number of this instance of SOLVE_FOR_PRESSURE
32 INTEGER myThid
33 CEndOfInterface
34
35 C Local variables
36 INTEGER i,j,k,bi,bj
37 _RS uf(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
38 _RS vf(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
39
40 #ifndef DIVG_IN_DYNAMICS
41 DO bj=myByLo(myThid),myByHi(myThid)
42 DO bi=myBxLo(myThid),myBxHi(myThid)
43 DO K=Nr,1,-1
44 DO j=1,sNy+1
45 DO i=1,sNx+1
46 uf(i,j) = _dyG(i,j,bi,bj)
47 & *drF(k)*_hFacW(i,j,k,bi,bj)
48 vf(i,j) = _dxG(i,j,bi,bj)
49 & *drF(k)*_hFacS(i,j,k,bi,bj)
50 ENDDO
51 ENDDO
52 CALL CALC_DIV_GHAT(
53 I bi,bj,1,sNx,1,sNy,K,
54 I uf,vf,
55 I myThid)
56 ENDDO
57 ENDDO
58 ENDDO
59 #endif
60
61 #ifdef INCLUDE_CD_CODE
62 C-- Save previous solution.
63 DO bj=myByLo(myThid),myByHi(myThid)
64 DO bi=myBxLo(myThid),myBxHi(myThid)
65 DO j=1-OLy,sNy+OLy
66 DO i=1-OLx,sNx+OLx
67 cg2d_xNM1(i,j,bi,bj) = cg2d_x(i,j,bi,bj)
68 ENDDO
69 ENDDO
70 ENDDO
71 ENDDO
72 #endif
73
74 C-- Add source term arising from w=d/dt (p_s + p_nh)
75 DO bj=myByLo(myThid),myByHi(myThid)
76 DO bi=myBxLo(myThid),myBxHi(myThid)
77 #ifdef ALLOW_NONHYDROSTATIC
78 DO j=1,sNy
79 DO i=1,sNx
80 cg2d_b(i,j,bi,bj) = cg2d_b(i,j,bi,bj)
81 & +freeSurfFac*_rA(I,J,bi,bj)*horiVertRatio*(
82 & -cg2d_x(I,J,bi,bj)
83 & -cg3d_x(I,J,1,bi,bj)
84 & )/deltaTMom/deltaTMom
85 cg3d_b(i,j,1,bi,bj) = cg3d_b(i,j,1,bi,bj)
86 & +freeSurfFac*_rA(I,J,bi,bj)*horiVertRatio*(
87 & -cg2d_x(I,J,bi,bj)
88 & -cg3d_x(I,J,1,bi,bj)
89 & )/deltaTMom/deltaTMom
90 ENDDO
91 ENDDO
92 #else
93 DO j=1,sNy
94 DO i=1,sNx
95 cg2d_b(i,j,bi,bj) = cg2d_b(i,j,bi,bj)
96 & +freeSurfFac*_rA(I,J,bi,bj)*horiVertRatio*(
97 & -cg2d_x(I,J,bi,bj)
98 & )/deltaTMom/deltaTMom
99 ENDDO
100 ENDDO
101 #endif
102
103 #ifdef ALLOW_OBCS
104 IF (useOBCS) THEN
105 DO i=1,sNx
106 C Northern boundary
107 IF (OB_Jn(I,bi,bj).NE.0) THEN
108 cg2d_b(I,OB_Jn(I,bi,bj),bi,bj)=0.
109 ENDIF
110 C Southern boundary
111 IF (OB_Js(I,bi,bj).NE.0) THEN
112 cg2d_b(I,OB_Js(I,bi,bj),bi,bj)=0.
113 ENDIF
114 ENDDO
115 DO j=1,sNy
116 C Eastern boundary
117 IF (OB_Ie(J,bi,bj).NE.0) THEN
118 cg2d_b(OB_Ie(J,bi,bj),J,bi,bj)=0.
119 ENDIF
120 C Western boundary
121 IF (OB_Iw(J,bi,bj).NE.0) THEN
122 cg2d_b(OB_Iw(J,bi,bj),J,bi,bj)=0.
123 ENDIF
124 ENDDO
125 ENDIF
126 #endif
127 ENDDO
128 ENDDO
129
130
131 C-- Find the surface pressure using a two-dimensional conjugate
132 C-- gradient solver.
133 C see CG2D.h for the interface to this routine.
134 CALL CG2D(
135 I cg2d_b,
136 U cg2d_x,
137 I myThid )
138
139 _EXCH_XY_R8(cg2d_x, myThid )
140
141 #ifdef ALLOW_NONHYDROSTATIC
142 IF ( nonHydrostatic ) THEN
143
144 C-- Solve for a three-dimensional pressure term (NH or IGW or both ).
145 C see CG3D.h for the interface to this routine.
146 DO bj=myByLo(myThid),myByHi(myThid)
147 DO bi=myBxLo(myThid),myBxHi(myThid)
148 DO j=1,sNy+1
149 DO i=1,sNx+1
150 uf(i,j)=-gBaro*_recip_dxC(i,j,bi,bj)*
151 & (cg2d_x(i,j,bi,bj)-cg2d_x(i-1,j,bi,bj))
152 vf(i,j)=-gBaro*_recip_dyC(i,j,bi,bj)*
153 & (cg2d_x(i,j,bi,bj)-cg2d_x(i,j-1,bi,bj))
154 ENDDO
155 ENDDO
156
157 #ifdef ALLOW_OBCS
158 IF (useOBCS) THEN
159 DO i=1,sNx+1
160 C Northern boundary
161 IF (OB_Jn(I,bi,bj).NE.0) THEN
162 vf(I,OB_Jn(I,bi,bj))=0.
163 ENDIF
164 C Southern boundary
165 IF (OB_Js(I,bi,bj).NE.0) THEN
166 vf(I,OB_Js(I,bi,bj)+1)=0.
167 ENDIF
168 ENDDO
169 DO j=1,sNy+1
170 C Eastern boundary
171 IF (OB_Ie(J,bi,bj).NE.0) THEN
172 uf(OB_Ie(J,bi,bj),J)=0.
173 ENDIF
174 C Western boundary
175 IF (OB_Iw(J,bi,bj).NE.0) THEN
176 uf(OB_Iw(J,bi,bj)+1,J)=0.
177 ENDIF
178 ENDDO
179 ENDIF
180 #endif
181
182 K=1
183 DO j=1,sNy
184 DO i=1,sNx
185 cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj)
186 & +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j)
187 & -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j)
188 & +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1)
189 & -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j )
190 & +(
191 & -wVel(i,j,k+1,bi,bj)
192 & )*_rA(i,j,bi,bj)/deltaTmom
193 & +freeSurfFac*_rA(I,J,bi,bj)*horiVertRatio*(
194 & +cg2d_x(I,J,bi,bj)
195 & )/deltaTMom/deltaTMom
196 ENDDO
197 ENDDO
198 DO K=2,Nr-1
199 DO j=1,sNy
200 DO i=1,sNx
201 cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj)
202 & +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j)
203 & -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j)
204 & +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1)
205 & -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j )
206 & +( wVel(i,j,k ,bi,bj)
207 & -wVel(i,j,k+1,bi,bj)
208 & )*_rA(i,j,bi,bj)/deltaTmom
209
210 ENDDO
211 ENDDO
212 ENDDO
213 K=Nr
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 & +( wVel(i,j,k ,bi,bj)
222 & )*_rA(i,j,bi,bj)/deltaTmom
223
224 ENDDO
225 ENDDO
226
227 #ifdef ALLOW_OBCS
228 IF (useOBCS) THEN
229 DO K=1,Nr
230 DO i=1,sNx
231 C Northern boundary
232 IF (OB_Jn(I,bi,bj).NE.0) THEN
233 cg3d_b(I,OB_Jn(I,bi,bj),K,bi,bj)=0.
234 ENDIF
235 C Southern boundary
236 IF (OB_Js(I,bi,bj).NE.0) THEN
237 cg3d_b(I,OB_Js(I,bi,bj),K,bi,bj)=0.
238 ENDIF
239 ENDDO
240 DO j=1,sNy
241 C Eastern boundary
242 IF (OB_Ie(J,bi,bj).NE.0) THEN
243 cg3d_b(OB_Ie(J,bi,bj),J,K,bi,bj)=0.
244 ENDIF
245 C Western boundary
246 IF (OB_Iw(J,bi,bj).NE.0) THEN
247 cg3d_b(OB_Iw(J,bi,bj),J,K,bi,bj)=0.
248 ENDIF
249 ENDDO
250 ENDDO
251 ENDIF
252 #endif
253
254 ENDDO ! bi
255 ENDDO ! bj
256
257 CALL CG3D( myThid )
258 _EXCH_XYZ_R8(cg3d_x, myThid )
259
260 ENDIF
261 #endif
262
263 RETURN
264 END

  ViewVC Help
Powered by ViewVC 1.1.22