/[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.38 by jmc, Sun Feb 10 20:04:11 2002 UTC revision 1.46 by jmc, Tue Apr 28 18:01:14 2009 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
4    #include "PACKAGES_CONFIG.h"
5  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
6    
7  CBOP  CBOP
# Line 25  C     === Global variables === Line 26  C     === Global variables ===
26  #include "EEPARAMS.h"  #include "EEPARAMS.h"
27  #include "PARAMS.h"  #include "PARAMS.h"
28  #include "GRID.h"  #include "GRID.h"
 c#include "DYNVARS.h"  
29  #include "SURFACE.h"  #include "SURFACE.h"
30  #include "CG2D.h"  #include "CG2D.h"
31  #ifdef ALLOW_OBCS  #ifdef ALLOW_OBCS
# Line 39  C     myThid - Thread no. that called th Line 39  C     myThid - Thread no. that called th
39    
40  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
41  C     === Local variables ===  C     === Local variables ===
42  C     xG, yG - Global coordinate location.  C     bi,bj  :: tile indices
43  C     zG  C     I,J,K  :: Loop counters
 C     iG, jG - Global coordinate index  
 C     bi,bj  - Loop counters  
44  C     faceArea - Temporary used to hold cell face areas.  C     faceArea - Temporary used to hold cell face areas.
 C     I,J,K  
45  C     myNorm - Work variable used in calculating normalisation factor  C     myNorm - Work variable used in calculating normalisation factor
46  C     sumArea - Work variable used to compute the total Domain Area  C     sumArea - Work variable used to compute the total Domain Area
47        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
48        INTEGER bi, bj        INTEGER bi, bj
49        INTEGER I,  J, K        INTEGER I, J, K, ks
50        _RL     faceArea        _RL     faceArea
51        _RS     myNorm        _RS     myNorm
52        _RL     sumArea        _RS     aC, aCw, aCs
       _RL     aC, aCw, aCs  
53  CEOP  CEOP
54    
55  C--   Initialize arrays in common blocs (CG2D.h) ; not really necessary  C--   Initialize arrays in common blocs (CG2D.h) ; not really necessary
56  C     but safer when EXCH do not fill all the overlap regions.  C     but safer when EXCH do not fill all the overlap regions.
57        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
58         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
# Line 64  C     but safer when EXCH do not fill al Line 60  C     but safer when EXCH do not fill al
60           DO I=1-OLx,sNx+OLx           DO I=1-OLx,sNx+OLx
61            aW2d(I,J,bi,bj) = 0. _d 0            aW2d(I,J,bi,bj) = 0. _d 0
62            aS2d(I,J,bi,bj) = 0. _d 0            aS2d(I,J,bi,bj) = 0. _d 0
63              aC2d(I,J,bi,bj) = 0. _d 0
64            pW(I,J,bi,bj) = 0. _d 0            pW(I,J,bi,bj) = 0. _d 0
65            pS(I,J,bi,bj) = 0. _d 0            pS(I,J,bi,bj) = 0. _d 0
66            pC(I,J,bi,bj) = 0. _d 0            pC(I,J,bi,bj) = 0. _d 0
# Line 94  C     aS2d: integral in Z Ay/dY Line 91  C     aS2d: integral in Z Ay/dY
91          DO K=1,Nr          DO K=1,Nr
92           DO J=1,sNy           DO J=1,sNy
93            DO I=1,sNx            DO I=1,sNx
94    C  deep-model: *deepFacC (faceArea), /deepFacC (recip_dx,y): => no net effect
95             faceArea = _dyG(I,J,bi,bj)*drF(K)             faceArea = _dyG(I,J,bi,bj)*drF(K)
96       &               *_hFacW(I,J,K,bi,bj)       &               *_hFacW(I,J,K,bi,bj)
97             aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj) +             aW2d(I,J,bi,bj) = aW2d(I,J,bi,bj)
98       &      implicSurfPress*implicDiv2DFlow       &              + implicSurfPress*implicDiv2DFlow
99       &           *faceArea*recip_dxC(I,J,bi,bj)       &               *faceArea*recip_dxC(I,J,bi,bj)
100             faceArea = _dxG(I,J,bi,bj)*drF(K)             faceArea = _dxG(I,J,bi,bj)*drF(K)
101       &               *_hFacS(I,J,K,bi,bj)       &               *_hFacS(I,J,K,bi,bj)
102             aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj) +             aS2d(I,J,bi,bj) = aS2d(I,J,bi,bj)
103       &      implicSurfPress*implicDiv2DFlow       &              + implicSurfPress*implicDiv2DFlow
104       &           *faceArea*recip_dyC(I,J,bi,bj)       &               *faceArea*recip_dyC(I,J,bi,bj)
105            ENDDO            ENDDO
106           ENDDO           ENDDO
107          ENDDO          ENDDO
# Line 131  C     aS2d: integral in Z Ay/dY Line 129  C     aS2d: integral in Z Ay/dY
129          ENDDO          ENDDO
130         ENDDO         ENDDO
131        ENDDO        ENDDO
132        _GLOBAL_MAX_R4( myNorm, myThid )        _GLOBAL_MAX_RS( myNorm, myThid )
133        IF ( myNorm .NE. 0. _d 0 ) THEN        IF ( myNorm .NE. 0. _d 0 ) THEN
134         myNorm = 1. _d 0/myNorm         myNorm = 1. _d 0/myNorm
135        ELSE        ELSE
136         myNorm = 1. _d 0         myNorm = 1. _d 0
137        ENDIF        ENDIF
        cg2dNorm = myNorm  
       _BEGIN_MASTER( myThid )  
 CcnhDebugStarts  
        WRITE(msgBuf,'(A,E40.25)') '// CG2D normalisation factor = ',  
      &               cg2dNorm  
        CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)  
        WRITE(msgBuf,*) '                               '  
        CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)  
 CcnhDebugEnds  
       _END_MASTER( myThid )  
