Plasma Simulation Lab.

MPI Subroutine Synopses

The subroutines described here are those only used in the examples, not exhaustive. For the detail of MPI, please refer MPI standard Documents, or manuals of each implementation, such as MPICH or Open MPI.

mpi_get_address(location,address,ierr)
  • type(*), dimension(..), asynchronous :: location : location of data
  • integer(kind=mpi_address_kind), intent(out) :: address : byte address
  • integer, optional, intent(out) :: ierr : error code
Gets a byte address of location.
mpi_bcast(buf,count,datatype,root,comm,ierr)
  • type(*), dimension(..) :: buf : starting location of data to be broadcasted
  • integer, intent(in) :: count : number of data to be broadcasted
  • type(mpi_datatype), intent(in) :: datatype : type of data to be broadcasted
  • integer, intent(in) :: root : rank of the processor which broadcasts data
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, optional, intent(out) :: ierr : error code
Broadcasts buf from the root processor to all processors in the communicator, and all other processors in the communicator store the received data into buf.
mpi_comm_rank(comm,rank,ierr)
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, intent(out) :: rank : processor rank
  • integer, optional, intent(out) :: ierr : error code
Gets the rank of the processor in the communicator.
mpi_comm_size(comm,size,ierr)
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, intent(out) :: size : number of processors
  • integer, optional, intent(out) :: ierr : error code
Gets the number of processors in the communicator.
mpi_finalize(ierr)
  • integer, optional, intent(out) :: ierr : error code
Finalizes MPI. MPI subroutines should be called before this statement.
mpi_gather(sendbuf,sendcounts,sendtype,recvbuf,recvcounts,recvtype,root,comm,ierr)
  • type(*), dimension(..), intent(in) :: sendbuf : starting location of data to be sent by each processor
  • integer, intent(in) :: sendcounts : number of data to be sent by each processor
  • type(mpi_datatype), intent(in) :: sendtype : type of data to be sent by each processor
  • type(*), dimension(..) :: recvbuf : starting location of data to be received by the root processor
  • integer, intent(in) :: recvcounts : number of data sent from each processor to be received by the root processor
  • type(mpi_datatype), intent(in) :: recvtype : type of data to be received by the root processor
  • integer, intent(in) :: root : rank of processor to which data are gathered
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, optional, intent(out) :: ierr : error code
Gathers the data sent by each processor to the root processor. The data sent by Ip-th processor are stored to the location next to the location of the data sent by the Ip-1-th processor. Sendcounts/sendtype and recvcounts/recvtype should be the same for all processors.
mpi_gatherv(sendbuf,sendcounts,sendtype,recvbuf,recvcounts,displs,recvtype,root,comm,ierr)
  • type(*), dimension(..), intent(in) :: sendbuf : starting location of data to be sent by each processor
  • integer, intent(in) :: sendcounts : number of data to be sent by each processor
  • type(mpi_datatype), intent(in) :: sendtype : type of data to be sent by each processor
  • type(*), dimension(..) :: recvbuf : starting location of data to be received by the root processor
  • integer, intent(in) :: recvcounts(*) : number of data sent from each processor to be received by the root processor
  • integer, intent(in) :: displs(*) : location of data to be placed on the root processor
  • type(mpi_datatype), intent(in) :: recvtype : type of data to be received by the root processor
  • integer, intent(in) :: root : rank of processor to which data are gathered
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, optional, intent(out) :: ierr : error code
Mpi_gatherv extends the functionality of mpi_gather by allowing a varying count of data from each processor. Displs specifies the location of data to be placed on the root processor.
mpi_init(ierr)
  • integer, optional, intent(out) :: ierr : error code
Initializes MPI. MPI subroutines should be called after this statement.
mpi_irecv(buf,count,datatype,source,tag,comm,request,ierr)
  • type(*), dimension(..), asynchronous :: buf : starting location of data to be received
  • integer, intent(in) :: count : number of data to be received
  • type(mpi_datatype), intent(in) :: datatype : type of data to be received
  • integer, intent(in) :: source : source processor rank
  • integer, intent(in) :: tag : message tag
  • type(mpi_comm), intent(in) :: comm : communicator
  • type(mpi_request), intent(out) :: request : request tag to be used by mpi_wait
  • integer, optional, intent(out) :: ierr : error code
Non-blocking version of mpi_recv.
mpi_isend(buf,count,datatype,dest,tag,comm,request,ierr)
  • type(*), dimension(..), intent(in), asynchronous :: buf : starting location of data to be sent
  • integer, intent(in) :: count : number of data to be sent
  • type(mpi_datatype), intent(in) :: datatype : type of data to be sent
  • integer, intent(in) :: dest : destination processor rank
  • integer, intent(in) :: tag : message tag
  • type(mpi_comm), intent(in) :: comm : communicator
  • type(mpi_request), intent(out) :: request : request tag to be used by mpi_wait
  • integer, optional, intent(out) :: ierr : error code
