1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/solve_for_pressure.F,v 1.8 1998/12/09 16:11:54 adcroft Exp $ |
2 |
|
3 |
#include "CPP_OPTIONS.h" |
4 |
|
5 |
CStartOfInterface |
6 |
SUBROUTINE SOLVE_FOR_PRESSURE( myThid ) |
7 |
C /==========================================================\ |
8 |
C | SUBROUTINE SOLVE_FOR_PRESSURE | |
9 |
C | o Controls inversion of two and/or three-dimensional | |
10 |
C | elliptic problems for the pressure field. | |
11 |
C \==========================================================/ |
12 |
IMPLICIT NONE |
13 |
|
14 |
C == Global variables |
15 |
#include "SIZE.h" |
16 |
#include "EEPARAMS.h" |
17 |
#include "PARAMS.h" |
18 |
#include "DYNVARS.h" |
19 |
#include "CG2D.h" |
20 |
#ifdef ALLOW_NONHYDROSTATIC |
21 |
#include "CG3D.h" |
22 |
#include "GW.h" |
23 |
#include "OBCS.h" |
24 |
#include "GRID.h" |
25 |
#endif |
26 |
|
27 |
C == Routine arguments == |
28 |
C myThid - Number of this instance of SOLVE_FOR_PRESSURE |
29 |
INTEGER myThid |
30 |
CEndOfInterface |
31 |
|
32 |
C Local variables |
33 |
INTEGER i,j,k,bi,bj |
34 |
#ifdef ALLOW_NONHYDROSTATIC |
35 |
_RS uf(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
36 |
_RS vf(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
37 |
#endif |
38 |
|
39 |
#ifdef INCLUDE_CD_CODE |
40 |
C-- Save previous solution. |
41 |
DO bj=myByLo(myThid),myByHi(myThid) |
42 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
43 |
DO j=1-OLy,sNy+OLy |
44 |
DO i=1-OLx,sNx+OLx |
45 |
cg2d_xNM1(i,j,bi,bj) = cg2d_x(i,j,bi,bj) |
46 |
ENDDO |
47 |
ENDDO |
48 |
ENDDO |
49 |
ENDDO |
50 |
#endif |
51 |
|
52 |
C-- Find the surface pressure using a two-dimensional conjugate |
53 |
C-- gradient solver. |
54 |
C see CG2D.h for the interface to this routine. |
55 |
CALL CG2D( |
56 |
I cg2d_b, |
57 |
U cg2d_x, |
58 |
I myThid ) |
59 |
|
60 |
#ifdef ALLOW_NONHYDROSTATIC |
61 |
IF ( nonHydrostatic ) THEN |
62 |
|
63 |
C-- Solve for a three-dimensional pressure term (NH or IGW or both ). |
64 |
C see CG3D.h for the interface to this routine. |
65 |
DO bj=myByLo(myThid),myByHi(myThid) |
66 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
67 |
DO j=1,sNy+1 |
68 |
DO i=1,sNx+1 |
69 |
uf(i,j)=-gBaro*_recip_dxC(i,j,bi,bj)* |
70 |
& (cg2d_x(i,j,bi,bj)-cg2d_x(i-1,j,bi,bj)) |
71 |
vf(i,j)=-gBaro*_recip_dyC(i,j,bi,bj)* |
72 |
& (cg2d_x(i,j,bi,bj)-cg2d_x(i,j-1,bi,bj)) |
73 |
ENDDO |
74 |
ENDDO |
75 |
|
76 |
IF (openBoundaries) THEN |
77 |
DO i=1,sNx+1 |
78 |
C Northern boundary |
79 |
IF (OB_Jn(I,bi,bj).NE.0) THEN |
80 |
uf(I,OB_Jn(I,bi,bj))=0. |
81 |
vf(I,OB_Jn(I,bi,bj))=0. |
82 |
ENDIF |
83 |
C Southern boundary |
84 |
IF (OB_Js(I,bi,bj).NE.0) THEN |
85 |
uf(I,OB_Js(I,bi,bj))=0. |
86 |
vf(I,OB_Js(I,bi,bj)+1)=0. |
87 |
ENDIF |
88 |
ENDDO |
89 |
DO j=1,sNy+1 |
90 |
C Eastern boundary |
91 |
IF (OB_Ie(J,bi,bj).NE.0) THEN |
92 |
uf(OB_Ie(J,bi,bj),J)=0. |
93 |
vf(OB_Ie(J,bi,bj),J)=0. |
94 |
ENDIF |
95 |
C Western boundary |
96 |
IF (OB_Iw(J,bi,bj).NE.0) THEN |
97 |
uf(OB_Iw(J,bi,bj)+1,J)=0. |
98 |
vf(OB_Iw(J,bi,bj),J)=0. |
99 |
ENDIF |
100 |
ENDDO |
101 |
ENDIF |
102 |
|
103 |
DO K=1,Nr |
104 |
DO j=1,sNy |
105 |
DO i=1,sNx |
106 |
c cg3d_x(i,j,k,bi,bj) = 0. |
107 |
cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj) |
108 |
& +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j) |
109 |
& -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j) |
110 |
& +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1) |
111 |
& -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j ) |
112 |
ENDDO |
113 |
ENDDO |
114 |
ENDDO |
115 |
|
116 |
ENDDO ! bi |
117 |
ENDDO ! bj |
118 |
|
119 |
CALL CG3D( myThid ) |
120 |
|
121 |
ENDIF |
122 |
#endif |
123 |
|
124 |
RETURN |
125 |
END |