138        DO bj=myByLo(myThid),myByHi(myThid)        DO bj=myByLo(myThid),myByHi(myThid)
139         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
140          DO J=1,sNy          DO J=1,sNy
# Line 157  CcnhDebugEnds Line 145  CcnhDebugEnds
145          ENDDO          ENDDO
146         ENDDO         ENDDO
147        ENDDO        ENDDO
148          
149  C--   Update overlap regions  C--   Update overlap regions
150  CcnhDebugStarts  CcnhDebugStarts
151  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.1' , 1, myThid )
152  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.1' , 1, myThid )
153  CcnhDebugEnds  CcnhDebugEnds
154  c     _EXCH_XY_R4(aW2d, myThid)  c     _EXCH_XY_RS(aW2d, myThid)
155  c     _EXCH_XY_R4(aS2d, myThid)  c     _EXCH_XY_RS(aS2d, myThid)
156        CALL EXCH_UV_XY_RS(aW2d,aS2d,.FALSE.,myThid)        CALL EXCH_UV_XY_RS(aW2d,aS2d,.FALSE.,myThid)
157  CcnhDebugStarts  CcnhDebugStarts
158  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aW2d, 'AW2D INI_CG2D.2' , 1, myThid )
159  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( aS2d, 'AS2D INI_CG2D.2' , 1, myThid )
160  CcnhDebugEnds  CcnhDebugEnds
161    
162          _BEGIN_MASTER(myThid)
163    C-- set global parameter in common block:
164          cg2dNorm = myNorm
165  C-- Define the solver tolerance in the appropriate Unit :  C-- Define the solver tolerance in the appropriate Unit :
166        cg2dNormaliseRHS = cg2dTargetResWunit.LE.0        cg2dNormaliseRHS = cg2dTargetResWunit.LE.0.
167        IF (cg2dNormaliseRHS) THEN        IF (cg2dNormaliseRHS) THEN
168  C-  when using a normalisation of RHS, tolerance has no unit => no conversion  C-  when using a normalisation of RHS, tolerance has no unit => no conversion
169          cg2dTolerance = cg2dTargetResidual          cg2dTolerance = cg2dTargetResidual
170        ELSE        ELSE
 C-  compute the total Area of the domain :  
         sumArea = 0.  
         DO bj=myByLo(myThid),myByHi(myThid)  
          DO bi=myBxLo(myThid),myBxHi(myThid)  
           DO j=1,sNy  
            DO i=1,sNx  
              IF (Ro_surf(i,j,bi,bj).GT.R_low(i,j,bi,bj)) THEN  
                sumArea = sumArea + rA(i,j,bi,bj)  
              ENDIF  
            ENDDO  
           ENDDO  
          ENDDO  
         ENDDO  
 c       WRITE(*,*) ' mythid, sumArea = ', mythid, sumArea  
         _GLOBAL_SUM_R8( sumArea, myThid )  