Non-blocking version of mpi_send.
mpi_recv(buf,count,datatype,source,tag,comm,status,ierr)
  • type(*), dimension(..) :: buf : starting location of data to be received
  • integer, intent(in) :: count : number of data to be received
  • type(mpi_dataype), intent(in) :: datatype : type of data to be received
  • integer, intent(in) :: source : source processor rank
  • integer, intent(in) :: tag : message tag
  • type(mpi_comm), intent(in) :: comm : communicator
  • type(mpi_status) :: status : information of the received data
  • integer, optional, intent(out) :: ierr : error code
Receives the data sent from the source processor, and stores it into buf. The corresponding mpi_send should have the same message tag. Status records information of the received data, such as the source processor rank, the message tag, and the error code, etc.
mpi_reduce(sendbuf,recvbuf,count,datatype,operator,root,comm,ierr)
  • type(*), dimension(..), intent(in) :: sendbuf : starting location of operand
  • type(*), dimension(..) :: recvbuf : starting location of result
  • integer, intent(in) :: count : size of sendbuf/recvbuf
  • type(mpi_datatype), intent(in) :: datatype : type of sendbuf/recvbuf
  • type(mpi_op), intent(in) :: operator : operator
  • integer, intent(in) :: root : rank of the processor which gets the result
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, optional, intent(out) :: ierr : error code
Combines the elements provided in sendbuf of each processor using the operation specified by operator, and returns the combined value in recvbuf of the root processor. The operator can be the predefined reduction operation (mpi_sum, mpi_max, mpi_min etc.) or a user defined operation.
mpi_send(buf,count,datatype,dest,tag,comm,ierr)
  • type(*), dimension(..), intent(in) :: buf : starting location of data to be sent
  • integer, intent(in) :: count : number of data to be sent
  • type(mpi_datatype), intent(in) :: datatype : type of data to be sent
  • integer, intent(in) :: dest : destination processor rank
  • integer, intent(in) :: tag : message tag
  • type(mpi_comm), intent(in) :: comm : communicator
  • integer, optional, intent(out) :: ierr : error code
Sends buf to the dest processor. The corresponding mpi_recv should have the same message tag.
mpi_sendrecv(sendbuf,sendcount,sendtype,dest,sendtag,recvbuf,recvcount,recvtype,source,recvtag,comm,status,ierr)
  • type(*), dimension(..), intent(in) :: sendbuf : starting location of data to be sent
  • integer, intent(in) :: sendcount : number of data to be sent
  • type(mpi_datatype), intent(in) :: sendtype : type of data to be sent
  • integer, intent(in) :: dest : destination processor rank
  • integer, intent(in) :: sendtag : message tag
  • type(*), dimension(..) :: recvbuf : starting location of data to be received
  • integer, intent(in) :: recvcount : number of data to be received
  • type(mpi_datatype), intent(in) :: recvtype : type of data to be received
  • integer, intent(in) :: source : source processor rank
  • integer, intent(in) :: recvtag : message tag
  • type(mpi_comm), intent(in) :: comm : communicator
  • type(mpi_status) :: status : information of the received data
  • integer, optional, intent(out) :: ierr : error code
Combination of mpi_send and mpi_recv.
mpi_type_commit(newtype,ierr)
  • type(mpi_datatype), intent(in) :: newtype : derivative type to be committed
  • integer, optional, intent(out) :: ierr : error code
Commits newtype. Newtype is available after committing.
mpi_type_create_struct(count,sizes,displacements,types,newtype,ierr)
  • integer, intent(in) :: count : number of elements of the new type
  • integer, intent(in) :: sizes(count) : size of each element of the new type
  • integer(kind=mpi_address_kind), intent(in) :: displacements(count) : displacement of each element of the new type
  • type(mpi_datatype), intent(in) :: types(count) : datatype of each element of the new type
  • type(mpi_datatype), intent(out) :: newtype : new data type
  • integer, optional, intent(out) :: ierr : error code
Creates a derivative type of the group of data defined by count, sizes, displacements, types.
mpi_wait(request,status,ierr)
  • type(mpi_request), intent(inout) :: request : tag
  • type(mpi_status) :: status : information on the completed operation.
  • integer, optional, intent(out) :: ierr : error code
Waits until the corresponding non-blocking subroutine having the same request tag ends.