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

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

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

revision 1.23 by adcroft, Wed Dec 9 16:11:52 1998 UTC revision 1.41.2.1 by edhill, Thu Oct 2 18:10:45 2003 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4    #include "PACKAGES_CONFIG.h"
5  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
6    
7  CStartOfInterface  CBOP
8    C     !ROUTINE: INI_CG2D
9    C     !INTERFACE:
10        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  
11    
12    C     !DESCRIPTION: \bv
13    C     *==========================================================*
14    C     | SUBROUTINE INI_CG2D                                      
15    C     | o Initialise 2d conjugate gradient solver operators.      
16    C     *==========================================================*
17    C     | These arrays are purely a function of the basin geom.    
18    C     | We set then here once and them use then repeatedly.      
19    C     *==========================================================*
20    C     \ev
21    
22    C     !USES:
23          IMPLICIT NONE
24  C     === Global variables ===  C     === Global variables ===
25  #include "SIZE.h"  #include "SIZE.h"
26  #include "EEPARAMS.h"  #include "EEPARAMS.h"
27  #include "PARAMS.h"  #include "PARAMS.h"
28  #include "GRID.h"  #include "GRID.h"
29  #include "DYNVARS.h"  c#include "DYNVARS.h"
30    #include "SURFACE.h"
31  #include "CG2D.h"  #include "CG2D.h"
32    #ifdef ALLOW_OBCS
33  #include "OBCS.h"  #include "OBCS.h"
34    #endif
35    
36    C     !INPUT/OUTPUT PARAMETERS:
37  C     === Routine arguments ===  C     === Routine arguments ===
38  C     myThid - Thread no. that called this routine.  C     myThid - Thread no. that called this routine.
39        INTEGER myThid        INTEGER myThid
 CEndOfInterface  
40    
41    C     !LOCAL VARIABLES:
42  C     === Local variables ===  C     === Local variables ===
43  C     xG, yG - Global coordinate location.  C     xG, yG - Global coordinate location.
44  C     zG  C     zG
# Line 34  C     iG, jG - Global coordinate index Line 46  C     iG, jG - Global coordinate index
46  C     bi,bj  - Loop counters  C     bi,bj  - Loop counters
47  C     faceArea - Temporary used to hold cell face areas.  C     faceArea - Temporary used to hold cell face areas.
48  C     I,J,K  C     I,J,K
49  C     myNorm - Work variable used in clculating normalisation factor  C     myNorm - Work variable used in calculating normalisation factor
50    C     sumArea - Work variable used to compute the total Domain Area
51        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
52        INTEGER bi, bj        INTEGER bi, bj
53        INTEGER I,  J, K        INTEGER I,  J, K
54        _RL     faceArea        _RL     faceArea
55        _RS     myNorm        _RS     myNorm
56          _RL     sumArea
57        _RL     aC, aCw, aCs        _RL     aC, aCw, aCs
58    CEOP
59    
60    C--   Initialize arrays in common blocs (CG2D.h) ; not really necessary
61    C     but safer when EXCH do not fill all the overlap regions.
62          DO bj=myByLo(myThid),myByHi(myThid)
63           DO bi=myBxLo(myThid),myBxHi(myThid)
64            DO J=1-OLy,sNy+OLy
65             DO I=1-OLx,sNx+OLx
66              aW2d(I,J,bi,bj) = 0. _d 0
67              aS2d(I,J,bi,bj) = 0. _d 0
68              pW(I,J,bi,bj) = 0. _d 0
69              pS(I,J,bi,bj) = 0. _d 0
70              pC(I,J,bi,bj) = 0. _d 0
71              cg2d_q(I,J,bi,bj) = 0. _d 0
72             ENDDO
73            ENDDO
74            DO J=1-1,sNy+1
75             DO I=1-1,sNx+1
76              cg2d_r(I,J,bi,bj) = 0. _d 0
77              cg2d_s(I,J,bi,bj) = 0. _d 0
78             ENDDO
79            ENDDO
80           ENDDO
81          ENDDO
82    
83  C--   Initialise laplace operator  C--   Initialise laplace operator
84  C     aW2d: integral in Z Ax/dX  C     aW2d: integral in Z Ax/dX
# Line 60  C     aS2d: integral in Z Ay/dY Line 98  C     aS2d: integral in Z Ay/dY
98             faceArea = _dyG(I,J,bi,bj)*drF(K)             faceArea = _dyG(I,J,bi,bj)*drF(K)
99       &               *_hFacW(I,J,K,bi,bj)       &               *_hFacW(I,J,K,bi,bj)
100             aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj) +             aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj) +
101       &      gBaro*faceArea*recip_dxC(I,J,bi,bj)       &      implicSurfPress*implicDiv2DFlow
102         &           *faceArea*recip_dxC(I,J,bi,bj)
103             faceArea = _dxG(I,J,bi,bj)*drF(K)             faceArea = _dxG(I,J,bi,bj)*drF(K)
104       &               *_hFacS(I,J,K,bi,bj)       &               *_hFacS(I,J,K,bi,bj)
105             aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj) +             aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj) +
106       &      gBaro*faceArea*recip_dyC(I,J,bi,bj)       &      implicSurfPress*implicDiv2DFlow
107         &           *faceArea*recip_dyC(I,J,bi,bj)
108            ENDDO            ENDDO
109           ENDDO           ENDDO
110          ENDDO          ENDDO
111          IF (openBoundaries) THEN  #ifdef ALLOW_OBCS
112            IF (useOBCS) THEN
113           DO I=1,sNx           DO I=1,sNx
114            IF (OB_Jn(I,bi,bj).NE.0) aS2d(I,OB_Jn(I,bi,bj),bi,bj)=0.            IF (OB_Jn(I,bi,bj).NE.0) aS2d(I,OB_Jn(I,bi,bj),bi,bj)=0.
115            IF (OB_Jn(I,bi,bj).NE.0) aS2d(I,OB_Jn(I,bi,bj)+1,bi,bj)=0.            IF (OB_Jn(I,bi,bj).NE.0) aS2d(I,OB_Jn(I,bi,bj)+1,bi,bj)=0.
# Line 82  C     aS2d: integral in Z Ay/dY Line 123  C     aS2d: integral in Z Ay/dY
123            IF (OB_Iw(J,bi,bj).NE.0) aW2d(OB_Iw(J,bi,bj),J,bi,bj)=0.            IF (OB_Iw(J,bi,bj).NE.0) aW2d(OB_Iw(J,bi,bj),J,bi,bj)=0.
124           ENDDO           ENDDO
125          ENDIF          ENDIF
126    #endif
127          DO J=1,sNy          DO J=1,sNy
128           DO I=1,sNx           DO I=1,sNx
129            myNorm = MAX(ABS(aW2d(I,J,bi,bj)),myNorm)            myNorm = MAX(ABS(aW2d(I,J,bi,bj)),myNorm)
# Line 90  C     aS2d: integral in Z Ay/dY Line 132  C     aS2d: integral in Z Ay/dY
132          ENDDO          ENDDO
133         ENDDO         ENDDO
134        ENDDO        ENDDO
135        cg2dNbuf(1,myThid) = myNorm        _GLOBAL_MAX_R4( myNorm, myThid )
136        _GLOBAL_MAX_R4( cg2dNbuf, myNorm, myThid )        IF ( myNorm .NE. 0. _d 0 ) THEN
137        IF ( cg2dNbuf(1,1) .NE. 0. _d 0 ) THEN         myNorm = 1. _d 0/myNorm
        myNorm = 1. _d 0/cg2dNbuf(1,1)  
