41 integer :: BLACS_NULL_CONTEXT = -1
45 integer :: context = -1
49 integer,
private :: iam
52 integer,
allocatable :: usermap(:, :)
62 type(blacs_proc_grid_t),
intent(inout) :: this
63 type(mpi_grp_t),
intent(in) :: mpi_grp
64 integer,
optional,
intent(in) :: procdim(:)
68 integer,
parameter :: maxdims = 2
69 integer :: dims(1:2), topo, coords(1:2), ix, iy, id, xy(2)
70 logical :: periods(1:2)
71 type(MPI_Comm) :: comm
73 integer,
allocatable :: procmap(:)
77 call mpi_topo_test(mpi_grp%comm, topo,
mpi_err)
79 if (topo /= mpi_cart .or.
present(procdim))
then
81 if (
present(procdim))
then
85 dims(1) = mpi_grp%size
90 call mpi_cart_create(mpi_grp%comm, 2, dims, periods, reorder, comm,
mpi_err)
95 call blacs_pinfo(this%iam, this%nprocs)
99 safe_allocate(procmap(0:mpi_grp%size - 1))
100 call mpi_allgather(this%iam, 1, mpi_integer, procmap(0), 1, mpi_integer, comm,
mpi_err)
102 assert(this%iam == procmap(mpi_grp%rank))
107 call mpi_cart_get(comm, maxdims, dims, periods, coords,
mpi_err)
109 safe_allocate(this%usermap(1:dims(1), 1:dims(2)))
116 this%usermap(ix, iy) = procmap(id)
121 call blacs_get(blacs_null_context, what = 0, val = this%context)
124 call blacs_gridmap(this%context, this%usermap(1, 1), dims(1), dims(1), dims(2))
127 call blacs_gridinfo(this%context, this%nprow, this%npcol, this%myrow, this%mycol)
130 assert(this%nprow == dims(1))
131 assert(this%npcol == dims(2))
132 assert(this%myrow == coords(1))
133 assert(this%mycol == coords(2))
135 if (topo /= mpi_cart)
then
139 safe_deallocate_a(procmap)
144 this%context = blacs_null_context
156 if (this%context /= blacs_null_context)
then
160 safe_deallocate_a(this%usermap)
163 this%context = blacs_null_context
178 cout%context = cin%context
181 cout%nprocs = cin%nprocs
182 cout%nprow = cin%nprow
183 cout%npcol = cin%npcol
185 cout%myrow = cin%myrow
186 cout%mycol = cin%mycol
188 if (cout%context /= blacs_null_context)
then
190 call blacs_get(blacs_null_context, what = 0, val = cout%context)
191 safe_allocate_source_a(cout%usermap, cin%usermap)
192 call blacs_gridmap(cout%context, cout%usermap(1, 1), cout%nprow, cout%nprow, cout%npcol)
This module contains interfaces for BLACS routines Interfaces are from http:
This module provides the BLACS processor grid.
subroutine, public blacs_proc_grid_init(this, mpi_grp, procdim)
Initializes a blacs context from an MPI communicator with topological information.
subroutine, public blacs_proc_grid_end(this)
subroutine, public blacs_proc_grid_copy(cin, cout)
logical pure function, public blacs_proc_grid_null(this)
integer, public mpi_err
used to store return values of mpi calls