1 |
adcroft |
1.10 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/solve_for_pressure.F,v 1.9 1999/03/22 15:54:05 adcroft Exp $ |
2 |
cnh |
1.1 |
|
3 |
adcroft |
1.5 |
#include "CPP_OPTIONS.h" |
4 |
cnh |
1.1 |
|
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 |
adcroft |
1.8 |
IMPLICIT NONE |
13 |
cnh |
1.1 |
|
14 |
cnh |
1.4 |
C == Global variables |
15 |
|
|
#include "SIZE.h" |
16 |
|
|
#include "EEPARAMS.h" |
17 |
|
|
#include "PARAMS.h" |
18 |
|
|
#include "DYNVARS.h" |
19 |
|
|
#include "CG2D.h" |
20 |
adcroft |
1.9 |
#ifdef ALLOW_NONHYDROSTATIC |
21 |
|
|
#include "CG3D.h" |
22 |
|
|
#include "GW.h" |
23 |
|
|
#include "OBCS.h" |
24 |
|
|
#include "GRID.h" |
25 |
|
|
#endif |
26 |
cnh |
1.4 |
|
27 |
cnh |
1.1 |
C == Routine arguments == |
28 |
|
|
C myThid - Number of this instance of SOLVE_FOR_PRESSURE |
29 |
|
|
INTEGER myThid |
30 |
|
|
CEndOfInterface |
31 |
cnh |
1.4 |
|
32 |
|
|
C Local variables |
33 |
cnh |
1.6 |
INTEGER i,j,k,bi,bj |
34 |
adcroft |
1.9 |
#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 |
cnh |
1.4 |
|
39 |
cnh |
1.7 |
#ifdef INCLUDE_CD_CODE |
40 |
cnh |
1.4 |
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 |
cnh |
1.1 |
|
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 |
cnh |
1.6 |
I cg2d_b, |
57 |
|
|
U cg2d_x, |
58 |
cnh |
1.1 |
I myThid ) |
59 |
|
|
|
60 |
adcroft |
1.10 |
_EXCH_XY_R8(cg2d_x, myThid ) |
61 |
|
|
|
62 |
adcroft |
1.9 |
#ifdef ALLOW_NONHYDROSTATIC |
63 |
|
|
IF ( nonHydrostatic ) THEN |
64 |
|
|
|
65 |
|
|
C-- Solve for a three-dimensional pressure term (NH or IGW or both ). |
66 |
|
|
C see CG3D.h for the interface to this routine. |
67 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
68 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
69 |
|
|
DO j=1,sNy+1 |
70 |
|
|
DO i=1,sNx+1 |
71 |
|
|
uf(i,j)=-gBaro*_recip_dxC(i,j,bi,bj)* |
72 |
|
|
& (cg2d_x(i,j,bi,bj)-cg2d_x(i-1,j,bi,bj)) |
73 |
|
|
vf(i,j)=-gBaro*_recip_dyC(i,j,bi,bj)* |
74 |
|
|
& (cg2d_x(i,j,bi,bj)-cg2d_x(i,j-1,bi,bj)) |
75 |
|
|
ENDDO |
76 |
|
|
ENDDO |
77 |
|
|
|
78 |
|
|
IF (openBoundaries) THEN |
79 |
|
|
DO i=1,sNx+1 |
80 |
|
|
C Northern boundary |
81 |
|
|
IF (OB_Jn(I,bi,bj).NE.0) THEN |
82 |
|
|
uf(I,OB_Jn(I,bi,bj))=0. |
83 |
|
|
vf(I,OB_Jn(I,bi,bj))=0. |
84 |
|
|
ENDIF |
85 |
|
|
C Southern boundary |
86 |
|
|
IF (OB_Js(I,bi,bj).NE.0) THEN |
87 |
|
|
uf(I,OB_Js(I,bi,bj))=0. |
88 |
|
|
vf(I,OB_Js(I,bi,bj)+1)=0. |
89 |
|
|
ENDIF |
90 |
|
|
ENDDO |
91 |
|
|
DO j=1,sNy+1 |
92 |
|
|
C Eastern boundary |
93 |
|
|
IF (OB_Ie(J,bi,bj).NE.0) THEN |
94 |
|
|
uf(OB_Ie(J,bi,bj),J)=0. |
95 |
|
|
vf(OB_Ie(J,bi,bj),J)=0. |
96 |
|
|
ENDIF |
97 |
|
|
C Western boundary |
98 |
|
|
IF (OB_Iw(J,bi,bj).NE.0) THEN |
99 |
|
|
uf(OB_Iw(J,bi,bj)+1,J)=0. |
100 |
|
|
vf(OB_Iw(J,bi,bj),J)=0. |
101 |
|
|
ENDIF |
102 |
|
|
ENDDO |
103 |
|
|
ENDIF |
104 |
|
|
|
105 |
|
|
DO K=1,Nr |
106 |
|
|
DO j=1,sNy |
107 |
|
|
DO i=1,sNx |
108 |
|
|
c cg3d_x(i,j,k,bi,bj) = 0. |
109 |
|
|
cg3d_b(i,j,k,bi,bj) = cg3d_b(i,j,k,bi,bj) |
110 |
|
|
& +dRF(K)*dYG(i+1,j,bi,bj)*hFacW(i+1,j,k,bi,bj)*uf(i+1,j) |
111 |
|
|
& -dRF(K)*dYG( i ,j,bi,bj)*hFacW( i ,j,k,bi,bj)*uf( i ,j) |
112 |
|
|
& +dRF(K)*dXG(i,j+1,bi,bj)*hFacS(i,j+1,k,bi,bj)*vf(i,j+1) |
113 |
|
|
& -dRF(K)*dXG(i, j ,bi,bj)*hFacS(i, j ,k,bi,bj)*vf(i, j ) |
114 |
|
|
ENDDO |
115 |
|
|
ENDDO |
116 |
|
|
ENDDO |
117 |
|
|
|
118 |
|
|
ENDDO ! bi |
119 |
|
|
ENDDO ! bj |
120 |
|
|
|
121 |
|
|
CALL CG3D( myThid ) |
122 |
adcroft |
1.10 |
|
123 |
|
|
_EXCH_XYZ_R8(cg3d_x, myThid ) |
124 |
adcroft |
1.9 |
|
125 |
|
|
ENDIF |
126 |
|
|
#endif |
127 |
cnh |
1.1 |
|
128 |
|
|
RETURN |
129 |
|
|
END |