Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:39:43 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
11942f961e Jean*0001 #include "CPP_EEOPTIONS.h"
                0002 
                0003 CBOP 0
                0004 C !ROUTINE: EXCH2_GET_SCAL_BOUNDS
                0005 
                0006 C !INTERFACE:
                0007       SUBROUTINE EXCH2_GET_SCAL_BOUNDS(
                0008      I                 fCode, eWdth, updateCorners,
                0009      I                 tgTile, tgNb,
                0010      O                 tIlo, tIhi, tJlo, tJhi,
                0011      O                 tiStride, tjStride,
                0012      I                 myThid )
                0013 
                0014 C !DESCRIPTION:
                0015 C     Return the index range & step of the part of the array (overlap-region)
                0016 C     which is going to be updated by the exchange with 1 neighbour.
                0017 C     Scalar field version (as opposed to 2-components vector field).
                0018 C     Note: presently only coded for grid-centered (mass point) scalar.
                0019 C           needs to extend it to grid-corner (vorticity point) scalar.
                0020 
                0021 C !USES:
                0022       IMPLICIT NONE
                0023 
                0024 #include "SIZE.h"
                0025 #include "W2_EXCH2_SIZE.h"
                0026 #include "W2_EXCH2_TOPOLOGY.h"
                0027 
                0028 C !INPUT/OUTPUT PARAMETERS:
                0029 C     fCode         :: field code (position on staggered grid)
                0030 C     eWdth         :: width of data region to exchange
                0031 C     updateCorners :: flag, do update corner halo region if true
                0032 C     tgTile        :: target tile
                0033 C     tgNb          :: target Neighbour entry
                0034 C     tIlo, tIhi    :: index range in I that will be filled in target array
                0035 C     tJlo, tJhi    :: index range in J that will be filled in target array
                0036 C     tiStride      :: index step  in I that will be filled in target array
                0037 C     tjStride      :: index step  in J that will be filled in target array
                0038 C     myThid        :: my Thread Id. number
                0039 
                0040       CHARACTER*2 fCode
                0041       INTEGER     eWdth
                0042       LOGICAL     updateCorners
                0043       INTEGER     tgTile, tgNb
                0044       INTEGER     tIlo, tIhi, tJlo, tJhi
                0045       INTEGER     tiStride, tjStride
                0046       INTEGER     myThid
                0047 
                0048 C !LOCAL VARIABLES:
                0049 CEOP
                0050 
                0051 C---  Initialise index range from Topology values:
                0052       tIlo = exch2_iLo(tgNb,tgTile)
                0053       tIhi = exch2_iHi(tgNb,tgTile)
                0054       tJlo = exch2_jLo(tgNb,tgTile)
                0055       tJhi = exch2_jHi(tgNb,tgTile)
                0056 
                0057 C---  Expand index range according to exchange-Width "eWdth"
                0058       IF ( tIlo .EQ. tIhi .AND. tIlo .EQ. 0 ) THEN
                0059 C      Filling a west edge overlap
                0060        tIlo = 1-eWdth
                0061        tiStride = 1
                0062        IF ( tJlo .LE. tJhi ) THEN
                0063         tjStride = 1
                0064        ELSE
                0065         tjStride =-1
                0066        ENDIF
                0067        IF ( updateCorners ) THEN
                0068         tJlo = tJlo-tjStride*(eWdth-1)
                0069         tJhi = tJhi+tjStride*(eWdth-1)
                0070        ELSE
                0071         tJlo = tJlo+tjStride
                0072         tJhi = tJhi-tjStride
                0073        ENDIF
                0074       ENDIF
                0075       IF ( tIlo .EQ. tIhi .AND. tIlo .GT. 1 ) THEN
                0076 C      Filling an east edge overlap
                0077        tIhi = tIhi+eWdth-1
                0078        tiStride = 1
                0079        IF ( tJlo .LE. tJhi ) THEN
                0080         tjStride = 1
                0081        ELSE
                0082         tjStride =-1
                0083        ENDIF
                0084        IF ( updateCorners ) THEN
                0085         tJlo = tJlo-tjStride*(eWdth-1)
                0086         tJhi = tJhi+tjStride*(eWdth-1)
                0087        ELSE
                0088         tJlo = tJlo+tjStride
                0089         tJhi = tJhi-tjStride
                0090        ENDIF
                0091       ENDIF
                0092       IF ( tJlo .EQ. tJhi .AND. tJlo .EQ. 0 ) THEN
                0093 C      Filling a south edge overlap
                0094        tJlo = 1-eWdth
                0095        tjStride = 1
                0096        IF ( tIlo .LE. tIhi ) THEN
                0097         tiStride = 1
                0098        ELSE
                0099         tiStride =-1
                0100        ENDIF
                0101        IF ( updateCorners ) THEN
                0102         tIlo = tIlo-tiStride*(eWdth-1)
                0103         tIhi = tIhi+tiStride*(eWdth-1)
                0104        ELSE
                0105         tIlo = tIlo+tiStride
                0106         tIhi = tIhi-tiStride
                0107        ENDIF
                0108       ENDIF
                0109       IF ( tJlo .EQ. tJhi .AND. tJlo .GT. 1 ) THEN
                0110 C      Filling a north edge overlap
                0111        tJhi = tJhi+eWdth-1
                0112        tjStride = 1
                0113        IF ( tIlo .LE. tIhi ) THEN
                0114         tiStride = 1
                0115        ELSE
                0116         tiStride =-1
                0117        ENDIF
                0118        IF ( updateCorners ) THEN
                0119         tIlo = tIlo-tiStride*(eWdth-1)
                0120         tIhi = tIhi+tiStride*(eWdth-1)
                0121        ELSE
                0122         tIlo = tIlo+tiStride
                0123         tIhi = tIhi-tiStride
                0124        ENDIF
                0125       ENDIF
                0126 
                0127       RETURN
                0128       END