SF_MPI
Description
SciFortran MPI interface
Quick access
- Routines:
allgather_mpi(),allreduce_mpi(),barrier_mpi(),bcast_mpi(),check_mpi(),check_mpi(),cpu_time_mpi(),error_mpi(),finalize_mpi(),finalize_mpi(),get_last_mpi(),get_last_mpi(),get_master_mpi(),get_master_mpi(),get_rank_mpi(),get_rank_mpi(),get_size_mpi(),get_size_mpi(),init_mpi(),init_mpi(),max_mpi(),reduce_mpi(),startmsg_mpi(),startmsg_mpi(),sum_mpi()
Subroutines and functions
- interface sf_mpi/bcast_mpi(comm, data[, root])
This subroutine broadcasts the logical, integer, real(8) or complex(8) scalar or array
datafrom the processrootto all the processes of the communicatorcomm, usingMPI_BCAST. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). Despite theintent(in),datais overwritten on the processes other thanroot. Nothing is done ifcommisMPI_COMM_NULL. MPI errors are reported byError_MPI.- Parameters:
comm [integer, in]
data (various shapes) [logical/integer/real/complex, in]
- Options:
root [integer, in]
- interface sf_mpi/allgather_mpi(comm, send, data)
This subroutine gathers the logical, integer, real(8) or complex(8) scalar or array
sendof every process of the communicatorcommintodata, on all the processes, in the order of the ranks, usingMPI_ALLGATHER. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8).datahas to be large enough to hold the contributions of all the processes. Nothing is done ifcommisMPI_COMM_NULL.- Parameters:
comm [integer, in] – MPI communicator
send (various shapes) [logical/integer/real/complex, in] – data sent by each process
data (various shapes) [logical/integer/real/complex, inout] – gathered data of all processes, by rank
- interface sf_mpi/allreduce_mpi(comm, send, data)
This subroutine sums the logical, integer, real(8) or complex(8) scalar or array
sendover all the processes of the communicatorcomm, and returns the sum indataon every process, usingMPI_ALLREDUCEwithMPI_SUM. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). Nothing is done ifcommisMPI_COMM_NULL. For the maximum and the sum on a single process seeMax_MPIandSum_MPI. Note that the MPI standard does not defineMPI_SUMfor logical data, so the logical procedures may fail or depend on the MPI implementation.- Parameters:
comm [integer, in] – MPI communicator
send (various shapes) [logical/integer/real/complex, in] – data to sum over the processes
data (various shapes) [logical/integer/real/complex, inout] – sum of send over the processes
- interface sf_mpi/reduce_mpi(comm, data[, recv, root])
This subroutine is the same as
Sum_MPI: it sums the logical, integer, real(8) or complex(8) scalar or arraydataover all the processes of the communicatorcommon the processroot(default 0), usingMPI_REDUCEwithMPI_SUM. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8).If
recvis present the sum is returned inrecvanddatais left unchanged. Otherwise the sum overwritesdataon the process of rank 0, which is the root for the defaultroot, anddatais unchanged on the other processes. Nothing is done ifcommisMPI_COMM_NULL. Note that the MPI standard does not defineMPI_SUMfor logical data, so the logical procedures may fail or depend on the MPI implementation.- Parameters:
comm [integer, in] – MPI communicator
data (various shapes) [logical/integer/real/complex, inout] – data to sum (overwritten on rank 0 if no recv)
- Options:
recv (various shapes) [logical/integer/real/complex, inout] – receives the sum on root if present
root [integer, in] – rank of the root process (default 0)
- interface sf_mpi/sum_mpi(comm, data[, recv, root])
This subroutine sums the logical, integer, real(8) or complex(8) scalar or array
dataover all the processes of the communicatorcommon the processroot(default 0), usingMPI_REDUCEwithMPI_SUM. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). It is the same asReduce_MPI.If
recvis present the sum is returned inrecvanddatais left unchanged. Otherwise the sum overwritesdataon the process of rank 0, which is the root for the defaultroot, anddatais unchanged on the other processes. Nothing is done ifcommisMPI_COMM_NULL. The sum on every process is available withAllReduce_MPI. Note that the MPI standard does not defineMPI_SUMfor logical data, so the logical procedures may fail or depend on the MPI implementation.- Parameters:
comm [integer, in] – MPI communicator
data (various shapes) [logical/integer/real/complex, inout] – data to sum (overwritten on rank 0 if no recv)
- Options:
recv (various shapes) [logical/integer/real/complex, inout] – receives the sum on root if present
root [integer, in] – rank of the root process (default 0)
- interface sf_mpi/max_mpi(comm, data[, recv, root])
This subroutine evaluates the element-wise maximum of the logical, integer, real(8) or complex(8) scalar or array
dataover all the processes of the communicatorcommon the processroot(default 0), usingMPI_REDUCEwithMPI_MAX. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8).If
recvis present the maximum is returned inrecvanddatais left unchanged. Otherwise the maximum overwritesdataon the process of rank 0, which is the root for the defaultroot, anddatais unchanged on the other processes. Nothing is done ifcommisMPI_COMM_NULL. Note that the MPI standard does not defineMPI_MAXfor logical and complex data, so these procedures may fail or depend on the MPI implementation.- Parameters:
comm [integer, in] – MPI communicator
data (various shapes) [logical/integer/real/complex, inout] – data to maximize (overwritten on rank 0 if no recv)
- Options:
recv (various shapes) [logical/integer/real/complex, inout] – receives the maximum on root if present
root [integer, in] – rank of the root process (default 0)
- subroutine sf_mpi/init_mpi([comm, msg])
This subroutine initializes the MPI environment with
MPI_Init. Ifcommis present it is set toMPI_COMM_WORLD, and ifmsgis present and true the start message ofStartMsg_MPIis printed. MPI errors are reported byError_MPI, which does not stop the program.- Options:
comm [integer]
msg [logical]
- subroutine sf_mpi/finalize_mpi([comm])
This subroutine terminates the MPI environment with
MPI_Finalize. Ifcommis present it is set toMPI_COMM_NULL. MPI errors are reported byError_MPI, which does not stop the program.- Options:
comm [integer]
- subroutine sf_mpi/startmsg_mpi([comm])
This subroutine prints on the standard output a start message made of a header line, one line
rank: i of N alivefor each process of the communicatorcommin the order of the ranks, and a closing line. The printing is synchronized with barriers. The default communicator isMPI_COMM_WORLD, and nothing is printed forMPI_COMM_NULL.- Options:
comm [integer]
- subroutine sf_mpi/barrier_mpi([comm])
This subroutine blocks the calling process until all the processes of the communicator
commhave reached the barrier, usingMPI_Barrier. The default communicator isMPI_COMM_WORLD, and nothing is done forMPI_COMM_NULL.- Options:
comm [integer] – MPI communicator (default: MPI_COMM_WORLD)
- function sf_mpi/check_mpi()
This function returns
.true.if the MPI environment has been initialized, as given byMPI_Initialized.- Result:
bool [logical]
- function sf_mpi/get_size_mpi([comm])
This function returns the number of processes of the communicator
comm(defaultMPI_COMM_WORLD), usingMPI_Comm_size. ForMPI_COMM_NULLthe result is not set.- Options:
comm [integer]
- Result:
size [integer]
- function sf_mpi/get_rank_mpi([comm])
This function returns the rank of the calling process in the communicator
comm(defaultMPI_COMM_WORLD), usingMPI_Comm_rank. ForMPI_COMM_NULLthe result is not set.- Options:
comm [integer]
- Result:
rank [integer]
- function sf_mpi/get_master_mpi([comm])
This function returns
.true.on the master process, i.e. the process of rank 0, of the communicatorcomm(defaultMPI_COMM_WORLD), and.false.on the other processes and forMPI_COMM_NULL.- Options:
comm [integer]
- Result:
master [logical]
- function sf_mpi/get_last_mpi([comm])
This function returns
.true.on the last process, i.e. the process of ranksize-1, of the communicatorcomm(defaultMPI_COMM_WORLD), and.false.on the other processes and forMPI_COMM_NULL.- Options:
comm [integer]
- Result:
last [logical]
- function sf_mpi/cpu_time_mpi()
This function returns the elapsed time in seconds on the calling processor, as given by
MPI_WTIME. The time is measured from an arbitrary point in the past, so only the difference between two calls is meaningful.- Result:
time [real]
- subroutine sf_mpi/error_mpi([err, sub])
This subroutine prints on the standard output the message associated to the MPI error code
err, preceded by the labelsub. The default code is the one stored by the module after the last MPI call, and the default label isMPI_Get_Error:. Nothing is printed forMPI_SUCCESSor for an unrecognized code, and the program is never stopped.- Options:
err [integer, in] – MPI error code (default: the last code stored by the module)
sub [character(len=*), in] – label of the calling routine, printed before the message
- subroutine sf_mpi/init_mpi()
This subroutine initializes the MPI environment with
MPI_Init. Ifcommis present it is set toMPI_COMM_WORLD, and ifmsgis present and true the start message ofStartMsg_MPIis printed. MPI errors are reported byError_MPI, which does not stop the program.
- subroutine sf_mpi/finalize_mpi()
This subroutine terminates the MPI environment with
MPI_Finalize. Ifcommis present it is set toMPI_COMM_NULL. MPI errors are reported byError_MPI, which does not stop the program.
- subroutine sf_mpi/startmsg_mpi(comm)
This subroutine prints on the standard output a start message made of a header line, one line
rank: i of N alivefor each process of the communicatorcommin the order of the ranks, and a closing line. The printing is synchronized with barriers. The default communicator isMPI_COMM_WORLD, and nothing is printed forMPI_COMM_NULL.- Parameters:
comm [integer] – MPI communicator (default: MPI_COMM_WORLD)
- function sf_mpi/check_mpi()
This function returns
.true.if the MPI environment has been initialized, as given byMPI_Initialized.- Result:
bool [logical]
- function sf_mpi/get_size_mpi(comm)
This function returns the number of processes of the communicator
comm(defaultMPI_COMM_WORLD), usingMPI_Comm_size. ForMPI_COMM_NULLthe result is not set.- Parameters:
comm [integer] – MPI communicator (default: MPI_COMM_WORLD)
- Result:
size [integer]
- function sf_mpi/get_rank_mpi(comm)
This function returns the rank of the calling process in the communicator
comm(defaultMPI_COMM_WORLD), usingMPI_Comm_rank. ForMPI_COMM_NULLthe result is not set.- Parameters:
comm [integer] – MPI communicator (default: MPI_COMM_WORLD)
- Result:
rank [integer]
- function sf_mpi/get_master_mpi(comm)
This function returns
.true.on the master process, i.e. the process of rank 0, of the communicatorcomm(defaultMPI_COMM_WORLD), and.false.on the other processes and forMPI_COMM_NULL.- Parameters:
comm [integer] – MPI communicator (default: MPI_COMM_WORLD)
- Result:
master [logical]
- function sf_mpi/get_last_mpi(comm)
This function returns
.true.on the last process, i.e. the process of ranksize-1, of the communicatorcomm(defaultMPI_COMM_WORLD), and.false.on the other processes and forMPI_COMM_NULL.- Parameters:
comm [integer] – MPI communicator (default: MPI_COMM_WORLD)
- Result:
last [logical]