Back to home page

MITgcm

 
 

    


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

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
574e21b197 Jean*0001 #include "CPP_EEOPTIONS.h"
463a0fddee Patr*0002 
                0003       SUBROUTINE SCATTER_YZ( global, local, myThid )
                0004 C     Scatter elements of a y-z array from mpi process 0 to all processes.
                0005       IMPLICIT NONE
                0006 #include "SIZE.h"
                0007 #include "EEPARAMS.h"
                0008 #include "EESUPPORT.h"
                0009 C     mythid - thread number for this instance of the routine.
                0010 C     global,local - working arrays used to transfer 2-D fields
574e21b197 Jean*0011       INTEGER mythid
463a0fddee Patr*0012       Real*8  global(Ny)
                0013       _RL     local(1-OLy:sNy+OLy,nSx,nSy)
                0014 
                0015       INTEGER jG, j, bi, bj
                0016 #ifdef ALLOW_USE_MPI
                0017 
                0018       _RL     temp(1-OLy:sNy+OLy,nSx,nSy)
                0019 
                0020       INTEGER istatus(MPI_STATUS_SIZE), ierr
                0021       INTEGER isource, itag, npe
                0022       INTEGER lbuff
                0023 #endif /* ALLOW_USE_MPI */
                0024 
                0025 C--   Make everyone wait except for master thread.
                0026       _BARRIER
                0027       _BEGIN_MASTER( myThid )
                0028 
                0029 #ifndef ALLOW_USE_MPI
                0030 
                0031       DO bj=1,nSy
                0032          DO bi=1,nSx
                0033                DO j=1,sNy
                0034                   jG = myYGlobalLo-1+(bi-1)*sNy+j
                0035                   local(j,bi,bj) = global(jG)
                0036                ENDDO
                0037          ENDDO
                0038       ENDDO
                0039 
                0040 #else /* ALLOW_USE_MPI */
                0041 
                0042       lbuff=(sNy+2*OLy)*nSx*nSy
                0043       isource = 0
                0044       itag = 0
                0045 
                0046       IF( mpiMyId .EQ. 0 ) THEN
                0047 
                0048 C--   Process 0 fills-in its local data
                0049          npe = 0
                0050          DO bj=1,nSy
                0051             DO bi=1,nSx
                0052                   DO j=1,sNy
                0053                      jG = mpi_myYGlobalLo(npe+1)-1+(bi-1)*sNy+j
                0054                      local(j,bi,bj) = global(jG)
                0055                   ENDDO
                0056             ENDDO
                0057          ENDDO
                0058 
                0059 C--   Process 0 sends local arrays to all other processes
                0060          DO npe = 1, numberOfProcs-1
                0061             DO bj=1,nSy
                0062                DO bi=1,nSx
                0063                      DO j=1,sNy
                0064                         jG = mpi_myYGlobalLo(npe+1)-1+(bi-1)*sNy+j
                0065                         temp(j,bi,bj) = global(jG)
                0066                      ENDDO
                0067                ENDDO
                0068             ENDDO
                0069             CALL MPI_SEND (temp, lbuff, MPI_DOUBLE_PRECISION,
                0070      &           npe, itag, MPI_COMM_MODEL, ierr)
                0071          ENDDO
                0072 
                0073       ELSE
                0074 
                0075 C--   All proceses except 0 receive local array from process 0
                0076          CALL MPI_RECV (local, lbuff, MPI_DOUBLE_PRECISION,
                0077      &        isource, itag, MPI_COMM_MODEL, istatus, ierr)
                0078 
                0079       ENDIF
                0080 
                0081 #endif /* ALLOW_USE_MPI */
                0082 
                0083       _END_MASTER( myThid )
                0084       _BARRIER
                0085 
                0086 C--   Fill in edges.
78abe72379 Jean*0087 CMM      _EXCH_XY_RL( local, myThid )
463a0fddee Patr*0088 
                0089       RETURN
                0090       END