45 logical :: parallel = .false.
46 integer,
allocatable :: process(:)
47 integer,
allocatable :: range(:, :)
50 integer,
allocatable :: num(:)
52 type(mpi_grp_t) :: mpi_grp
63 class(distributed_t),
intent(in) :: this
72 class(distributed_t),
intent(in) :: this
82 class(distributed_t),
intent(in) :: this
83 integer,
allocatable :: displs(:)
85 displs = this%range(1, :) - 1
92 type(distributed_t),
intent(out) :: this
93 integer,
intent(in) :: total
94 type(MPI_Comm),
intent(in) :: comm
95 character(len=*),
optional,
intent(in) :: tag
96 logical,
optional,
intent(in) :: scalapack_compat
102 safe_allocate(this%process(1:total))
105 safe_allocate(this%num(0:this%mpi_grp%size - 1))
106 safe_allocate(this%range(1:2, 0:this%mpi_grp%size - 1))
109 if (this%mpi_grp%size == 1 .or. total == 1)
then
110 this%process(1:total) = 0
113 this%parallel = .false.
114 this%range(:, 0) = [1, total]
119 this%parallel = .
true.
122 lsize = this%num, scalapack_compat = scalapack_compat)
124 this%start = this%range(1, this%mpi_grp%rank)
125 this%end = this%range(2, this%mpi_grp%rank)
127 do i = 0, this%mpi_grp%size - 1
128 this%process(this%range(1, i):this%range(2, i)) = i
131 if (
present(tag))
then
132 message(1) =
'Info: Parallelization in ' // trim(tag)
134 do i = 0, this%mpi_grp%size - 1
135 write(
message(1),
'(a,i4,a,i6,a)')
'Info: Process in group ', i, &
136 ' will manage ', this%num(i),
' '//trim(tag)
137 if (this%num(i) > 0)
then
138 write(
message(1),
'(a,a,i6,a,i6)') trim(
message(1)),
':', this%range(1, i),
" - ", this%range(2, i)
155 integer,
intent(in) :: total
179 out%parallel = in%parallel
181 nprocs = in%mpi_grp%size
185 if (
allocated(in%process))
then
186 safe_allocate(out%process(1:
size(in%process)))
187 out%process(:) = in%process(:)
190 if (
allocated(in%range))
then
191 safe_allocate(out%range(1:2, 0:nprocs - 1))
192 out%range(1:2, 0:nprocs - 1) = in%range(1:2, 0:nprocs - 1)
195 if (
allocated(in%num))
then
196 safe_allocate(out%num(0:nprocs - 1))
197 out%num(0:nprocs - 1) = in%num(0:nprocs - 1)
209 safe_deallocate_a(this%process)
210 safe_deallocate_a(this%range)
211 safe_deallocate_a(this%num)
pure integer function, dimension(:), allocatable distributed_displs(this)
Displacement of each process''s local part, relative to the start of the distributed quantity,...
subroutine, public distributed_end(this)
subroutine, public distributed_init(this, total, comm, tag, scalapack_compat)
Distribute N instances across M processes of communicator comm
subroutine, public distributed_copy(in, out)
Create a copy of a distributed instance.
subroutine, public distributed_init_serial(this, total)
Serial initialization of a distributed instance. The calling process is assigned all total instances,...
pure integer function distributed_nglobal(this)
Total number of distributed instances.
pure integer function distributed_nlocal(this)
Number of instances of the distributed quantity on process mpi_grprank.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_comm), parameter, public mpi_comm_undefined
used to indicate a communicator has not been initialized
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
This module handles the communicators for the various parallelization strategies.
subroutine, public multicomm_divide_range(nobjs, nprocs, istart, ifinal, lsize, scalapack_compat)
This routine uses the one-factorization (or near-one-factorization of a complete graph to construct a...
Distribution of N instances over mpi_grpsize processes, for the local rank mpi_grprank....