** Warning **

Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle dbname=MITgcm at /usr/local/share/lxr/lib/LXR/Common.pm line 1224.

Last-Modified: Wed, 10 Sep 2024 05:11:47 GMT Content-Type: text/html; charset=utf-8 MITgcm/MITgcm/pkg/generic_advdiff/gad_som_prep_cs_corner.F
Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:41:10 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
b79a2b44f2 Jean*0001 #include "GAD_OPTIONS.h"
                0002 
                0003 CBOP
                0004 C     !ROUTINE: GAD_SOM_PREP_CS_CORNER
                0005 C     !INTERFACE:
                0006       SUBROUTINE GAD_SOM_PREP_CS_CORNER(
                0007      U           smVol, smTr0, smTr, smCorners,
                0008      I           prep4dirX, overlapOnly, interiorOnly,
                0009      I           N_edge, S_edge, E_edge, W_edge,
                0010      I           iPass, k, myNz, bi, bj, myThid )
                0011 
                0012 
                0013 C     !DESCRIPTION: \bv
                0014 C     *==========================================================*
                0015 C     | SUBROUTINE GAD_SOM_PREP_CS_CORNER
                0016 C     | o Prepare for Horizontal SOM Advection :
                0017 C     |   when using Cubed-Sphere Grid, fill corner-halo regions
                0018 C     |   of all Tracer-moments with proper values
                0019 C     *==========================================================*
                0020 C     \ev
                0021 C     !USES:
                0022       IMPLICIT NONE
                0023 
                0024 C     === Global variables ===
                0025 #include "SIZE.h"
                0026 #include "EEPARAMS.h"
                0027 #include "GAD.h"
                0028 
                0029 C     !INPUT/OUTPUT PARAMETERS:
                0030 C     === Routine arguments ===
                0031 C     smVol      :: grid-cell volume
                0032 C     smTr0      :: tracer Zero Order moment
                0033 C     smTr       :: tracer 1rst & 2nd Order moments
                0034 C     smCorners  :: Temporary storage of Corner-halo-regions values
                0035 C                   ( 3rd dim = Number of corners = 4 : SW, SE, NE, NW )
                0036 C     prep4dirX  :: True = prepare for X direction advection
                0037 C                   otherwise, prepare for Y direction advection.
                0038 C  overlapOnly   :: only update the edges of myTile, but not the interior
                0039 C  interiorOnly  :: only update the interior of myTile, but not the edges
                0040 C [N,S,E,W]_edge :: true if N,S,E,W edge of myTile is an Edge of the cube
                0041 C     iPass      :: current passage index in SOM_ADVECT
                0042 C     k          :: current level index
                0043 C     myNz       :: 3rd dimension of array to exchange
                0044 C     bi,bj      :: current tile indices
                0045 C     myThid     :: my Thread Id number
                0046       INTEGER myNz
                0047       _RL     smVol(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz)
                0048       _RL     smTr0(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz)
                0049       _RL     smTr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz,nSx,nSy,nSOM)
                0050       _RL     smCorners(OLx,OLy,4,-1:nSOM)
                0051       LOGICAL prep4dirX, overlapOnly, interiorOnly
                0052       LOGICAL N_edge, S_edge, E_edge, W_edge
                0053       INTEGER iPass, k, bi, bj
                0054       INTEGER myThid
                0055 CEOP
                0056 
                0057 C     !LOCAL VARIABLES:
                0058 C     === Local variables ===
                0059       INTEGER i,j, jPass, n
                0060       LOGICAL southWestCorner
                0061       LOGICAL southEastCorner
                0062       LOGICAL northEastCorner
                0063       LOGICAL northWestCorner
                0064 
                0065       southWestCorner = S_edge .AND. W_edge
                0066       southEastCorner = S_edge .AND. E_edge
                0067       northEastCorner = N_edge .AND. E_edge
                0068       northWestCorner = N_edge .AND. W_edge
                0069 
                0070       IF ( overlapOnly ) THEN
                0071 C--   to avoid repeating 2 times the full sequence of FILL_CS_CORNER calls,
                0072 C     add a loop on jPass (from iPass to 2) to reproduce the following logic:
                0073 C     1 ) overlapOnly & iPass = 1  (face 3 & 6)
                0074 C         - fill corners for the other direction
                0075 C         - then store the corner values
                0076 C     2 ) IF overlapOnly           :: fill corners for the current direction
                0077 C         ELSEIF .NOT.interiorOnly :: get the corner values back from storage
                0078 C         ENDIF
                0079        DO jPass = iPass,2
                0080 
                0081         IF ( ( jPass.EQ.2 .AND. prep4dirX ) .OR.
                0082      &       ( jPass.EQ.1 .AND. .NOT.prep4dirX ) ) THEN
                0083 C--   Fill corners to prepare for calculations in X
                0084           CALL GAD_SOM_FILL_CS_CORNER( .TRUE.,
                0085      U                                 smVol(1-OLx,1-OLy,k),
                0086      U                                 smTr0(1-OLx,1-OLy,k),
                0087      U                                 smTr(1-OLx,1-OLy,k,bi,bj,1),
                0088      U                                 smTr(1-OLx,1-OLy,k,bi,bj,2),
                0089      U                                 smTr(1-OLx,1-OLy,k,bi,bj,3),
                0090      U                                 smTr(1-OLx,1-OLy,k,bi,bj,4),
                0091      U                                 smTr(1-OLx,1-OLy,k,bi,bj,5),
                0092      U                                 smTr(1-OLx,1-OLy,k,bi,bj,6),
                0093      U                                 smTr(1-OLx,1-OLy,k,bi,bj,7),
                0094      U                                 smTr(1-OLx,1-OLy,k,bi,bj,8),
                0095      U                                 smTr(1-OLx,1-OLy,k,bi,bj,9),
                0096      I                                 bi, bj, myThid )
                0097 C--   End of filling for X dir
                0098 c       ENDIF
                0099 
                0100         ELSE
                0101 C Note: the 2 IF tests are equivalent to just 1 if/else test;
                0102 C       use this later option and leave the former commented.
                0103 
                0104 c       IF ( ( jPass.EQ.1 .AND. prep4dirX ) .OR.
                0105 c    &       ( jPass.EQ.2 .AND. .NOT.prep4dirX ) ) THEN
                0106 C--   Fill corners to prepare for calculations in Y
                0107           CALL GAD_SOM_FILL_CS_CORNER( .FALSE.,
                0108      U                                 smVol(1-OLx,1-OLy,k),
                0109      U                                 smTr0(1-OLx,1-OLy,k),
                0110      U                                 smTr(1-OLx,1-OLy,k,bi,bj,1),
                0111      U                                 smTr(1-OLx,1-OLy,k,bi,bj,2),
                0112      U                                 smTr(1-OLx,1-OLy,k,bi,bj,3),
                0113      U                                 smTr(1-OLx,1-OLy,k,bi,bj,4),
                0114      U                                 smTr(1-OLx,1-OLy,k,bi,bj,5),
                0115      U                                 smTr(1-OLx,1-OLy,k,bi,bj,6),
                0116      U                                 smTr(1-OLx,1-OLy,k,bi,bj,7),
                0117      U                                 smTr(1-OLx,1-OLy,k,bi,bj,8),
                0118      U                                 smTr(1-OLx,1-OLy,k,bi,bj,9),
                0119      I                                 bi, bj, myThid )
                0120 C--   End of filling for Y dir
                0121         ENDIF
                0122 
                0123         IF ( jPass.EQ.1 ) THEN
                0124 C--   Store corner values (to be used on the next iPass)
                0125          IF ( southWestCorner ) THEN
                0126           DO j=1,OLy
                0127            DO i=1,OLx
                0128             smCorners(i,j,1,-1) = smVol(i-OLx,j-OLy,k)
                0129             smCorners(i,j,1, 0) = smTr0(i-OLx,j-OLy,k)
                0130             DO n=1,nSOM
                0131              smCorners(i,j,1,n) = smTr (i-OLx,j-OLy,k,bi,bj,n)
                0132             ENDDO
                0133            ENDDO
                0134           ENDDO
                0135          ENDIF
                0136          IF ( southEastCorner ) THEN
                0137           DO j=1,OLy
                0138            DO i=1,OLx
                0139             smCorners(i,j,2,-1) = smVol(sNx+i,j-OLy,k)
                0140             smCorners(i,j,2, 0) = smTr0(sNx+i,j-OLy,k)
                0141             DO n=1,nSOM
                0142              smCorners(i,j,2,n) = smTr (sNx+i,j-OLy,k,bi,bj,n)
                0143             ENDDO
                0144            ENDDO
                0145           ENDDO
                0146          ENDIF
                0147          IF ( northEastCorner ) THEN
                0148           DO j=1,OLy
                0149            DO i=1,OLx
                0150             smCorners(i,j,3,-1) = smVol(sNx+i,sNy+j,k)
                0151             smCorners(i,j,3, 0) = smTr0(sNx+i,sNy+j,k)
                0152             DO n=1,nSOM
                0153              smCorners(i,j,3,n) = smTr (sNx+i,sNy+j,k,bi,bj,n)
                0154             ENDDO
                0155            ENDDO
                0156           ENDDO
                0157          ENDIF
                0158          IF ( northWestCorner ) THEN
                0159           DO j=1,OLy
                0160            DO i=1,OLx
                0161             smCorners(i,j,4,-1) = smVol(i-OLx,sNy+j,k)
                0162             smCorners(i,j,4, 0) = smTr0(i-OLx,sNy+j,k)
                0163             DO n=1,nSOM
                0164              smCorners(i,j,4,n) = smTr (i-OLx,sNy+j,k,bi,bj,n)
                0165             ENDDO
                0166            ENDDO
                0167           ENDDO
                0168          ENDIF
                0169 C--   End storing block
                0170         ENDIF
                0171 
                0172 C--   End of loop on jPass
                0173        ENDDO
                0174 
                0175       ELSEIF ( .NOT.interiorOnly ) THEN
                0176 
                0177 C--   Get back corner values from storage
                0178         IF ( southWestCorner ) THEN
                0179           DO j=1,OLy
                0180            DO i=1,OLx
                0181             smVol(i-OLx,j-OLy,k )        = smCorners(i,j,1,-1)
                0182             smTr0(i-OLx,j-OLy,k )        = smCorners(i,j,1, 0)
                0183             DO n=1,nSOM
                0184              smTr(i-OLx,j-OLy,k,bi,bj,n) = smCorners(i,j,1, n)
                0185             ENDDO
                0186            ENDDO
                0187           ENDDO
                0188         ENDIF
                0189         IF ( southEastCorner ) THEN
                0190           DO j=1,OLy
                0191            DO i=1,OLx
                0192             smVol(sNx+i,j-OLy,k )        = smCorners(i,j,2,-1)
                0193             smTr0(sNx+i,j-OLy,k )        = smCorners(i,j,2, 0)
                0194             DO n=1,nSOM
                0195              smTr(sNx+i,j-OLy,k,bi,bj,n) = smCorners(i,j,2, n)
                0196             ENDDO
                0197            ENDDO
                0198           ENDDO
                0199         ENDIF
                0200         IF ( northEastCorner ) THEN
                0201           DO j=1,OLy
                0202            DO i=1,OLx
                0203             smVol(sNx+i,sNy+j,k )        = smCorners(i,j,3,-1)
                0204             smTr0(sNx+i,sNy+j,k )        = smCorners(i,j,3, 0)
                0205             DO n=1,nSOM
                0206              smTr(sNx+i,sNy+j,k,bi,bj,n) = smCorners(i,j,3, n)
                0207             ENDDO
                0208            ENDDO
                0209           ENDDO
                0210         ENDIF
                0211         IF ( northWestCorner ) THEN
                0212           DO j=1,OLy
                0213            DO i=1,OLx
                0214             smVol(i-OLx,sNy+j,k )        = smCorners(i,j,4,-1)
                0215             smTr0(i-OLx,sNy+j,k )        = smCorners(i,j,4, 0)
                0216             DO n=1,nSOM
                0217              smTr(i-OLx,sNy+j,k,bi,bj,n) = smCorners(i,j,4, n)
                0218             ENDDO
                0219            ENDDO
                0220           ENDDO
                0221         ENDIF
                0222 C--   End getting back corner values from storage
                0223 
                0224 C---  End if/else - overlapOnly - block
                0225       ENDIF
                0226 
                0227       RETURN
                0228       END