PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
Interfaces and Types | Functions/Subroutines | Variables
mpi_utilities Module Reference

Numerical utilities related to MPI. More...

Interfaces and Types

interface  broadcast_var
 Wrapper function to broadcast a single variable using MPI. More...
 
interface  get_ghost_arr
 Fill the ghost regions in an array. More...
 
interface  get_ser_var
 Gather parallel variable in serial version on group master. More...
 

Functions/Subroutines

integer function, public redistribute_var (var, dis_var, lims, lims_dis)
 Redistribute variables according to new limits. More...
 
integer function, public wait_mpi ()
 Wait for all processes, wrapper to MPI barrier. More...
 
integer function, public lock_req_acc (lock, blocking)
 Request access to lock of a BL (blocking) or optionally a NB (non-blocking) type. More...
 
integer function, public lock_return_acc (lock)
 Returns access to a lock. More...
 
logical function wl_empty (wl, proc_type, next_procs)
 Decides whether a waiting list is empty. More...
 
integer function lock_notify (lock_loc, rec_rank)
 Notifies a rank that they can get the lock. More...
 
integer function lock_get_notified (lock_loc)
 Get notified that the rank can get the lock. More...
 
integer function, public lock_wl_change (wl_action, blocking, lock_loc, wl, ranks)
 Adds, removes or sets to active a rank from the waiting list for a lock and returns the lock waiting list: More...
 
character(len=max_str_ln) function, public lock_header (lock_loc)
 Returns the header for lock debug messages. More...
 

Variables

logical, public debug_lock = .false.
 print debug information about lock operations More...
 
integer, public n_waits = 0
 number of waits More...
 

Detailed Description

Numerical utilities related to MPI.

This includes a lock system, which can be both BL (blocking) or NB (non-blocking). It is based on the implementation of an MPI-IO atomic mode without file support, described in [13].

See also
See mpi_vars.

The reason for this was the fact that using a simple lock file can lead to crashes.

Note
A downside of this method is that in some rare cases a deadlock may occur as the master process, which contains the shared variable with a window that other processes may use, is idle and waiting, whereas the others are still performing lock options. As the master is idle and waiting, its MPI asynchronous communication is not performed. To remedy this, just call wait_MPI() after procedures where lock operations are performed.

Function/Subroutine Documentation

◆ lock_get_notified()

integer function mpi_utilities::lock_get_notified ( type(lock_type), intent(in)  lock_loc)

Get notified that the rank can get the lock.

Note
Based on [13].
Returns
ierr
Parameters
[in]lock_loclock

Definition at line 1063 of file MPI_utilities.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lock_header()

character(len=max_str_ln) function, public mpi_utilities::lock_header ( type(lock_type), intent(in)  lock_loc)

Returns the header for lock debug messages.

Note
Debug version only
Parameters
[in]lock_loclock

Definition at line 1217 of file MPI_utilities.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lock_notify()

integer function mpi_utilities::lock_notify ( type(lock_type), intent(in)  lock_loc,
integer, intent(in)  rec_rank 
)

Notifies a rank that they can get the lock.

The signal sent is the rank + 1.

Note
Based on [13].
Returns
ierr
Parameters
[in]lock_loclock
[in]rec_rankreceiving rank

Definition at line 1031 of file MPI_utilities.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lock_req_acc()

integer function, public mpi_utilities::lock_req_acc ( type(lock_type), intent(inout)  lock,
logical, intent(in), optional  blocking 
)

Request access to lock of a BL (blocking) or optionally a NB (non-blocking) type.

Note
Based on [13].
Returns
ierr

Definition at line 765 of file MPI_utilities.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lock_return_acc()

integer function, public mpi_utilities::lock_return_acc ( type(lock_type), intent(inout)  lock)

Returns access to a lock.

The blocking property has been set when requesting the lock.

Note
Based on [13].
Returns
ierr

Definition at line 872 of file MPI_utilities.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lock_wl_change()

integer function, public mpi_utilities::lock_wl_change ( integer, intent(in)  wl_action,
logical, intent(in)  blocking,
type(lock_type), intent(inout)  lock_loc,
integer, dimension(:), intent(inout), allocatable  wl,
integer, dimension(:), intent(in), optional  ranks 
)

Adds, removes or sets to active a rank from the waiting list for a lock and returns the lock waiting list:

Actions:

  • wl_action = 0: remove
  • wl_action = 1: add
  • wl_action = 2: active

Or negative equivalents for non-blocking (NB) procs.

Optionally, the rank(s) of the process for which to perform this action can be passed. This is useful for doing the same action on multiple processes.

Note
Based on [13].
Debug version only
Returns
ierr
Parameters
[in]wl_actionaction to perform
[in]blockingthe ranks to be changed are blocking
[in,out]lock_loclock
[in,out]wlwaiting list
[in]ranksrank(s) for which to perform option

Definition at line 1111 of file MPI_utilities.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redistribute_var()

integer function, public mpi_utilities::redistribute_var ( real(dp), dimension(:), intent(in)  var,
real(dp), dimension(:), intent(inout)  dis_var,
integer, dimension(2), intent(in)  lims,
integer, dimension(2), intent(in)  lims_dis 
)

Redistribute variables according to new limits.

Parameters
[in]varparallel vector
[in,out]dis_varredistributed vector
[in]limsindices of parallel vector
[in]lims_disindices of redistributed parallel vector

Definition at line 330 of file MPI_utilities.f90.

+ Here is the caller graph for this function:

◆ wait_mpi()

integer function, public mpi_utilities::wait_mpi

Wait for all processes, wrapper to MPI barrier.

Returns
ierr

Definition at line 744 of file MPI_utilities.f90.

+ Here is the caller graph for this function:

◆ wl_empty()

logical function mpi_utilities::wl_empty ( integer, dimension(:), intent(in)  wl,
integer, dimension(:), intent(in)  proc_type,
integer, dimension(:), intent(inout), optional, allocatable  next_procs 
)

Decides whether a waiting list is empty.

The type of process to find is indicated by an array of possible values.

See also
See lock_wl_change() for an explanation of the process type.

Additionally, for NB processes, the negative inverse of these values are used.

If the waiting list is not empty, the next process(es) can optionally be returned.

Note
Based on [13].
Returns
ierr
Parameters
[in]wlwaiting list
[in]proc_typetypes of processes accepted
[in,out]next_procsnext process(es) if not empty

Definition at line 985 of file MPI_utilities.f90.

+ Here is the caller graph for this function:

Variable Documentation

◆ debug_lock

logical, public mpi_utilities::debug_lock = .false.

print debug information about lock operations

Note
Debug version only

Definition at line 40 of file MPI_utilities.f90.

◆ n_waits

integer, public mpi_utilities::n_waits = 0

number of waits

Note
Debug version only

Definition at line 41 of file MPI_utilities.f90.