mp_sendrecv_lv Subroutine

private subroutine mp_sendrecv_lv(msgin, dest, msgout, source, comm)

Sends and receives vector data

Arguments

Type IntentOptional Attributes Name
integer(kind=int_8), intent(in), CONTIGUOUS :: msgin(:)

Data to send

integer, intent(in) :: dest

Process to send data to

integer(kind=int_8), intent(out), CONTIGUOUS :: msgout(:)

Received data

integer, intent(in) :: source

Process from which to receive

type(mp_comm_type), intent(in) :: comm

Message passing environment identifier


Source Code

      SUBROUTINE mp_sendrecv_lv(msgin, dest, msgout, source, comm)
      !! Sends and receives vector data

         INTEGER(KIND=int_8), CONTIGUOUS, INTENT(IN)        :: msgin(:)
         !! Data to send
         INTEGER, INTENT(IN)                      :: dest
         !! Process to send data to
         INTEGER(KIND=int_8), CONTIGUOUS, INTENT(OUT)       :: msgout(:)
         !! Received data
         INTEGER, INTENT(IN)                      :: source
         !! Process from which to receive
         TYPE(mp_comm_type), INTENT(IN)           :: comm
         !! Message passing environment identifier

         CHARACTER(LEN=*), PARAMETER :: routineN = 'mp_sendrecv_lv'

         INTEGER                                  :: handle, ierr
#if defined(__parallel)
         INTEGER                                  :: msglen_in, msglen_out, &
                                                     recv_tag, send_tag
#endif

         ierr = 0
         CALL timeset(routineN, handle)

#if defined(__parallel)
         msglen_in = SIZE(msgin)
         msglen_out = SIZE(msgout)
         send_tag = 0 ! cannot think of something better here, this might be dangerous
         recv_tag = 0 ! cannot think of something better here, this might be dangerous
         CALL mpi_sendrecv(msgin, msglen_in, MPI_INTEGER8, dest, send_tag, msgout, &
                           msglen_out, MPI_INTEGER8, source, recv_tag, comm%handle, MPI_STATUS_IGNORE, ierr)
         IF (ierr /= 0) CALL mp_stop(ierr, "mpi_sendrecv @ "//routineN)
         CALL add_perf(perf_id=7, &
                       msg_size=(msglen_in + msglen_out)*int_8_size/2)
#else
         MARK_USED(dest)
         MARK_USED(source)
         MARK_USED(comm)
         msgout = msgin
#endif
         CALL timestop(handle)
      END SUBROUTINE mp_sendrecv_lv