138        ELSE        ELSE
139         myNorm = 1. _d 0         myNorm = 1. _d 0
140        ENDIF        ENDIF
# Line 123  CcnhDebugStarts Line 164  CcnhDebugStarts
164  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid )
165  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid )
166  CcnhDebugEnds  CcnhDebugEnds
167        _EXCH_XY_R4(aW2d, myThid)  c     _EXCH_XY_R4(aW2d, myThid)
168        _EXCH_XY_R4(aS2d, myThid)  c     _EXCH_XY_R4(aS2d, myThid)
169          CALL EXCH_UV_XY_RS(aW2d,aS2d,.FALSE.,myThid)
170  CcnhDebugStarts  CcnhDebugStarts
171        CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid )
172        CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid )
173  CcnhDebugEnds  CcnhDebugEnds
174    
175    C-- Define the solver tolerance in the appropriate Unit :
176          cg2dNormaliseRHS = cg2dTargetResWunit.LE.0
177          IF (cg2dNormaliseRHS) THEN
178    C-  when using a normalisation of RHS, tolerance has no unit => no conversion
179            cg2dTolerance = cg2dTargetResidual
180          ELSE
181    C-  compute the total Area of the domain :
182            sumArea = 0.
183            DO bj=myByLo(myThid),myByHi(myThid)
184             DO bi=myBxLo(myThid),myBxHi(myThid)
185              DO j=1,sNy
186               DO i=1,sNx
187                 IF (Ro_surf(i,j,bi,bj).GT.R_low(i,j,bi,bj)) THEN
188                   sumArea = sumArea + rA(i,j,bi,bj)
189                 ENDIF
190               ENDDO
191              ENDDO
192             ENDDO
193            ENDDO
194    c       WRITE(*,*) ' mythid, sumArea = ', mythid, sumArea
195            _GLOBAL_SUM_R8( sumArea, myThid )
196    C-  convert Target-Residual (in W unit) to cg2d-solver residual unit [m^2/s^2]
197            cg2dTolerance = cg2dNorm * cg2dTargetResWunit
198         &                           * sumArea / deltaTmom
199            _BEGIN_MASTER( myThid )
200            WRITE(standardMessageUnit,'(2A,1P2E22.14)') ' ini_cg2d: ',
201         &          'sumArea,cg2dTolerance =', sumArea,cg2dTolerance
202            _END_MASTER( myThid )
203          ENDIF
204        
205  C--   Initialise preconditioner  C--   Initialise preconditioner
206  C     Note. 20th May 1998  C     Note. 20th May 1998
207  C           I made a weird discovery! In the model paper we argue  C           I made a weird discovery! In the model paper we argue
# Line 151  C           defaults to 0.51 but can be Line 223  C           defaults to 0.51 but can be
223            pC(I,J,bi,bj) = 1. _d 0            pC(I,J,bi,bj) = 1. _d 0
224            aC = -(            aC = -(
225       &     aW2d(I,J,bi,bj) + aW2d(I+1,J  ,bi,bj)       &     aW2d(I,J,bi,bj) + aW2d(I+1,J  ,bi,bj)
226       &    +aS2d(I,J,bi,bj) + aS2D(I  ,J+1,bi,bj)       &    +aS2d(I,J,bi,bj) + aS2d(I  ,J+1,bi,bj)
227       &    +freeSurfFac*myNorm* horiVertRatio*       &    +freeSurfFac*myNorm*recip_Bo(I,J,bi,bj)*
228       &     rA(I,J,bi,bj)/deltaTMom/deltaTMom       &     rA(I,J,bi,bj)/deltaTMom/deltaTfreesurf
229       &    )       &    )
230            aCs = -(            aCs = -(
231       &     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)
232       &    +aS2d(I,J-1,bi,bj) + aS2d(I  ,J  ,bi,bj)       &    +aS2d(I,J-1,bi,bj) + aS2d(I  ,J  ,bi,bj)
233       &    +freeSurfFac*myNorm* horiVertRatio*       &    +freeSurfFac*myNorm*recip_Bo(I,J-1,bi,bj)*
234       &     rA(I,J-1,bi,bj)/deltaTMom/deltaTMom       &     rA(I,J-1,bi,bj)/deltaTMom/deltaTfreesurf
235       &    )       &    )
236            aCw = -(            aCw = -(
237       &     aW2d(I-1,J,bi,bj) + aW2d(I  ,J  ,bi,bj)       &     aW2d(I-1,J,bi,bj) + aW2d(I  ,J  ,bi,bj)
238       &    +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)
239       &    +freeSurfFac*myNorm* horiVertRatio*       &    +freeSurfFac*myNorm*recip_Bo(I-1,J,bi,bj)*
240       &     rA(I-1,J,bi,bj)/deltaTMom/deltaTMom       &     rA(I-1,J,bi,bj)/deltaTMom/deltaTfreesurf
241       &    )       &    )
242            IF ( aC .EQ. 0. ) THEN            IF ( aC .EQ. 0. ) THEN
243              pC(I,J,bi,bj) = 0. _d 0              pC(I,J,bi,bj) = 1. _d 0
244            ELSE            ELSE
245             pC(I,J,bi,bj) =  1. _d 0 / aC             pC(I,J,bi,bj) =  1. _d 0 / aC
246            ENDIF            ENDIF
# Line 193  C         pS(I,J,bi,bj) = 0. Line 265  C         pS(I,J,bi,bj) = 0.
265        ENDDO        ENDDO
266  C--   Update overlap regions  C--   Update overlap regions
267        _EXCH_XY_R4(pC, myThid)        _EXCH_XY_R4(pC, myThid)
268        _EXCH_XY_R4(pW, myThid)  c     _EXCH_XY_R4(pW, myThid)
269        _EXCH_XY_R4(pS, myThid)  c     _EXCH_XY_R4(pS, myThid)
270          CALL EXCH_UV_XY_RS(pW,pS,.FALSE.,myThid)
271  CcnhDebugStarts  CcnhDebugStarts
272        CALL PLOT_FIELD_XYRS( pC, 'pC   INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( pC, 'pC   INI_CG2D.2' , 1, myThid )
273        CALL PLOT_FIELD_XYRS( pW, 'pW   INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( pW, 'pW   INI_CG2D.2' , 1, myThid )
274        CALL PLOT_FIELD_XYRS( pS, 'pS   INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( pS, 'pS   INI_CG2D.2' , 1, myThid )
275  CcnhDebugEnds  CcnhDebugEnds
276    
 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  
   
277        RETURN        RETURN
278        END        END

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.41.2.1

  ViewVC Help
Powered by ViewVC 1.1.22