Back to home page

MITgcm

 
 

    


Warning, /eesupp/src/scatter_2d_wh_rx.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
d7fbd5d0c9 Gael*0001 #include "PACKAGES_CONFIG.h"
                0002 #include "CPP_EEOPTIONS.h"
                0003 
                0004 CBOP
                0005 C !ROUTINE: SCATTER_2D_WH_RX
                0006 C !INTERFACE:
                0007       SUBROUTINE SCATTER_2D_WH_RX(
                0008      I                  gloBuff,
                0009      O                  procBuff,
                0010      I                  myThid )
                0011 C !DESCRIPTION:
                0012 C     Scatter elements, including halos, of a global 2-D array from mpi process 0 to all processes.
                0013 C     Note: done by Master-Thread ; might need barrier calls before and after
                0014 C           this S/R call.
                0015 
                0016 C     !USES:
                0017       IMPLICIT NONE
                0018 #include "SIZE.h"
                0019 #include "EEPARAMS.h"
                0020 #include "EESUPPORT.h"
                0021 
                0022 C     !INPUT/OUTPUT PARAMETERS:
                0023 C gloBuff   ( _RX ) :: full-domain 2D IO-buffer array             (Input)
                0024 C procBuff  ( _RX ) :: proc-domain 2D IO-buffer array             (Input)
                0025 C myThid   (integer):: my Thread Id number
                0026 
                0027 C     sNxWh :: x tile size with halo included
                0028 C     sNyWh :: y tile size with halo included
                0029 C     pocNyWh :: processor sum of sNyWh
                0030 C     gloNyWh :: global sum of sNyWh
                0031       INTEGER sNxWh
                0032       INTEGER sNyWh
                0033       INTEGER procNyWh
                0034       INTEGER gloNyWh
                0035       PARAMETER ( sNxWh = sNx+2*Olx )
                0036       PARAMETER ( sNyWh = sNy+2*Oly )
                0037       PARAMETER ( procNyWh = sNyWh*nSy*nSx )
                0038       PARAMETER ( gloNyWh = procNyWh*nPy*nPx )
                0039 
                0040       _RX     gloBuff(sNxWh,gloNyWh)
                0041       _RX     procBuff(sNxWh,procNyWh)
                0042       INTEGER myThid
                0043 CEOP
                0044 
                0045 C !LOCAL VARIABLES:
                0046       INTEGER i,j
                0047 #ifdef ALLOW_USE_MPI
                0048       INTEGER jj, np0, np
                0049       _RX     temp(sNxWh,gloNyWh)
                0050       INTEGER istatus(MPI_STATUS_SIZE), ierr
                0051       INTEGER lbuff, isource, itag
                0052 #endif /* ALLOW_USE_MPI */
                0053 
                0054       _BEGIN_MASTER( myThid )
                0055 
                0056 #ifdef ALLOW_USE_MPI
                0057 
                0058       lbuff = sNxWh*procNyWh
                0059       isource = 0
                0060       itag  = 0
                0061 
                0062       IF( mpiMyId .EQ. 0 ) THEN
                0063 
                0064 C--   Process 0 sends local arrays to all other processes
                0065         DO np = 2, numberOfProcs
                0066          np0 = np - 1
                0067 
                0068 C--   Process 0 extract the local arrays from the global buffer.
                0069          DO j=1,procNyWh
                0070           DO i=1,sNxWh
                0071            jj=j+procNyWh*(np-1)
                0072            temp(i,j) = gloBuff(i,jj)
                0073           ENDDO
                0074          ENDDO
                0075 
                0076 C--   Process 0 sends local arrays to all other processes
                0077          CALL MPI_SEND (temp, lbuff, _MPI_TYPE_RX,
                0078      &           np0, itag, MPI_COMM_MODEL, ierr)
                0079 
                0080 C-      end loop on np
                0081         ENDDO
                0082 
                0083       ELSE
                0084 
                0085 C--   All proceses except 0 receive local array from process 0
                0086          CALL MPI_RECV (procBuff, lbuff, _MPI_TYPE_RX,
                0087      &        isource, itag, MPI_COMM_MODEL, istatus, ierr)
                0088 
                0089       ENDIF
                0090 
                0091 #endif /* ALLOW_USE_MPI */
                0092 
                0093       IF( myProcId .EQ. 0 ) THEN
                0094 C--   Process 0 fills-in its local data
                0095 
                0096         DO j=1,procNyWh
                0097          DO i=1,sNxWh
                0098           procBuff(i,j) = gloBuff(i,j)
                0099          ENDDO
                0100         ENDDO
                0101 
                0102 c        DO j=1,gloNyWh
                0103 c          DO i=1,sNxWh
                0104 c            gloBuff(i,j) = 0.
                0105 c          ENDDO
                0106 c        ENDDO
                0107 
                0108 C-    end if myProcId = 0
                0109       ENDIF
                0110 
                0111       _END_MASTER( myThid )
                0112 
                0113       RETURN
                0114       END
                0115 
                0116 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|