module fd4_globaldef_mod module mrgrnk_modTypes:
public type fd4_mpitypeVariables:
type (fd4_mpitype), public, save :: sortmdtSubroutines and functions:
public subroutine fd4_mpitype_add (mdt, index, blen, displ, mpitype, is_min) public subroutine fd4_mpitype_commit (mdt, err, startdispl) public subroutine fd4_mpitype_allocate (mdt, length, is_sortmdt) public subroutine fd4_mpitype_free (mdt, free_memory, free_types)
call fd4_mpitype_add(mdt, index, blen, displ, ...) ! add a memory location to the type call fd4_mpitype_add(mdt, index, blen, displ, ...) ! add a memory location to the type call fd4_mpitype_add(mdt, index, blen, displ, ...) ! add a memory location to the type ... call fd4_mpitype_commit(mdt, err) ! call mpi_type_create_struct and ..._commit ... call MPI_Send( ... , mdt%datatype ... ) ... call fd4_mpitype_free(mdt)
Note: index is an 8 byte integer!
Note: sortmdt is a global variable which will be allocated, but not deallocated. This is intented behavior.
Author: Matthias Lieber
public type fd4_mpitype integer :: datatype = MPI_DATATYPE_NULL integer (kind=i8k), pointer, dimension (:) :: indexes => null () integer, pointer, dimension (:) :: blens => null () integer, pointer, dimension (:) :: types => null () integer (kind=MPI_ADDRESS_KIND), pointer, dimension (:) :: displ => null () integer (kind=MPI_ADDRESS_KIND) :: mindispl = -1 integer :: count = 0 integer (kind=i_k), pointer, dimension (:) :: sort => null () end type fd4_mpitypeComponents:
sort | used in sortmdt only |
public subroutine fd4_mpitype_add (mdt, index, blen, displ, mpitype, is_min) type (fd4_mpitype), intent(inout) :: mdt integer (kind=i8k), intent(in) :: index integer, intent(in) :: blen integer (kind=MPI_ADDRESS_KIND), intent(in) :: displ integer, intent(in) :: mpitype logical, optional, intent(out) :: is_min end subroutine fd4_mpitype_addParameters:
mdt | the fd4_mpitype |
index | index used for sorting |
blen | block length for constructing datatype |
displ | displacement for constructing datatype |
mpitype | type for constructing datatype |
is_min | true if the displacement is the lowest of (currently) all |
Use the is_min parameter if you need to know the component with the lowest displacement This is the one you should use in mpi_send etc. when using the resulting mpi datatype. fd4_mpitype_commit calculates the displacements relative to the minimal displacement to avoid negative displacements.
The index is used for sorting in fd4_mpitype_commit to allow sender-receiver matching of the types.
public subroutine fd4_mpitype_commit (mdt, err, startdispl) type (fd4_mpitype), intent(inout) :: mdt integer (kind=i_k), intent(out) :: err integer (kind=MPI_ADDRESS_KIND), optional, intent(in) :: startdispl end subroutine fd4_mpitype_commitParameters:
mdt | the fd4_mpitype |
err | error status: 0...ok |
startdispl | start address of the type |
Notes about startdispl:
public subroutine fd4_mpitype_allocate (mdt, length, is_sortmdt) type (fd4_mpitype), intent(inout) :: mdt integer (kind=i_k), intent(in) :: length logical, optional, intent(in) :: is_sortmdt end subroutine fd4_mpitype_allocateParameters:
mdt | the fd4_mpitype |
length | size to allocate (max number of components) |
is_sortmdt | internal option only, do not use! |
public subroutine fd4_mpitype_free (mdt, free_memory, free_types) type (fd4_mpitype), intent(inout) :: mdt logical, intent(in) :: free_memory logical, intent(in) :: free_types end subroutine fd4_mpitype_freeParameters:
mdt | the fd4_mpitype |
free_memory | free the arrays used to construct the MPI datatype |
free_types | free the basic types used to construct the MPI datatype |
free_memory does not imply free_types or vice versa!