Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:36:08 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
449149bd7b Jean*0001 #include "PACKAGES_CONFIG.h"
                0002 #include "CPP_EEOPTIONS.h"
                0003 
                0004 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0005 CBOP
                0006 C     !ROUTINE: FILL_CS_CORNER_AG_RL
                0007 
                0008 C     !INTERFACE:
                0009       SUBROUTINE FILL_CS_CORNER_AG_RL(
                0010      I     fill4dirX, withSigns,
                0011      U     uFld, vFld,
                0012      I     bi,bj, myThid)
                0013 
                0014 C     !DESCRIPTION:
                0015 C     *==========================================================*
                0016 C     | SUBROUTINE FILL_CS_CORNER_AG_RL
                0017 C     | o Fill the corner-halo region of CS-grid,
                0018 C     |   for a 2 components vector field on A-grid (center of grid cell)
                0019 C     *==========================================================*
                0020 C     | o the corner halo region is filled with valid values
                0021 C     |   in order to compute (later on) gradient in X or Y
                0022 C     |   direction, on a wide stencil.
                0023 C     *==========================================================*
                0024 
                0025 C     !USES:
                0026       IMPLICIT NONE
                0027 
                0028 C     == Global variables ==
                0029 #include "SIZE.h"
                0030 #include "EEPARAMS.h"
                0031 #ifdef ALLOW_EXCH2
1cc6effca6 Jean*0032 #include "W2_EXCH2_SIZE.h"
449149bd7b Jean*0033 #include "W2_EXCH2_TOPOLOGY.h"
                0034 #endif /* ALLOW_EXCH2 */
                0035 
                0036 C     !INPUT/OUTPUT PARAMETERS:
                0037 C     == Routine arguments ==
                0038 C
                0039 C     fill4dirX :: True = prepare for X direction calculations
                0040 C                  otherwise, prepare for Y direction
                0041 C     withSigns :: True = account for sign of vector component
                0042 C     uFld      :: u-component of vector field array with empty corners to fill
                0043 C     vFld      :: v-component of vector field array with empty corners to fill
                0044 C     bi,bj     :: tile indices
                0045 C     myThid    :: thread number
                0046       LOGICAL fill4dirX
                0047       LOGICAL withSigns
                0048       _RL uFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0049       _RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0050       INTEGER bi,bj
                0051       INTEGER myThid
                0052 
                0053 C     !LOCAL VARIABLES:
                0054 C     == Local variables ==
                0055 C      i,j           :: loop indices
                0056 C      myTile        :: tile number
                0057       INTEGER i,j
                0058       LOGICAL southWestCorner
                0059       LOGICAL southEastCorner
                0060       LOGICAL northWestCorner
                0061       LOGICAL northEastCorner
                0062       _RL     negOne
                0063 #ifdef ALLOW_EXCH2
                0064       INTEGER myTile
                0065 #endif
                0066 CEOP
                0067 
                0068       negOne = 1.
                0069       IF (withSigns) negOne = -1.
                0070 
                0071       IF (useCubedSphereExchange) THEN
                0072 
                0073 #ifdef ALLOW_EXCH2