171  C-  convert Target-Residual (in W unit) to cg2d-solver residual unit [m^2/s^2]  C-  convert Target-Residual (in W unit) to cg2d-solver residual unit [m^2/s^2]
172          cg2dTolerance = cg2dNorm * cg2dTargetResWunit          cg2dTolerance = cg2dNorm * cg2dTargetResWunit
173       &                           * sumArea / deltaTMom       &                           * globalArea / deltaTmom
         WRITE(*,'(2A,1P2E22.14)') ' ini_cg2d: ',  
      &          'sumArea,cg2dTolerance =', sumArea,cg2dTolerance  
174        ENDIF        ENDIF
175              _END_MASTER(myThid)
176    
177    CcnhDebugStarts
178          _BEGIN_MASTER( myThid )
179           WRITE(msgBuf,'(2A,1PE23.16)') 'INI_CG2D: ',
180         &      'CG2D normalisation factor = ', cg2dNorm
181           CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)
182           IF (.NOT.cg2dNormaliseRHS) THEN
183            WRITE(msgBuf,'(2A,1PE22.15,A,1PE16.10,A)') 'INI_CG2D: ',
184         &      'cg2dTolerance =', cg2dTolerance, ' (Area=',globalArea,')'
185            CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)
186           ENDIF
187           WRITE(msgBuf,*) ' '
188           CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1)
189          _END_MASTER( myThid )
190    CcnhDebugEnds
191    
192  C--   Initialise preconditioner  C--   Initialise preconditioner
193  C     Note. 20th May 1998  C     Note. 20th May 1998
194  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 217  C           defaults to 0.51 but can be Line 207  C           defaults to 0.51 but can be
207         DO bi=myBxLo(myThid),myBxHi(myThid)         DO bi=myBxLo(myThid),myBxHi(myThid)
208          DO J=1,sNy          DO J=1,sNy
209           DO I=1,sNx           DO I=1,sNx
210              ks = ksurfC(I,J,bi,bj)
211            pC(I,J,bi,bj) = 1. _d 0            pC(I,J,bi,bj) = 1. _d 0
212            aC = -(            aC = -(
213       &     aW2d(I,J,bi,bj) + aW2d(I+1,J  ,bi,bj)       &     aW2d(I,J,bi,bj) + aW2d(I+1,J  ,bi,bj)
214       &    +aS2d(I,J,bi,bj) + aS2d(I  ,J+1,bi,bj)       &    +aS2d(I,J,bi,bj) + aS2d(I  ,J+1,bi,bj)
215       &    +freeSurfFac*myNorm*recip_Bo(I,J,bi,bj)*       &    +freeSurfFac*myNorm*recip_Bo(I,J,bi,bj)*deepFac2F(ks)
216       &     rA(I,J,bi,bj)/deltaTMom/deltaTMom       &                *rA(I,J,bi,bj)/deltaTMom/deltaTfreesurf
217       &    )       &    )
218            aCs = -(            aCs = -(
219       &     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)
220       &    +aS2d(I,J-1,bi,bj) + aS2d(I  ,J  ,bi,bj)       &    +aS2d(I,J-1,bi,bj) + aS2d(I  ,J  ,bi,bj)
221       &    +freeSurfFac*myNorm*recip_Bo(I,J-1,bi,bj)*       &    +freeSurfFac*myNorm*recip_Bo(I,J-1,bi,bj)*deepFac2F(ks)
222       &     rA(I,J-1,bi,bj)/deltaTMom/deltaTMom       &                *rA(I,J-1,bi,bj)/deltaTMom/deltaTfreesurf
223       &    )       &    )
224            aCw = -(            aCw = -(
225       &     aW2d(I-1,J,bi,bj) + aW2d(I  ,J  ,bi,bj)       &     aW2d(I-1,J,bi,bj) + aW2d(I  ,J  ,bi,bj)
226       &    +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)
227       &    +freeSurfFac*myNorm*recip_Bo(I-1,J,bi,bj)*       &    +freeSurfFac*myNorm*recip_Bo(I-1,J,bi,bj)*deepFac2F(ks)
228       &     rA(I-1,J,bi,bj)/deltaTMom/deltaTMom       &                *rA(I-1,J,bi,bj)/deltaTMom/deltaTfreesurf
229       &    )       &    )
230            IF ( aC .EQ. 0. ) THEN            IF ( aC .EQ. 0. ) THEN
231              pC(I,J,bi,bj) = 1. _d 0              pC(I,J,bi,bj) = 1. _d 0
# Line 244  C           defaults to 0.51 but can be Line 235  C           defaults to 0.51 but can be
235            IF ( aC + aCw .EQ. 0. ) THEN            IF ( aC + aCw .EQ. 0. ) THEN
236             pW(I,J,bi,bj) = 0.             pW(I,J,bi,bj) = 0.
237            ELSE            ELSE
238             pW(I,J,bi,bj) =             pW(I,J,bi,bj) =
239       &     -aW2d(I  ,J  ,bi,bj)/((cg2dpcOffDFac *(aCw+aC))**2 )       &     -aW2d(I  ,J  ,bi,bj)/((cg2dpcOffDFac *(aCw+aC))**2 )
240            ENDIF            ENDIF
241            IF ( aC + aCs .EQ. 0. ) THEN            IF ( aC + aCs .EQ. 0. ) THEN
# Line 253  C           defaults to 0.51 but can be Line 244  C           defaults to 0.51 but can be
244             pS(I,J,bi,bj) =             pS(I,J,bi,bj) =
245       &     -aS2d(I  ,J  ,bi,bj)/((cg2dpcOffDFac *(aCs+aC))**2 )       &     -aS2d(I  ,J  ,bi,bj)/((cg2dpcOffDFac *(aCs+aC))**2 )
246            ENDIF            ENDIF
247    C-    store solver main diagonal :
248              aC2d(I,J,bi,bj) = aC
249  C         pC(I,J,bi,bj) = 1.  C         pC(I,J,bi,bj) = 1.
250  C         pW(I,J,bi,bj) = 0.  C         pW(I,J,bi,bj) = 0.
251  C         pS(I,J,bi,bj) = 0.  C         pS(I,J,bi,bj) = 0.
# Line 261  C         pS(I,J,bi,bj) = 0. Line 254  C         pS(I,J,bi,bj) = 0.
254         ENDDO         ENDDO
255        ENDDO        ENDDO
256  C--   Update overlap regions  C--   Update overlap regions
257        _EXCH_XY_R4(pC, myThid)        _EXCH_XY_RS(pC, myThid)
258  c     _EXCH_XY_R4(pW, myThid)  c     _EXCH_XY_RS(pW, myThid)
259  c     _EXCH_XY_R4(pS, myThid)  c     _EXCH_XY_RS(pS, myThid)
260        CALL EXCH_UV_XY_RS(pW,pS,.FALSE.,myThid)        CALL EXCH_UV_XY_RS(pW,pS,.FALSE.,myThid)
261  CcnhDebugStarts  CcnhDebugStarts
262  C     CALL PLOT_FIELD_XYRS( pC, 'pC   INI_CG2D.2' , 1, myThid )  C     CALL PLOT_FIELD_XYRS( pC, 'pC   INI_CG2D.2' , 1, myThid )

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.46

  ViewVC Help
Powered by ViewVC 1.1.22