17 #include "./base/base_uses.f90"
23 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'group_dist_types'
25 PUBLIC :: group_dist_d0_type, group_dist_d1_type, &
29 TYPE group_dist_d0_type
30 INTEGER :: starts = -1, ends = -1, sizes = -1
31 END TYPE group_dist_d0_type
35 TYPE group_dist_d1_type
36 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: starts, ends, sizes
37 END TYPE group_dist_d1_type
39 INTERFACE create_group_dist
40 MODULE PROCEDURE create_group_dist_d0, &
41 create_group_dist_d1_i1, &
42 create_group_dist_d1_i3, &
43 create_group_dist_d1_gd, &
44 create_group_dist_d1_0
45 END INTERFACE create_group_dist
47 INTERFACE get_group_dist
48 MODULE PROCEDURE get_group_dist_d0, &
53 INTERFACE release_group_dist
54 MODULE PROCEDURE release_group_dist_d1
55 END INTERFACE release_group_dist
66 PURE SUBROUTINE create_group_dist_d0(this, ngroups, dimen, pos)
67 TYPE(group_dist_d0_type),
INTENT(INOUT) :: this
68 INTEGER,
INTENT(IN) :: ngroups, dimen, pos
70 INTEGER,
DIMENSION(2) :: itmp
75 this%sizes = itmp(2) - itmp(1) + 1
77 END SUBROUTINE create_group_dist_d0
85 PURE SUBROUTINE create_group_dist_d1_i1(this, ngroups, dimen)
86 TYPE(group_dist_d1_type),
INTENT(INOUT) :: this
87 INTEGER,
INTENT(IN) :: ngroups, dimen
90 INTEGER,
DIMENSION(2) :: itmp
92 ALLOCATE (this%starts(0:ngroups - 1))
94 ALLOCATE (this%ends(0:ngroups - 1))
96 ALLOCATE (this%sizes(0:ngroups - 1))
99 DO iproc = 0, ngroups - 1
101 this%starts(iproc) = itmp(1)
102 this%ends(iproc) = itmp(2)
103 this%sizes(iproc) = itmp(2) - itmp(1) + 1
106 END SUBROUTINE create_group_dist_d1_i1
113 PURE SUBROUTINE create_group_dist_d1_0(this, ngroups)
114 TYPE(group_dist_d1_type),
INTENT(INOUT) :: this
115 INTEGER,
INTENT(IN) :: ngroups
117 ALLOCATE (this%starts(0:ngroups - 1))
119 ALLOCATE (this%ends(0:ngroups - 1))
121 ALLOCATE (this%sizes(0:ngroups - 1))
124 END SUBROUTINE create_group_dist_d1_0
134 SUBROUTINE create_group_dist_d1_i3(this, starts, ends, sizes, comm)
135 TYPE(group_dist_d1_type),
INTENT(INOUT) :: this
136 INTEGER,
INTENT(IN) :: starts, ends, sizes
138 CLASS(mp_comm_type),
INTENT(IN) :: comm
140 CHARACTER(LEN=*),
PARAMETER :: routineN =
'create_group_dist_d1_i3'
144 CALL timeset(routinen, handle)
146 ALLOCATE (this%starts(0:comm%num_pe - 1))
147 ALLOCATE (this%ends(0:comm%num_pe - 1))
148 ALLOCATE (this%sizes(0:comm%num_pe - 1))
150 CALL comm%allgather(starts, this%starts)
151 CALL comm%allgather(ends, this%ends)
152 CALL comm%allgather(sizes, this%sizes)
154 CALL timestop(handle)
156 END SUBROUTINE create_group_dist_d1_i3
164 SUBROUTINE create_group_dist_d1_gd(this, group_dist_ext, comm)
165 TYPE(group_dist_d1_type),
INTENT(INOUT) :: this
166 TYPE(group_dist_d0_type),
INTENT(IN) :: group_dist_ext
168 CLASS(mp_comm_type),
INTENT(IN) :: comm
170 CHARACTER(LEN=*),
PARAMETER :: routineN =
'create_group_dist_d1_gd'
174 CALL timeset(routinen, handle)
176 ALLOCATE (this%starts(0:comm%num_pe - 1))
177 ALLOCATE (this%ends(0:comm%num_pe - 1))
178 ALLOCATE (this%sizes(0:comm%num_pe - 1))
180 CALL comm%allgather(group_dist_ext%starts, this%starts)
181 CALL comm%allgather(group_dist_ext%ends, this%ends)
182 CALL comm%allgather(group_dist_ext%sizes, this%sizes)
184 CALL timestop(handle)
186 END SUBROUTINE create_group_dist_d1_gd
195 PURE SUBROUTINE get_group_dist_d0(this, starts, ends, sizes)
196 TYPE(group_dist_d0_type),
INTENT(IN) :: this
197 INTEGER,
INTENT(OUT),
OPTIONAL :: starts, ends, sizes
199 IF (
PRESENT(starts)) starts = this%starts
200 IF (
PRESENT(ends)) ends = this%ends
201 IF (
PRESENT(sizes)) sizes = this%sizes
203 END SUBROUTINE get_group_dist_d0
214 PURE SUBROUTINE get_group_dist_d1(this, pos, starts, ends, sizes, group_dist_ext)
215 TYPE(group_dist_d1_type),
INTENT(IN) :: this
216 INTEGER,
INTENT(IN) :: pos
217 INTEGER,
INTENT(OUT),
OPTIONAL :: starts, ends, sizes
218 TYPE(group_dist_d0_type),
INTENT(OUT),
OPTIONAL :: group_dist_ext
220 IF (
PRESENT(starts)) starts = this%starts(pos)
221 IF (
PRESENT(ends)) ends = this%ends(pos)
222 IF (
PRESENT(sizes)) sizes = this%sizes(pos)
224 IF (
PRESENT(group_dist_ext))
THEN
225 group_dist_ext%starts = this%starts(pos)
226 group_dist_ext%ends = this%ends(pos)
227 group_dist_ext%sizes = this%sizes(pos)
230 END SUBROUTINE get_group_dist_d1
239 PURE SUBROUTINE get_group_dist_gd1(this, pos, group_dist_ext, pos_ext)
240 TYPE(group_dist_d1_type),
INTENT(IN) :: this
241 INTEGER,
INTENT(IN) :: pos
242 TYPE(group_dist_d1_type),
INTENT(INOUT) :: group_dist_ext
243 INTEGER,
INTENT(IN) :: pos_ext
245 group_dist_ext%starts(pos_ext) = this%starts(pos)
246 group_dist_ext%ends(pos_ext) = this%ends(pos)
247 group_dist_ext%sizes(pos_ext) = this%sizes(pos)
249 END SUBROUTINE get_group_dist_gd1
255 PURE SUBROUTINE release_group_dist_d1(this)
256 TYPE(group_dist_d1_type),
INTENT(INOUT) :: this
258 DEALLOCATE (this%starts)
259 DEALLOCATE (this%ends)
260 DEALLOCATE (this%sizes)
262 END SUBROUTINE release_group_dist_d1
270 TYPE(group_dist_d1_type),
INTENT(IN) :: this
273 res = maxval(this%sizes)
284 TYPE(group_dist_d1_type),
INTENT(IN) :: this
285 INTEGER,
INTENT(IN) :: pos
291 DO p = 0,
SIZE(this%sizes) - 1
292 IF (pos <= this%ends(p) .AND. pos >= this%starts(p))
THEN
Types to describe group distributions.
elemental integer function, public maxsize(this)
...
elemental integer function, public group_dist_proc(this, pos)
...
Interface to the message passing library MPI.
All kind of helpful little routines.
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me