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 datainteger(kind=mpi_address_kind), intent(out) :: address
: byte addressinteger, optional, intent(out) :: ierr
: error code
location
. mpi_bcast(buf,count,datatype,root,comm,ierr)
-
type(*), dimension(..) :: buf
: starting location of data to be broadcastedinteger, intent(in) :: count
: number of data to be broadcastedtype(mpi_datatype), intent(in) :: datatype
: type of data to be broadcastedinteger, intent(in) :: root
: rank of the processor which broadcasts datatype(mpi_comm), intent(in) :: comm
: communicatorinteger, optional, intent(out) :: ierr
: error code
buf
from theroot
processor to all processors in the communicator, and all other processors in the communicator store the received data intobuf
. mpi_comm_rank(comm,rank,ierr)
-
type(mpi_comm), intent(in) :: comm
: communicatorinteger, intent(out) :: rank
: processor rankinteger, optional, intent(out) :: ierr
: error code
mpi_comm_size(comm,size,ierr)
-
type(mpi_comm), intent(in) :: comm
: communicatorinteger, intent(out) :: size
: number of processorsinteger, optional, intent(out) :: ierr
: error code
mpi_finalize(ierr)
-
integer, optional, intent(out) :: ierr
: error code
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 processorinteger, intent(in) :: sendcounts
: number of data to be sent by each processortype(mpi_datatype), intent(in) :: sendtype
: type of data to be sent by each processortype(*), dimension(..) :: recvbuf
: starting location of data to be received by theroot
processorinteger, intent(in) :: recvcounts
: number of data sent from each processor to be received by theroot
processortype(mpi_datatype), intent(in) :: recvtype
: type of data to be received by theroot
processorinteger, intent(in) :: root
: rank of processor to which data are gatheredtype(mpi_comm), intent(in) :: comm
: communicatorinteger, optional, intent(out) :: ierr
: error code
root
processor. The data sent by -th processor are stored to the location next to the location of the data sent by the -th processor.Sendcounts
/sendtype
andrecvcounts
/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 processorinteger, intent(in) :: sendcounts
: number of data to be sent by each processortype(mpi_datatype), intent(in) :: sendtype
: type of data to be sent by each processortype(*), dimension(..) :: recvbuf
: starting location of data to be received by theroot
processorinteger, intent(in) :: recvcounts(*)
: number of data sent from each processor to be received by theroot
processorinteger, intent(in) :: displs(*)
: location of data to be placed on theroot
processortype(mpi_datatype), intent(in) :: recvtype
: type of data to be received by theroot
processorinteger, intent(in) :: root
: rank of processor to which data are gatheredtype(mpi_comm), intent(in) :: comm
: communicatorinteger, optional, intent(out) :: ierr
: error code
Mpi_gatherv
extends the functionality ofmpi_gather
by allowing a varying count of data from each processor.Displs
specifies the location of data to be placed on theroot
processor. mpi_init(ierr)
integer, optional, intent(out) :: ierr
: error code
mpi_irecv(buf,count,datatype,source,tag,comm,request,ierr)
-
type(*), dimension(..), asynchronous :: buf
: starting location of data to be receivedinteger, intent(in) :: count
: number of data to be receivedtype(mpi_datatype), intent(in) :: datatype
: type of data to be receivedinteger, intent(in) :: source
: source processor rankinteger, intent(in) :: tag
: message tagtype(mpi_comm), intent(in) :: comm
: communicatortype(mpi_request), intent(out) :: request
: request tag to be used bympi_wait
integer, optional, intent(out) :: ierr
: error code
mpi_recv
. mpi_isend(buf,count,datatype,dest,tag,comm,request,ierr)
-
type(*), dimension(..), intent(in), asynchronous :: buf
: starting location of data to be sentinteger, intent(in) :: count
: number of data to be senttype(mpi_datatype), intent(in) :: datatype
: type of data to be sentinteger, intent(in) :: dest
: destination processor rankinteger, intent(in) :: tag
: message tagtype(mpi_comm), intent(in) :: comm
: communicatortype(mpi_request), intent(out) :: request
: request tag to be used bympi_wait
integer, optional, intent(out) :: ierr
: error code
mpi_send
. mpi_recv(buf,count,datatype,source,tag,comm,status,ierr)
-
type(*), dimension(..) :: buf
: starting location of data to be receivedinteger, intent(in) :: count
: number of data to be receivedtype(mpi_dataype), intent(in) :: datatype
: type of data to be receivedinteger, intent(in) :: source
: source processor rankinteger, intent(in) :: tag
: message tagtype(mpi_comm), intent(in) :: comm
: communicatortype(mpi_status) :: status
: information of the received datainteger, optional, intent(out) :: ierr
: error code
source
processor, and stores it intobuf
. The correspondingmpi_send
should have the same messagetag
.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 operandtype(*), dimension(..) :: recvbuf
: starting location of resultinteger, intent(in) :: count
: size ofsendbuf
/recvbuf
type(mpi_datatype), intent(in) :: datatype
: type ofsendbuf
/recvbuf
type(mpi_op), intent(in) :: operator
: operatorinteger, intent(in) :: root
: rank of the processor which gets the resulttype(mpi_comm), intent(in) :: comm
: communicatorinteger, optional, intent(out) :: ierr
: error code
sendbuf
of each processor using the operation specified byoperator
, and returns the combined value inrecvbuf
of theroot
processor. Theoperator
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 sentinteger, intent(in) :: count
: number of data to be senttype(mpi_datatype), intent(in) :: datatype
: type of data to be sentinteger, intent(in) :: dest
: destination processor rankinteger, intent(in) :: tag
: message tagtype(mpi_comm), intent(in) :: comm
: communicatorinteger, optional, intent(out) :: ierr
: error code
buf
to thedest
processor. The correspondingmpi_recv
should have the same messagetag
. 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 sentinteger, intent(in) :: sendcount
: number of data to be senttype(mpi_datatype), intent(in) :: sendtype
: type of data to be sentinteger, intent(in) :: dest
: destination processor rankinteger, intent(in) :: sendtag
: message tagtype(*), dimension(..) :: recvbuf
: starting location of data to be receivedinteger, intent(in) :: recvcount
: number of data to be receivedtype(mpi_datatype), intent(in) :: recvtype
: type of data to be receivedinteger, intent(in) :: source
: source processor rankinteger, intent(in) :: recvtag
: message tagtype(mpi_comm), intent(in) :: comm
: communicatortype(mpi_status) :: status
: information of the received datainteger, optional, intent(out) :: ierr
: error code
mpi_send
andmpi_recv
. mpi_type_commit(newtype,ierr)
-
type(mpi_datatype), intent(in) :: newtype
: derivative type to be committedinteger, optional, intent(out) :: ierr
: error code
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 typeinteger, intent(in) :: sizes(count)
: size of each element of the new typeinteger(kind=mpi_address_kind), intent(in) :: displacements(count)
: displacement of each element of the new typetype(mpi_datatype), intent(in) :: types(count)
: datatype of each element of the new typetype(mpi_datatype), intent(out) :: newtype
: new data typeinteger, optional, intent(out) :: ierr
: error code
count
,sizes
,displacements
,types
. mpi_wait(request,status,ierr)
-
type(mpi_request), intent(inout) :: request
: tagtype(mpi_status) :: status
: information on the completed operation.integer, optional, intent(out) :: ierr
: error code