Back to home page

MITgcm

 
 

    


Warning, /pkg/exch2/exch2_get_rx1.template is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
ed81d0a43c Jean*0001 #include "CPP_EEOPTIONS.h"
                0002 #include "W2_OPTIONS.h"
                0003 
                0004 CBOP 0
                0005 C !ROUTINE: EXCH2_GET_RX1
                0006 
                0007 C !INTERFACE:
                0008       SUBROUTINE EXCH2_GET_RX1(
                0009      I       tIlo, tIhi, tiStride,
                0010      I       tJlo, tJhi, tjStride,
                0011      I       tKlo, tKhi, tkStride,
                0012      I       thisTile, nN, bi, bj,
                0013      I       e2BufrRecSize, sizeNb, sizeBi, sizeBj,
                0014      I       e2Bufr1_RX,
                0015      U       array,
                0016      I       i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
                0017      U       e2_msgHandles,
                0018      I       commSetting, myThid )
                0019 
                0020 C !DESCRIPTION:
                0021 C     Scalar field (1 component) Exchange:
                0022 C     Get from buffer exchanged data to fill in this tile-egde overlap region.
                0023 
                0024 C !USES:
                0025       IMPLICIT NONE
                0026 
                0027 #include "SIZE.h"
                0028 #include "EEPARAMS.h"
                0029 #include "W2_EXCH2_SIZE.h"
                0030 #include "W2_EXCH2_TOPOLOGY.h"
                0031 
                0032 C !INPUT/OUTPUT PARAMETERS:
                0033 C     === Routine arguments ===
                0034 C     tIlo,tIhi     :: index range in I that will be filled in target "array"
                0035 C     tIstride      :: index step  in I that will be filled in target "array"
                0036 C     tJlo,tJhi     :: index range in J that will be filled in target "array"
                0037 C     tJstride      :: index step  in J that will be filled in target "array"
                0038 C     tKlo,tKhi     :: index range in K that will be filled in target "array"
                0039 C     tKstride      :: index step  in K that will be filled in target "array"
d6ea3164dc Jean*0040 C     thisTile      :: receiving tile Id. number
ed81d0a43c Jean*0041 C     bi,bj         :: Indices of the receiving tile within this process
                0042 C                   ::  (used to select buffer slots that are allowed).
                0043 C     nN            :: Neighbour entry that we are processing
                0044 C     e2BufrRecSize :: Number of elements in each entry of e2Bufr1_RX
                0045 C     sizeNb        :: Second dimension of e2Bufr1_RX
                0046 C     sizeBi        :: Third  dimension of e2Bufr1_RX
                0047 C     sizeBj        :: Fourth dimension of e2Bufr1_RX
                0048 C     e2Bufr1_RX    :: Data transport buffer array. This array is used in one of
                0049 C                   :: two ways. For PUT communication the entry in the buffer
                0050 C                   :: associated with the source for this receive (determined
                0051 C                   :: from the opposing_send index) is read.
                0052 C                   :: For MSG communication the entry in the buffer associated
                0053 C                   :: with this neighbor of this tile is used as a receive
                0054 C                   :: location for loading a linear stream of bytes.
                0055 C     array         :: Target array that this receive writes to.
                0056 C     i1Lo, i1Hi    :: I coordinate bounds of target array
                0057 C     j1Lo, j1Hi    :: J coordinate bounds of target array
                0058 C     k1Lo, k1Hi    :: K coordinate bounds of target array
                0059 C     e2_msgHandles :: Synchronization and coordination data structure used to
                0060 C                   :: coordinate access to e2Bufr1_RX or to regulate message
                0061 C                   :: buffering. In PUT communication sender will increment
                0062 C                   :: handle entry once data is ready in buffer. Receiver will
                0063 C                   :: decrement handle once data is consumed from buffer.