6e33c64afb Jean*0074        myTile = W2_myTileList(bi,bj)
449149bd7b Jean*0075        southWestCorner = exch2_isWedge(myTile).EQ.1
                0076      &             .AND. exch2_isSedge(myTile).EQ.1
                0077        southEastCorner = exch2_isEedge(myTile).EQ.1
                0078      &             .AND. exch2_isSedge(myTile).EQ.1
                0079        northEastCorner = exch2_isEedge(myTile).EQ.1
                0080      &             .AND. exch2_isNedge(myTile).EQ.1
                0081        northWestCorner = exch2_isWedge(myTile).EQ.1
                0082      &             .AND. exch2_isNedge(myTile).EQ.1
                0083 #else
                0084        southWestCorner = .TRUE.
                0085        southEastCorner = .TRUE.
                0086        northWestCorner = .TRUE.
                0087        northEastCorner = .TRUE.
                0088 #endif
                0089 
                0090        IF ( fill4dirX ) THEN
                0091 C--    Internal exchange for calculations in X
                0092 
                0093 C-     For cube face corners we need to duplicate the
                0094 C-     i-1 and i+1 values into the null space as follows:
                0095 C
                0096 C
                0097 C      o NW corner: copy T(    0,sNy  ) into T(    0,sNy+1) e.g.
                0098 C                      |
                0099 C         x T(0,sNy+1) |
                0100 C        /\            |
                0101 C      --||------------|-----------
                0102 C        ||            |
                0103 C         x T(0,sNy)   |   x T(1,sNy)
                0104 C                      |
                0105 C
                0106 C      o SW corner: copy T(0,1) into T(0,0) e.g.
                0107 C                      |
                0108 C         x T(0,1)     |  x T(1,1)
                0109 C        ||            |
                0110 C      --||------------|-----------
                0111 C        \/            |
                0112 C         x T(0,0)     |
                0113 C                      |
                0114 C
                0115 C      o NE corner: copy T(sNx+1,sNy  ) into T(sNx+1,sNy+1) e.g.
                0116 C                      |
                0117 C                      |   x T(sNx+1,sNy+1)
                0118 C                      |  /\
                0119 C      ----------------|--||-------
                0120 C                      |  ||
                0121 C         x T(sNx,sNy) |   x T(sNx+1,sNy  )
                0122 C                      |
                0123 C      o SE corner: copy T(sNx+1,1    ) into T(sNx+1,0    ) e.g.
                0124 C                      |
                0125 C         x T(sNx,1)   |   x T(sNx+1,    1)
                0126 C                      |  ||
                0127 C      ----------------|--||-------
                0128 C                      |  \/
                0129 C                      |   x T(sNx+1,    0)
                0130          IF ( southWestCorner ) THEN
                0131           DO j=1,OLy
                0132            DO i=1,OLx
                0133             uFld( 1-i , 1-j ) = vFld( 1-j , i  )*negOne
                0134             vFld( 1-i , 1-j ) = uFld( 1-j , i  )
                0135            ENDDO
                0136           ENDDO
                0137          ENDIF
                0138          IF ( southEastCorner ) THEN
                0139           DO j=1,OLy
                0140            DO i=1,OLx
                0141             uFld(sNx+i, 1-j ) = vFld(sNx+j, i  )
                0142             vFld(sNx+i, 1-j ) = uFld(sNx+j, i  )*negOne
                0143            ENDDO
                0144           ENDDO
                0145          ENDIF
                0146          IF ( northWestCorner ) THEN
                0147           DO j=1,OLy
                0148            DO i=1,OLx
                0149             uFld( 1-i ,sNy+j) = vFld( 1-j , sNy+1-i )
                0150             vFld( 1-i ,sNy+j) = uFld( 1-j , sNy+1-i )*negOne
                0151            ENDDO
                0152           ENDDO
                0153          ENDIF
                0154          IF ( northEastCorner ) THEN
                0155           DO j=1,OLy
                0156            DO i=1,OLx
                0157             uFld(sNx+i,sNy+j) = vFld(sNx+j, sNy+1-i )*negOne
                0158             vFld(sNx+i,sNy+j) = uFld(sNx+j, sNy+1-i )
                0159            ENDDO
                0160           ENDDO
                0161          ENDIF
                0162 
                0163 C--   End of X direction ; start Y direction case.
                0164 
                0165        ELSE
                0166 C--    Internal exchange for calculations in Y
                0167 
                0168 C-     For cube face corners we need to duplicate the
                0169 C-     j-1 and j+1 values into the null space as follows:
                0170 C
                0171 C      o SW corner: copy T(0,1) into T(0,0) e.g.
                0172 C                      |
                0173 C                      |  x T(1,1)
                0174 C                      |
                0175 C      ----------------|-----------
                0176 C                      |
                0177 C         x T(0,0)<====== x T(1,0)
                0178 C                      |
                0179 C
                0180 C      o NW corner: copy T(    0,sNy  ) into T(    0,sNy+1) e.g.
                0181 C                      |
                0182 C         x T(0,sNy+1)<=== x T(1,sNy+1)
                0183 C                      |
                0184 C      ----------------|-----------
                0185 C                      |
                0186 C                      |   x T(1,sNy)
                0187 C                      |
                0188 C
                0189 C      o NE corner: copy T(sNx+1,sNy  ) into T(sNx+1,sNy+1) e.g.
                0190 C                      |
                0191 C      x T(sNx,sNy+1)=====>x T(sNx+1,sNy+1)
                0192 C                      |
                0193 C      ----------------|-----------
                0194 C                      |
                0195 C      x T(sNx,sNy)    |
                0196 C                      |
                0197 C      o SE corner: copy T(sNx+1,1    ) into T(sNx+1,0    ) e.g.
                0198 C                      |
                0199 C         x T(sNx,1)   |
                0200 C                      |
                0201 C      ----------------|-----------
                0202 C                      |
                0203 C         x T(sNx,0) =====>x T(sNx+1,    0)
                0204          IF ( southWestCorner ) THEN
                0205           DO j=1,Oly
                0206            DO i=1,Olx
                0207             uFld( 1-i , 1-j ) = vFld(   j   , 1-i )
                0208             vFld( 1-i , 1-j ) = uFld(   j   , 1-i )*negOne
                0209            ENDDO
                0210           ENDDO
                0211          ENDIF
                0212          IF ( southEastCorner ) THEN
                0213           DO j=1,Oly
                0214            DO i=1,Olx
                0215             uFld(sNx+i, 1-j ) = vFld(sNx+1-j, 1-i )*negOne
                0216             vFld(sNx+i, 1-j ) = uFld(sNx+1-j, 1-i )
                0217            ENDDO
                0218           ENDDO
                0219          ENDIF
                0220          IF ( northWestCorner ) THEN
                0221           DO j=1,Oly
                0222            DO i=1,Olx
                0223             uFld( 1-i ,sNy+j) = vFld(   j   ,sNy+i)*negOne
                0224             vFld( 1-i ,sNy+j) = uFld(   j   ,sNy+i)
                0225            ENDDO
                0226           ENDDO
                0227          ENDIF
                0228          IF ( northEastCorner ) THEN
                0229           DO j=1,Oly
                0230            DO i=1,Olx
                0231             uFld(sNx+i,sNy+j) = vFld(sNx+1-j,sNy+i)
                0232             vFld(sNx+i,sNy+j) = uFld(sNx+1-j,sNy+i)*negOne
                0233            ENDDO
                0234           ENDDO
                0235          ENDIF
                0236 
                0237 C-     End of Y direction case.
                0238        ENDIF
                0239 
                0240 C--   End useCubedSphereExchange
                0241       ENDIF
                0242 
                0243       RETURN
                0244       END