1 |
C $Header$ |
C $Header$ |
2 |
|
C $Name$ |
3 |
|
|
4 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
5 |
|
|
6 |
CStartOfInterface |
CBOP |
7 |
|
C !ROUTINE: INI_CG2D |
8 |
|
C !INTERFACE: |
9 |
SUBROUTINE INI_CG2D( myThid ) |
SUBROUTINE INI_CG2D( myThid ) |
|
C /==========================================================\ |
|
|
C | SUBROUTINE INI_CG2D | |
|
|
C | o Initialise 2d conjugate gradient solver operators. | |
|
|
C |==========================================================| |
|
|
C | These arrays are purely a function of the basin geom. | |
|
|
C | We set then here once and them use then repeatedly. | |
|
|
C \==========================================================/ |
|
|
IMPLICIT NONE |
|
10 |
|
|
11 |
|
C !DESCRIPTION: \bv |
12 |
|
C *==========================================================* |
13 |
|
C | SUBROUTINE INI_CG2D |
14 |
|
C | o Initialise 2d conjugate gradient solver operators. |
15 |
|
C *==========================================================* |
16 |
|
C | These arrays are purely a function of the basin geom. |
17 |
|
C | We set then here once and them use then repeatedly. |
18 |
|
C *==========================================================* |
19 |
|
C \ev |
20 |
|
|
21 |
|
C !USES: |
22 |
|
IMPLICIT NONE |
23 |
C === Global variables === |
C === Global variables === |
24 |
#include "SIZE.h" |
#include "SIZE.h" |
25 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
26 |
#include "PARAMS.h" |
#include "PARAMS.h" |
27 |
#include "GRID.h" |
#include "GRID.h" |
28 |
#include "DYNVARS.h" |
c#include "DYNVARS.h" |
29 |
|
#include "SURFACE.h" |
30 |
#include "CG2D.h" |
#include "CG2D.h" |
31 |
#ifdef ALLOW_OBCS |
#ifdef ALLOW_OBCS |
32 |
#include "OBCS.h" |
#include "OBCS.h" |
33 |
#endif |
#endif |
34 |
|
|
35 |
|
C !INPUT/OUTPUT PARAMETERS: |
36 |
C === Routine arguments === |
C === Routine arguments === |
37 |
C myThid - Thread no. that called this routine. |
C myThid - Thread no. that called this routine. |
38 |
INTEGER myThid |
INTEGER myThid |
|
CEndOfInterface |
|
39 |
|
|
40 |
|
C !LOCAL VARIABLES: |
41 |
C === Local variables === |
C === Local variables === |
42 |
C xG, yG - Global coordinate location. |
C xG, yG - Global coordinate location. |
43 |
C zG |
C zG |
45 |
C bi,bj - Loop counters |
C bi,bj - Loop counters |
46 |
C faceArea - Temporary used to hold cell face areas. |
C faceArea - Temporary used to hold cell face areas. |
47 |
C I,J,K |
C I,J,K |
48 |
C myNorm - Work variable used in clculating normalisation factor |
C myNorm - Work variable used in calculating normalisation factor |
49 |
|
C sumArea - Work variable used to compute the total Domain Area |
50 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
51 |
INTEGER bi, bj |
INTEGER bi, bj |
52 |
INTEGER I, J, K |
INTEGER I, J, K |
53 |
_RL faceArea |
_RL faceArea |
54 |
_RS myNorm |
_RS myNorm |
55 |
|
_RL sumArea |
56 |
_RL aC, aCw, aCs |
_RL aC, aCw, aCs |
57 |
|
CEOP |
58 |
|
|
59 |
C-- Initialise laplace operator |
C-- Initialise laplace operator |
60 |
C aW2d: integral in Z Ax/dX |
C aW2d: integral in Z Ax/dX |
74 |
faceArea = _dyG(I,J,bi,bj)*drF(K) |
faceArea = _dyG(I,J,bi,bj)*drF(K) |
75 |
& *_hFacW(I,J,K,bi,bj) |
& *_hFacW(I,J,K,bi,bj) |
76 |
aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj) + |
aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj) + |
77 |
& gBaro*faceArea*recip_dxC(I,J,bi,bj) |
& implicSurfPress*implicDiv2DFlow |
78 |
|
& *faceArea*recip_dxC(I,J,bi,bj) |
79 |
faceArea = _dxG(I,J,bi,bj)*drF(K) |
faceArea = _dxG(I,J,bi,bj)*drF(K) |
80 |
& *_hFacS(I,J,K,bi,bj) |
& *_hFacS(I,J,K,bi,bj) |
81 |
aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj) + |
aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj) + |
82 |
& gBaro*faceArea*recip_dyC(I,J,bi,bj) |
& implicSurfPress*implicDiv2DFlow |
83 |
|
& *faceArea*recip_dyC(I,J,bi,bj) |
84 |
ENDDO |
ENDDO |
85 |
ENDDO |
ENDDO |
86 |
ENDDO |
ENDDO |
140 |
C CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid ) |
141 |
C CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid ) |
142 |
CcnhDebugEnds |
CcnhDebugEnds |
143 |
_EXCH_XY_R4(aW2d, myThid) |
c _EXCH_XY_R4(aW2d, myThid) |
144 |
_EXCH_XY_R4(aS2d, myThid) |
c _EXCH_XY_R4(aS2d, myThid) |
145 |
|
CALL EXCH_UV_XY_RS(aW2d,aS2d,.FALSE.,myThid) |
146 |
CcnhDebugStarts |
CcnhDebugStarts |
147 |
C CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid ) |
148 |
C CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid ) |
149 |
CcnhDebugEnds |
CcnhDebugEnds |
150 |
|
|
151 |
|
C-- Define the solver tolerance in the appropriate Unit : |
152 |
|
cg2dNormaliseRHS = cg2dTargetResWunit.LE.0 |
153 |
|
IF (cg2dNormaliseRHS) THEN |
154 |
|
C- when using a normalisation of RHS, tolerance has no unit => no conversion |
155 |
|
cg2dTolerance = cg2dTargetResidual |
156 |
|
ELSE |
157 |
|
C- compute the total Area of the domain : |
158 |
|
sumArea = 0. |
159 |
|
DO bj=myByLo(myThid),myByHi(myThid) |
160 |
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
161 |
|
DO j=1,sNy |
162 |
|
DO i=1,sNx |
163 |
|
IF (Ro_surf(i,j,bi,bj).GT.R_low(i,j,bi,bj)) THEN |
164 |
|
sumArea = sumArea + rA(i,j,bi,bj) |
165 |
|
ENDIF |
166 |
|
ENDDO |
167 |
|
ENDDO |
168 |
|
ENDDO |
169 |
|
ENDDO |
170 |
|
c WRITE(*,*) ' mythid, sumArea = ', mythid, sumArea |
171 |
|
_GLOBAL_SUM_R8( sumArea, myThid ) |
172 |
|
C- convert Target-Residual (in W unit) to cg2d-solver residual unit [m^2/s^2] |
173 |
|
cg2dTolerance = cg2dNorm * cg2dTargetResWunit |
174 |
|
& * sumArea / deltaTMom |
175 |
|
WRITE(*,'(2A,1P2E22.14)') ' ini_cg2d: ', |
176 |
|
& 'sumArea,cg2dTolerance =', sumArea,cg2dTolerance |
177 |
|
ENDIF |
178 |
|
|
179 |
C-- Initialise preconditioner |
C-- Initialise preconditioner |
180 |
C Note. 20th May 1998 |
C Note. 20th May 1998 |
181 |
C I made a weird discovery! In the model paper we argue |
C I made a weird discovery! In the model paper we argue |
198 |
aC = -( |
aC = -( |
199 |
& aW2d(I,J,bi,bj) + aW2d(I+1,J ,bi,bj) |
& aW2d(I,J,bi,bj) + aW2d(I+1,J ,bi,bj) |
200 |
& +aS2d(I,J,bi,bj) + aS2d(I ,J+1,bi,bj) |
& +aS2d(I,J,bi,bj) + aS2d(I ,J+1,bi,bj) |
201 |
& +freeSurfFac*myNorm* horiVertRatio* |
& +freeSurfFac*myNorm*recip_Bo(I,J,bi,bj)* |
202 |
& rA(I,J,bi,bj)/deltaTMom/deltaTMom |
& rA(I,J,bi,bj)/deltaTMom/deltaTMom |
203 |
& ) |
& ) |
204 |
aCs = -( |
aCs = -( |
205 |
& aW2d(I,J-1,bi,bj) + aW2d(I+1,J-1,bi,bj) |
& aW2d(I,J-1,bi,bj) + aW2d(I+1,J-1,bi,bj) |
206 |
& +aS2d(I,J-1,bi,bj) + aS2d(I ,J ,bi,bj) |
& +aS2d(I,J-1,bi,bj) + aS2d(I ,J ,bi,bj) |
207 |
& +freeSurfFac*myNorm* horiVertRatio* |
& +freeSurfFac*myNorm*recip_Bo(I,J-1,bi,bj)* |
208 |
& rA(I,J-1,bi,bj)/deltaTMom/deltaTMom |
& rA(I,J-1,bi,bj)/deltaTMom/deltaTMom |
209 |
& ) |
& ) |
210 |
aCw = -( |
aCw = -( |
211 |
& aW2d(I-1,J,bi,bj) + aW2d(I ,J ,bi,bj) |
& aW2d(I-1,J,bi,bj) + aW2d(I ,J ,bi,bj) |
212 |
& +aS2d(I-1,J,bi,bj) + aS2d(I-1,J+1,bi,bj) |
& +aS2d(I-1,J,bi,bj) + aS2d(I-1,J+1,bi,bj) |
213 |
& +freeSurfFac*myNorm* horiVertRatio* |
& +freeSurfFac*myNorm*recip_Bo(I-1,J,bi,bj)* |
214 |
& rA(I-1,J,bi,bj)/deltaTMom/deltaTMom |
& rA(I-1,J,bi,bj)/deltaTMom/deltaTMom |
215 |
& ) |
& ) |
216 |
IF ( aC .EQ. 0. ) THEN |
IF ( aC .EQ. 0. ) THEN |
239 |
ENDDO |
ENDDO |
240 |
C-- Update overlap regions |
C-- Update overlap regions |
241 |
_EXCH_XY_R4(pC, myThid) |
_EXCH_XY_R4(pC, myThid) |
242 |
_EXCH_XY_R4(pW, myThid) |
c _EXCH_XY_R4(pW, myThid) |
243 |
_EXCH_XY_R4(pS, myThid) |
c _EXCH_XY_R4(pS, myThid) |
244 |
|
CALL EXCH_UV_XY_RS(pW,pS,.FALSE.,myThid) |
245 |
CcnhDebugStarts |
CcnhDebugStarts |
246 |
C CALL PLOT_FIELD_XYRS( pC, 'pC INI_CG2D.2' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( pC, 'pC INI_CG2D.2' , 1, myThid ) |
247 |
C CALL PLOT_FIELD_XYRS( pW, 'pW INI_CG2D.2' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( pW, 'pW INI_CG2D.2' , 1, myThid ) |
248 |
C CALL PLOT_FIELD_XYRS( pS, 'pS INI_CG2D.2' , 1, myThid ) |
C CALL PLOT_FIELD_XYRS( pS, 'pS INI_CG2D.2' , 1, myThid ) |
249 |
CcnhDebugEnds |
CcnhDebugEnds |
250 |
|
|
|
C-- Set default values for initial guess and RHS |
|
|
IF ( startTime .EQ. 0 ) THEN |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
|
|
DO J=1,sNy |
|
|
DO I=1,sNx |
|
|
cg2d_x(I,J,bi,bj) = 0. _d 0 |
|
|
cg2d_b(I,J,bi,bj) = 0. _d 0 |
|
|
#ifdef INCLUDE_CD_CODE |
|
|
cg2d_xNM1(I,J,bi,bj) = 0. _d 0 |
|
|
#endif |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDDO |
|
|
C-- Update overlap regions |
|
|
_EXCH_XY_R8(cg2d_x, myThid) |
|
|
_EXCH_XY_R8(cg2d_b, myThid) |
|
|
#ifdef INCLUDE_CD_CODE |
|
|
_EXCH_XY_R8(cg2d_xNM1, myThid) |
|
|
#endif |
|
|
ENDIF |
|
|
|
|
251 |
RETURN |
RETURN |
252 |
END |
END |