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

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

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


Revision 1.23 - (show annotations) (download)
Wed Dec 9 16:11:52 1998 UTC (25 years, 5 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint19
Changes since 1.22: +2 -1 lines
Added IMPLICIT NONE in a lot of subroutines.
Also corrected the recip_Rhonil bug: we didn't set it in ini_parms.F

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_cg2d.F,v 1.22 1998/12/08 19:44:28 adcroft Exp $
2
3 #include "CPP_OPTIONS.h"
4
5 CStartOfInterface
6 SUBROUTINE INI_CG2D( myThid )
7 C /==========================================================\
8 C | SUBROUTINE INI_CG2D |
9 C | o Initialise 2d conjugate gradient solver operators. |
10 C |==========================================================|
11 C | These arrays are purely a function of the basin geom. |
12 C | We set then here once and them use then repeatedly. |
13 C \==========================================================/
14 IMPLICIT NONE
15
16 C === Global variables ===
17 #include "SIZE.h"
18 #include "EEPARAMS.h"
19 #include "PARAMS.h"
20 #include "GRID.h"
21 #include "DYNVARS.h"
22 #include "CG2D.h"
23 #include "OBCS.h"
24
25 C === Routine arguments ===
26 C myThid - Thread no. that called this routine.
27 INTEGER myThid
28 CEndOfInterface
29
30 C === Local variables ===
31 C xG, yG - Global coordinate location.
32 C zG
33 C iG, jG - Global coordinate index
34 C bi,bj - Loop counters
35 C faceArea - Temporary used to hold cell face areas.
36 C I,J,K
37 C myNorm - Work variable used in clculating normalisation factor
38 CHARACTER*(MAX_LEN_MBUF) msgBuf
39 INTEGER bi, bj
40 INTEGER I, J, K
41 _RL faceArea
42 _RS myNorm
43 _RL aC, aCw, aCs
44
45 C-- Initialise laplace operator
46 C aW2d: integral in Z Ax/dX
47 C aS2d: integral in Z Ay/dY
48 myNorm = 0. _d 0
49 DO bj=myByLo(myThid),myByHi(myThid)
50 DO bi=myBxLo(myThid),myBxHi(myThid)
51 DO J=1,sNy
52 DO I=1,sNx
53 aW2d(I,J,bi,bj) = 0. _d 0
54 aS2d(I,J,bi,bj) = 0. _d 0
55 ENDDO
56 ENDDO
57 DO K=1,Nr
58 DO J=1,sNy
59 DO I=1,sNx
60 faceArea = _dyG(I,J,bi,bj)*drF(K)
61 & *_hFacW(I,J,K,bi,bj)
62 aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj) +
63 & gBaro*faceArea*recip_dxC(I,J,bi,bj)
64 faceArea = _dxG(I,J,bi,bj)*drF(K)
65 & *_hFacS(I,J,K,bi,bj)
66 aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj) +
67 & gBaro*faceArea*recip_dyC(I,J,bi,bj)
68 ENDDO
69 ENDDO
70 ENDDO
71 IF (openBoundaries) THEN
72 DO I=1,sNx
73 IF (OB_Jn(I,bi,bj).NE.0) aS2d(I,OB_Jn(I,bi,bj),bi,bj)=0.
74 IF (OB_Jn(I,bi,bj).NE.0) aS2d(I,OB_Jn(I,bi,bj)+1,bi,bj)=0.
75 IF (OB_Js(I,bi,bj).NE.0) aS2d(I,OB_Js(I,bi,bj)+1,bi,bj)=0.
76 IF (OB_Js(I,bi,bj).NE.0) aS2d(I,OB_Js(I,bi,bj),bi,bj)=0.
77 ENDDO
78 DO J=1,sNy
79 IF (OB_Ie(J,bi,bj).NE.0) aW2d(OB_Ie(J,bi,bj),J,bi,bj)=0.
80 IF (OB_Ie(J,bi,bj).NE.0) aW2d(OB_Ie(J,bi,bj)+1,J,bi,bj)=0.
81 IF (OB_Iw(J,bi,bj).NE.0) aW2d(OB_Iw(J,bi,bj)+1,J,bi,bj)=0.
82 IF (OB_Iw(J,bi,bj).NE.0) aW2d(OB_Iw(J,bi,bj),J,bi,bj)=0.
83 ENDDO
84 ENDIF
85 DO J=1,sNy
86 DO I=1,sNx
87 myNorm = MAX(ABS(aW2d(I,J,bi,bj)),myNorm)
88 myNorm = MAX(ABS(aS2d(I,J,bi,bj)),myNorm)
89 ENDDO
90 ENDDO
91 ENDDO
92 ENDDO
93 cg2dNbuf(1,myThid) = myNorm
94 _GLOBAL_MAX_R4( cg2dNbuf, myNorm, myThid )
95 IF ( cg2dNbuf(1,1) .NE. 0. _d 0 ) THEN
96 myNorm = 1. _d 0/cg2dNbuf(1,1)
97 ELSE
98 myNorm = 1. _d 0
99 ENDIF
100 cg2dNorm = myNorm
101 _BEGIN_MASTER( myThid )
102 CcnhDebugStarts
103 WRITE(msgBuf,'(A,E40.25)') '// CG2D normalisation factor = ',
104 & cg2dNorm
105 CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)
106 WRITE(msgBuf,*) ' '
107 CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)
108 CcnhDebugEnds
109 _END_MASTER( myThid )
110 DO bj=myByLo(myThid),myByHi(myThid)
111 DO bi=myBxLo(myThid),myBxHi(myThid)
112 DO J=1,sNy
113 DO I=1,sNx
114 aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj)*myNorm
115 aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj)*myNorm
116 ENDDO
117 ENDDO
118 ENDDO
119 ENDDO
120
121 C-- Update overlap regions
122 CcnhDebugStarts
123 C CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid )
124 C CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid )
125 CcnhDebugEnds
126 _EXCH_XY_R4(aW2d, myThid)
127 _EXCH_XY_R4(aS2d, myThid)
128 CcnhDebugStarts
129 CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid )
130 CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid )
131 CcnhDebugEnds
132
133 C-- Initialise preconditioner
134 C Note. 20th May 1998
135 C I made a weird discovery! In the model paper we argue
136 C for the form of the preconditioner used here ( see
137 C A Finite-volume, Incompressible Navier-Stokes Model
138 C ...., Marshall et. al ). The algebra gives a simple
139 C 0.5 factor for the averaging of ac and aCw to get a
140 C symmettric pre-conditioner. By using a factor of 0.51
141 C i.e. scaling the off-diagonal terms in the
142 C preconditioner down slightly I managed to get the
143 C number of iterations for convergence in a test case to
144 C drop form 192 -> 134! Need to investigate this further!
145 C For now I have introduced a parameter cg2dpcOffDFac which
146 C defaults to 0.51 but can be set at runtime.
147 DO bj=myByLo(myThid),myByHi(myThid)
148 DO bi=myBxLo(myThid),myBxHi(myThid)
149 DO J=1,sNy
150 DO I=1,sNx
151 pC(I,J,bi,bj) = 1. _d 0
152 aC = -(
153 & aW2d(I,J,bi,bj) + aW2d(I+1,J ,bi,bj)
154 & +aS2d(I,J,bi,bj) + aS2D(I ,J+1,bi,bj)
155 & +freeSurfFac*myNorm* horiVertRatio*
156 & rA(I,J,bi,bj)/deltaTMom/deltaTMom
157 & )
158 aCs = -(
159 & aW2d(I,J-1,bi,bj) + aW2d(I+1,J-1,bi,bj)
160 & +aS2d(I,J-1,bi,bj) + aS2d(I ,J ,bi,bj)
161 & +freeSurfFac*myNorm* horiVertRatio*
162 & rA(I,J-1,bi,bj)/deltaTMom/deltaTMom
163 & )
164 aCw = -(
165 & aW2d(I-1,J,bi,bj) + aW2d(I ,J ,bi,bj)
166 & +aS2d(I-1,J,bi,bj) + aS2d(I-1,J+1,bi,bj)
167 & +freeSurfFac*myNorm* horiVertRatio*
168 & rA(I-1,J,bi,bj)/deltaTMom/deltaTMom
169 & )
170 IF ( aC .EQ. 0. ) THEN
171 pC(I,J,bi,bj) = 0. _d 0
172 ELSE
173 pC(I,J,bi,bj) = 1. _d 0 / aC
174 ENDIF
175 IF ( aC + aCw .EQ. 0. ) THEN
176 pW(I,J,bi,bj) = 0.
177 ELSE
178 pW(I,J,bi,bj) =
179 & -aW2d(I ,J ,bi,bj)/((cg2dpcOffDFac *(aCw+aC))**2 )
180 ENDIF
181 IF ( aC + aCs .EQ. 0. ) THEN
182 pS(I,J,bi,bj) = 0.
183 ELSE
184 pS(I,J,bi,bj) =
185 & -aS2d(I ,J ,bi,bj)/((cg2dpcOffDFac *(aCs+aC))**2 )
186 ENDIF
187 C pC(I,J,bi,bj) = 1.
188 C pW(I,J,bi,bj) = 0.
189 C pS(I,J,bi,bj) = 0.
190 ENDDO
191 ENDDO
192 ENDDO
193 ENDDO
194 C-- Update overlap regions
195 _EXCH_XY_R4(pC, myThid)
196 _EXCH_XY_R4(pW, myThid)
197 _EXCH_XY_R4(pS, myThid)
198 CcnhDebugStarts
199 CALL PLOT_FIELD_XYRS( pC, 'pC INI_CG2D.2' , 1, myThid )
200 CALL PLOT_FIELD_XYRS( pW, 'pW INI_CG2D.2' , 1, myThid )
201 CALL PLOT_FIELD_XYRS( pS, 'pS INI_CG2D.2' , 1, myThid )
202 CcnhDebugEnds
203
204 C-- Set default values for initial guess and RHS
205 IF ( startTime .EQ. 0 ) THEN
206 DO bj=myByLo(myThid),myByHi(myThid)
207 DO bi=myBxLo(myThid),myBxHi(myThid)
208 DO J=1,sNy
209 DO I=1,sNx
210 cg2d_x(I,J,bi,bj) = 0. _d 0
211 cg2d_b(I,J,bi,bj) = 0. _d 0
212 #ifdef INCLUDE_CD_CODE
213 cg2d_xNM1(I,J,bi,bj) = 0. _d 0
214 #endif
215 ENDDO
216 ENDDO
217 ENDDO
218 ENDDO
219 C-- Update overlap regions
220 _EXCH_XY_R8(cg2d_x, myThid)
221 _EXCH_XY_R8(cg2d_b, myThid)
222 #ifdef INCLUDE_CD_CODE
223 _EXCH_XY_R8(cg2d_xNM1, myThid)
224 #endif
225 ENDIF
226
227 RETURN
228 END

  ViewVC Help
Powered by ViewVC 1.1.22