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 data from the process root to all the processes of the communicator comm, using MPI_BCAST. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). Despite the intent(in), data is overwritten on the processes other than root. Nothing is done if comm is MPI_COMM_NULL. MPI errors are reported by Error_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 send of every process of the communicator comm into data, on all the processes, in the order of the ranks, using MPI_ALLGATHER. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). data has to be large enough to hold the contributions of all the processes. Nothing is done if comm is MPI_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 send over all the processes of the communicator comm, and returns the sum in data on every process, using MPI_ALLREDUCE with MPI_SUM. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). Nothing is done if comm is MPI_COMM_NULL. For the maximum and the sum on a single process see Max_MPI and Sum_MPI. Note that the MPI standard does not define MPI_SUM for 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 array data over all the processes of the communicator comm on the process root (default 0), using MPI_REDUCE with MPI_SUM. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8).

If recv is present the sum is returned in recv and data is left unchanged. Otherwise the sum overwrites data on the process of rank 0, which is the root for the default root, and data is unchanged on the other processes. Nothing is done if comm is MPI_COMM_NULL. Note that the MPI standard does not define MPI_SUM for 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 data over all the processes of the communicator comm on the process root (default 0), using MPI_REDUCE with MPI_SUM. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8). It is the same as Reduce_MPI.

If recv is present the sum is returned in recv and data is left unchanged. Otherwise the sum overwrites data on the process of rank 0, which is the root for the default root, and data is unchanged on the other processes. Nothing is done if comm is MPI_COMM_NULL. The sum on every process is available with AllReduce_MPI. Note that the MPI standard does not define MPI_SUM for 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 data over all the processes of the communicator comm on the process root (default 0), using MPI_REDUCE with MPI_MAX. The specific procedures cover scalars and arrays up to rank 7 (8 with gfortran newer than 8).

If recv is present the maximum is returned in recv and data is left unchanged. Otherwise the maximum overwrites data on the process of rank 0, which is the root for the default root, and data is unchanged on the other processes. Nothing is done if comm is MPI_COMM_NULL. Note that the MPI standard does not define MPI_MAX for 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. If comm is present it is set to MPI_COMM_WORLD, and if msg is present and true the start message of StartMsg_MPI is printed. MPI errors are reported by Error_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. If comm is present it is set to MPI_COMM_NULL. MPI errors are reported by Error_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 alive for each process of the communicator comm in the order of the ranks, and a closing line. The printing is synchronized with barriers. The default communicator is MPI_COMM_WORLD, and nothing is printed for MPI_COMM_NULL.

Options:

comm [integer]

subroutine  sf_mpi/barrier_mpi([comm])

This subroutine blocks the calling process until all the processes of the communicator comm have reached the barrier, using MPI_Barrier. The default communicator is MPI_COMM_WORLD, and nothing is done for MPI_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 by MPI_Initialized.

Result:

bool [logical]

function  sf_mpi/get_size_mpi([comm])

This function returns the number of processes of the communicator comm (default MPI_COMM_WORLD), using MPI_Comm_size. For MPI_COMM_NULL the 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 (default MPI_COMM_WORLD), using MPI_Comm_rank. For MPI_COMM_NULL the 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 communicator comm (default MPI_COMM_WORLD), and .false. on the other processes and for MPI_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 rank size-1, of the communicator comm (default MPI_COMM_WORLD), and .false. on the other processes and for MPI_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 label sub. The default code is the one stored by the module after the last MPI call, and the default label is MPI_Get_Error:. Nothing is printed for MPI_SUCCESS or 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. If comm is present it is set to MPI_COMM_WORLD, and if msg is present and true the start message of StartMsg_MPI is printed. MPI errors are reported by Error_MPI, which does not stop the program.

subroutine  sf_mpi/finalize_mpi()

This subroutine terminates the MPI environment with MPI_Finalize. If comm is present it is set to MPI_COMM_NULL. MPI errors are reported by Error_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 alive for each process of the communicator comm in the order of the ranks, and a closing line. The printing is synchronized with barriers. The default communicator is MPI_COMM_WORLD, and nothing is printed for MPI_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 by MPI_Initialized.

Result:

bool [logical]

function  sf_mpi/get_size_mpi(comm)

This function returns the number of processes of the communicator comm (default MPI_COMM_WORLD), using MPI_Comm_size. For MPI_COMM_NULL the 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 (default MPI_COMM_WORLD), using MPI_Comm_rank. For MPI_COMM_NULL the 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 communicator comm (default MPI_COMM_WORLD), and .false. on the other processes and for MPI_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 rank size-1, of the communicator comm (default MPI_COMM_WORLD), and .false. on the other processes and for MPI_COMM_NULL.

Parameters:

comm [integer] – MPI communicator (default: MPI_COMM_WORLD)

Result:

last [logical]