d6ea3164dc Jean*0064 C                   :: For MPI MSG communication MPI_Wait uses handle to check
ed81d0a43c Jean*0065 C                   :: Isend has cleared. This is done in routine after receives.
                0066 C     commSetting   :: Mode of communication used to exchange with this neighbor
                0067 C     myThid        :: my Thread Id. number
                0068 
                0069       INTEGER tILo, tIHi, tiStride
                0070       INTEGER tJLo, tJHi, tjStride
                0071       INTEGER tKLo, tKHi, tkStride
                0072       INTEGER i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi
                0073       INTEGER thisTile, nN, bi, bj
                0074       INTEGER e2BufrRecSize, sizeNb, sizeBi, sizeBj
                0075       _RX     e2Bufr1_RX( e2BufrRecSize, sizeNb, sizeBi, sizeBj, 2 )
                0076       _RX     array(i1Lo:i1Hi,j1Lo:j1Hi,k1Lo:k1Hi)
                0077       INTEGER e2_msgHandles( 2, sizeNb, sizeBi, sizeBj )
                0078       CHARACTER commSetting
                0079       INTEGER myThid
                0080 CEOP
                0081 
                0082 C !LOCAL VARIABLES:
                0083 C     == Local variables ==
                0084 C     itl,jtl,ktl :: Loop counters (this tile)
                0085 C     soT    :: Source tile Id number
                0086 C     oNb    :: Opposing send record number
                0087 C     iBufr  :: Buffer counter
d6ea3164dc Jean*0088 C     sNb    :: buffer (source) Neighbour index to get data from
ed81d0a43c Jean*0089 C     sBi    :: buffer (source) Tile  index (for this Proc) to get data from
                0090 C     sBj    :: buffer (source) Tile  index (for this Proc) to get data from
                0091 C     sLv    :: buffer (source) level index to get data from
                0092 C     i,j    :: Loop counters
                0093       INTEGER itl, jtl, ktl
                0094       INTEGER soT
                0095       INTEGER oNb
                0096       INTEGER iBufr
                0097       INTEGER sNb, sBi, sBj, sLv
                0098 c     CHARACTER*(MAX_LEN_MBUF) msgBuf
                0099 
                0100       soT = exch2_neighbourId( nN, thisTile )
                0101       oNb = exch2_opposingSend(nN, thisTile )
                0102 
                0103 C     Handle receive end data transport according to communication mechanism
                0104 C     between source and target tile
                0105       IF     ( commSetting .EQ. 'P' ) THEN
                0106 C      1 Need to check and spin on data ready assertion for multithreaded mode,
                0107 C        for now, ensure global sync using barrier.
                0108 C      2 get directly data from 1rst level buffer (sLv=1);
                0109 
                0110 C     find the tile indices (local to this Proc) corresponding to
170d15a4c7 Jean*0111 C      this source tile Id "soT" (note: this is saved in W2_tileIndex array)
ed81d0a43c Jean*0112        sLv = 1
                0113        sNb = oNb
170d15a4c7 Jean*0114        sBi = W2_tileIndex(soT)
                0115        sBj = 1 + (sBi-1)/sizeBi
                0116        sBi = 1 + MOD(sBi-1,sizeBi)
ed81d0a43c Jean*0117 #ifdef ALLOW_USE_MPI
                0118       ELSEIF ( commSetting .EQ. 'M' ) THEN
                0119        sLv = 2
                0120        sBi = bi
                0121        sBj = bj
                0122        sNb = nN
                0123 #endif /* ALLOW_USE_MPI */
                0124       ELSE
                0125        STOP 'EXCH2_GET_RX1:: commSetting VALUE IS INVALID'
                0126       ENDIF
                0127 
                0128       iBufr = 0
                0129       DO ktl=tKlo,tKhi,tKStride
                0130        DO jtl=tJLo, tJHi, tjStride
                0131         DO itl=tILo, tIHi, tiStride
                0132 C     Read from e2Bufr1_RX(iBufr,sNb,sBi,sBj,sLv)
                0133          iBufr = iBufr+1
                0134          array(itl,jtl,ktl) = e2Bufr1_RX(iBufr,sNb,sBi,sBj,sLv)
                0135         ENDDO
                0136        ENDDO
                0137       ENDDO
                0138 
                0139       RETURN
                0140       END
                0141 
                0142 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0143 
                0144 CEH3 ;;; Local Variables: ***
                0145 CEH3 ;;; mode:fortran ***
                0146 CEH3 ;;; End: ***