!======================================================================= ! RCS Header: ! Revision [$Revision: 1.7.2.1 $] Named [$Name: release#2_9_b5 $] ! Last checkin [$Date: 2001/12/06 10:13:53 $] ! Author [$Author: frpb $] !======================================================================= ! *****************************COPYRIGHT******************************* ! (c) CROWN COPYRIGHT 2001, Met Office, All Rights Reserved. ! Please refer to Copyright file in top level GCOM directory ! for further details ! *****************************COPYRIGHT******************************* #include "gc_prolog.h" SUBROUTINE GC_BRECV (MSG, LEN, SEND, ISTAT, RARR, SARR) ! ****************************************************************** ! * Purpose: ! * ! * Receive a byte array from processor SEND. ! * ! * Input: ! * MSG - message tag ! * LEN - number of BYTES in message ! * SEND - sender of the message (SEND = GC_ANY means any ! * processor) ! * SARR - name of the array on the sending processor ! * (SHM_SRC only) ! * ! * Output: ! * RARR - array to be received ! * ISTAT - status of send 0 is OK (MPI_SRC only), ! * refer to the header files for nonzero status codes ! * ! * NOTES: ! * The use of ISTAT as an input argument is obsoleted. Use ! * GC_SETOPT(). ! * ! ****************************************************************** IMPLICIT NONE INTEGER MSG, LEN, SEND, ISTAT, $ RARR(LEN/GC__ISIZE+1), SARR(LEN/GC__ISIZE+1) #if defined(SHM_SRC) INTEGER LLEN #include "gc__opts_common.h" INCLUDE 'mpp/shmem.fh' INTEGER ME, GC_ME, SHMEM_SWAP, INFO REAL LARR(LEN) POINTER(PTR,LARR) #include "gc__nam_flags_common.h" #endif #if defined(MPI_SRC) INCLUDE 'mpif.h' INTEGER STATUS(MPI_STATUS_SIZE) INTEGER LLEN,GC_ME,ME,I #endif #if defined(SHM_SRC) LLEN = LEN/GC__ISIZE IF (MOD(LEN, GC__ISIZE) .NE. 0) LLEN = LLEN + 1 ME = GC_ME() CALL GC__GET_SWAP_LOCATION(NAM_FLAG, ME, ME, SEND, PTR, 1) !DIR$ SUPPRESS NAM_FLAG INFO = SHMEM_SWAP(NAM_FLAG(SEND), 0, ME) IF (INFO .NE. SHMEM_SYNC_VALUE) & CALL GC__LOST_LOCK(ME, SEND, INFO) CALL SHMEM_GET(RARR, LARR, LLEN, SEND) #endif #if defined(MPI_SRC) ME=GC_ME() IF (SEND .EQ. ME) THEN ! Receiving from myself LLEN=LEN/GC__ISIZE IF (MOD(LEN, GC__ISIZE) .NE. 0) LLEN = LLEN + 1 DO I=1,LLEN RARR(I)=SARR(I) ENDDO ELSE ! Receiving from another processor IF (SEND .EQ. GC__ANY) THEN CALL MPI_RECV(RARR, LEN, MPI_BYTE, MPI_ANY_SOURCE, MSG, $ MPI_COMM_WORLD, STATUS, ISTAT) ELSE CALL MPI_RECV(RARR, LEN, MPI_BYTE, SEND, MSG, $ MPI_COMM_WORLD,STATUS, ISTAT) ENDIF ENDIF ! IF (SEND .EQ. ME) #endif #if defined(SHM_SRC) || defined(SERIAL_SRC) ISTAT = GC__OK #endif RETURN END