23 dbt_distribution_destroy,&
24 dbt_distribution_new,&
25 dbt_distribution_type,&
26 dbt_mp_environ_pgrid,&
39#include "./base/base_uses.f90"
45 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tensors_types'
60 LOGICAL :: owns_comm = .false.
67 LOGICAL :: owns_dist = .false.
73 INTEGER :: iter_level = 0
75 INTEGER,
DIMENSION(2) :: bounds_i = 0, bounds_j = 0, bounds_k = 0
77 INTEGER :: ipair = -1, my_pair = -1
94 INTEGER,
DIMENSION(:),
INTENT(IN) :: dist1, dist2, dist3
95 INTEGER,
INTENT(IN) :: nkind
98 LOGICAL,
INTENT(IN),
OPTIONAL :: own_comm
100 CHARACTER(len=*),
PARAMETER :: routinen =
'distribution_3d_create'
103 INTEGER,
DIMENSION(2) :: mp_coor_1, mp_coor_2
106 CALL timeset(routinen, handle)
108 IF (
PRESENT(own_comm))
THEN
109 IF (own_comm) dist_3d%comm_3d = mp_comm_3d
110 dist_3d%owns_comm = own_comm
112 dist_3d%owns_comm = .false.
115 CALL comm_2d_1%from_sub(mp_comm_3d, [.true., .true., .false.])
116 CALL comm_2d_2%from_sub(mp_comm_3d, [.false., .true., .true.])
118 mp_coor_1 = comm_2d_1%mepos_cart
119 mp_coor_2 = comm_2d_2%mepos_cart
121 cpassert(mp_coor_1(2) == mp_coor_2(1))
126 dist_3d%comm_2d_1 = comm_2d_1
127 dist_3d%comm_2d_2 = comm_2d_2
129 CALL timestop(handle)
139 CHARACTER(len=*),
PARAMETER :: routinen =
'distribution_3d_destroy'
143 CALL timeset(routinen, handle)
146 CALL dist%comm_2d_1%free()
147 CALL dist%comm_2d_2%free()
148 IF (dist%owns_comm)
CALL dist%comm_3d%free()
150 NULLIFY (dist%dist_2d_1, dist%dist_2d_2)
152 CALL timestop(handle)
168 INTEGER,
DIMENSION(:),
INTENT(IN) :: dist1, dist2
169 INTEGER,
INTENT(IN) :: nkind
174 CHARACTER(len=*),
PARAMETER :: routinen =
'distribution_2d_create'
176 INTEGER :: handle, iatom, ikind, n, natom
177 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nparticle_local_col, nparticle_local_row
178 INTEGER,
DIMENSION(2) :: mp_coor, mp_dims
179 INTEGER,
DIMENSION(:, :),
POINTER :: dist1_prv, dist2_prv
180 TYPE(
cp_1d_i_p_type),
DIMENSION(:),
POINTER :: local_particle_col, local_particle_row
184 NULLIFY (blacs_env, local_particle_col, local_particle_row, para_env)
186 CALL timeset(routinen, handle)
188 cpassert(
PRESENT(mp_comm_2d) .OR.
PRESENT(blacs_env_ext))
190 IF (
PRESENT(mp_comm_2d))
THEN
191 mp_dims = mp_comm_2d%num_pe_cart
192 mp_coor = mp_comm_2d%mepos_cart
194 para_env = mp_comm_2d
198 cpassert(blacs_env%mepos(1) == mp_coor(1))
199 cpassert(blacs_env%mepos(2) == mp_coor(2))
203 IF (
PRESENT(blacs_env_ext))
THEN
204 blacs_env => blacs_env_ext
205 mp_coor(1) = blacs_env%mepos(1)
206 mp_coor(2) = blacs_env%mepos(2)
209 natom =
SIZE(particle_set)
210 ALLOCATE (dist1_prv(natom, 2), dist2_prv(natom, 2))
211 dist1_prv(:, 1) = dist1
212 dist2_prv(:, 1) = dist2
214 ALLOCATE (local_particle_col(nkind), local_particle_row(nkind))
215 ALLOCATE (nparticle_local_row(nkind), nparticle_local_col(nkind))
216 nparticle_local_row = 0; nparticle_local_col = 0
219 ikind = particle_set(iatom)%atomic_kind%kind_number
221 IF (dist1_prv(iatom, 1) == mp_coor(1)) nparticle_local_row(ikind) = nparticle_local_row(ikind) + 1
222 IF (dist2_prv(iatom, 1) == mp_coor(2)) nparticle_local_col(ikind) = nparticle_local_col(ikind) + 1
226 n = nparticle_local_row(ikind)
227 ALLOCATE (local_particle_row(ikind)%array(n))
229 n = nparticle_local_col(ikind)
230 ALLOCATE (local_particle_col(ikind)%array(n))
233 nparticle_local_row = 0; nparticle_local_col = 0
235 ikind = particle_set(iatom)%atomic_kind%kind_number
237 IF (dist1_prv(iatom, 1) == mp_coor(1))
THEN
238 nparticle_local_row(ikind) = nparticle_local_row(ikind) + 1
239 local_particle_row(ikind)%array(nparticle_local_row(ikind)) = iatom
241 IF (dist2_prv(iatom, 1) == mp_coor(2))
THEN
242 nparticle_local_col(ikind) = nparticle_local_col(ikind) + 1
243 local_particle_col(ikind)%array(nparticle_local_col(ikind)) = iatom
247 CALL distribution_2d_create_prv(dist_2d, row_distribution_ptr=dist1_prv, &
248 col_distribution_ptr=dist2_prv, local_rows_ptr=local_particle_row, &
249 local_cols_ptr=local_particle_col, blacs_env=blacs_env)
251 IF (.NOT.
PRESENT(blacs_env_ext))
THEN
255 CALL timestop(handle)
268 INTEGER,
INTENT(IN) :: nel
269 INTEGER,
INTENT(INOUT) :: nbin
270 INTEGER,
DIMENSION(nel),
INTENT(IN) :: weights
271 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT), &
272 OPTIONAL :: limits_start, limits_end
273 INTEGER,
DIMENSION(nel),
INTENT(OUT),
OPTIONAL :: dist
275 INTEGER :: el_end, el_start, end_weight, ibin, &
276 nel_div, nel_rem, nel_split, nel_w, &
278 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: lim_e, lim_s
280 ALLOCATE (lim_s(nbin), lim_e(nbin))
285 nel_rem = mod(nel_w, nbin)
292 IF (ibin <= nel_rem)
THEN
293 nel_split = nel_split + 1
295 el_start = el_end + 1
297 w_partialsum = w_partialsum + weights(el_end)
298 end_weight = end_weight + nel_split
299 DO WHILE (w_partialsum < end_weight)
302 w_partialsum = w_partialsum + weights(el_end)
303 IF (el_end == nel)
EXIT
306 IF (
PRESENT(dist)) dist(el_start:el_end) = ibin - 1
307 lim_s(ibin) = el_start
310 IF (el_end == nel)
EXIT
313 IF (
PRESENT(limits_start) .AND.
PRESENT(limits_end))
THEN
314 ALLOCATE (limits_start(ibin)); limits_start(:ibin) = lim_s(:ibin)
315 ALLOCATE (limits_end(ibin)); limits_end(:ibin) = lim_e(:ibin)
336 SUBROUTINE create_3c_tensor(t3c, dist_1, dist_2, dist_3, pgrid, sizes_1, sizes_2, sizes_3, map1, map2, name)
337 TYPE(dbt_type),
INTENT(OUT) :: t3c
338 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: dist_1, dist_2, dist_3
339 TYPE(dbt_pgrid_type),
INTENT(IN) :: pgrid
340 INTEGER,
DIMENSION(:),
INTENT(IN) :: sizes_1, sizes_2, sizes_3, map1, map2
341 CHARACTER(len=*),
INTENT(IN) :: name
343 CHARACTER(len=*),
PARAMETER :: routinen =
'create_3c_tensor'
345 INTEGER :: handle, size_1, size_2, size_3
346 INTEGER,
DIMENSION(3) :: pcoord, pdims
347 TYPE(dbt_distribution_type) :: dist
349 CALL timeset(routinen, handle)
351 CALL dbt_mp_environ_pgrid(pgrid, pdims, pcoord)
353 size_1 =
SIZE(sizes_1)
354 size_2 =
SIZE(sizes_2)
355 size_3 =
SIZE(sizes_3)
357 ALLOCATE (dist_1(size_1))
358 ALLOCATE (dist_2(size_2))
359 ALLOCATE (dist_3(size_3))
361 CALL dbt_default_distvec(size_1, pdims(1), sizes_1, dist_1)
362 CALL dbt_default_distvec(size_2, pdims(2), sizes_2, dist_2)
363 CALL dbt_default_distvec(size_3, pdims(3), sizes_3, dist_3)
365 CALL dbt_distribution_new(dist, pgrid, dist_1, dist_2, dist_3)
366 CALL dbt_create(t3c, name, dist, map1, map2, sizes_1, sizes_2, sizes_3)
367 CALL dbt_distribution_destroy(dist)
369 CALL timestop(handle)
384 TYPE(dbt_type),
INTENT(OUT) :: t2c
385 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: dist_1, dist_2
386 TYPE(dbt_pgrid_type),
INTENT(IN) :: pgrid
387 INTEGER,
DIMENSION(:),
INTENT(IN) :: sizes_1, sizes_2
388 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: order
389 CHARACTER(len=*),
INTENT(IN) :: name
391 CHARACTER(len=*),
PARAMETER :: routinen =
'create_2c_tensor'
393 INTEGER :: handle, size_1, size_2
394 INTEGER,
DIMENSION(2) :: order_in, pcoord, pdims
395 TYPE(dbt_distribution_type) :: dist
397 CALL timeset(routinen, handle)
399 IF (
PRESENT(order))
THEN
405 CALL dbt_mp_environ_pgrid(pgrid, pdims, pcoord)
407 size_1 =
SIZE(sizes_1)
408 size_2 =
SIZE(sizes_2)
410 ALLOCATE (dist_1(size_1))
411 ALLOCATE (dist_2(size_2))
413 CALL dbt_default_distvec(size_1, pdims(1), sizes_1, dist_1)
414 CALL dbt_default_distvec(size_2, pdims(2), sizes_2, dist_2)
416 CALL dbt_distribution_new(dist, pgrid, dist_1, dist_2)
417 CALL dbt_create(t2c, name, dist, [order_in(1)], [order_in(2)], sizes_1, sizes_2)
418 CALL dbt_distribution_destroy(dist)
420 CALL timestop(handle)
430 INTEGER,
DIMENSION(:),
INTENT(IN) :: blk_sizes
431 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: blk_sizes_split
432 INTEGER,
INTENT(IN) :: max_size
434 INTEGER :: blk_remainder, i, isplit, isplit_sum, &
438 DO i = 1,
SIZE(blk_sizes)
439 nsplit = (blk_sizes(i) + max_size - 1)/max_size
440 isplit_sum = isplit_sum + nsplit
443 ALLOCATE (blk_sizes_split(isplit_sum))
446 DO i = 1,
SIZE(blk_sizes)
447 nsplit = (blk_sizes(i) + max_size - 1)/max_size
448 blk_remainder = blk_sizes(i)
449 DO isplit = 1, nsplit
450 isplit_sum = isplit_sum + 1
451 blk_sizes_split(isplit_sum) = min(max_size, blk_remainder)
452 blk_remainder = blk_remainder - max_size
469 INTEGER,
INTENT(IN) :: min_blk_size
470 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: pgf_blk_sizes
472 INTEGER :: blk_count, blk_count_prev, blk_size, &
473 iatom, ikind, iset, natom, nblk, nset
474 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of, pgf_blk_sizes_tmp
475 INTEGER,
DIMENSION(:),
POINTER :: nsgf_set
481 ikind = kind_of(iatom)
486 ALLOCATE (pgf_blk_sizes_tmp(nblk)); pgf_blk_sizes_tmp = 0
491 blk_count_prev = blk_count
492 ikind = kind_of(iatom)
495 blk_size = blk_size + nsgf_set(iset)
496 IF (blk_size >= min_blk_size)
THEN
497 blk_count = blk_count + 1
498 pgf_blk_sizes_tmp(blk_count) = pgf_blk_sizes_tmp(blk_count) + blk_size
502 IF (blk_size > 0)
THEN
503 IF (blk_count == blk_count_prev) blk_count = blk_count + 1
504 pgf_blk_sizes_tmp(blk_count) = pgf_blk_sizes_tmp(blk_count) + blk_size
509 ALLOCATE (pgf_blk_sizes(blk_count))
510 pgf_blk_sizes(:) = pgf_blk_sizes_tmp(:blk_count)
523 starts_array_block, ends_array_block)
524 INTEGER,
DIMENSION(:),
INTENT(IN) :: sizes
525 INTEGER,
INTENT(INOUT) :: nbatches
526 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: starts_array, ends_array, &
527 starts_array_block, ends_array_block
529 INTEGER :: bsum, imem, nblocks
531 nblocks =
SIZE(sizes)
533 CALL contiguous_tensor_dist(nblocks, nbatches, sizes, limits_start=starts_array_block, limits_end=ends_array_block)
535 ALLOCATE (starts_array(nbatches))
536 ALLOCATE (ends_array(nbatches))
539 DO imem = 1, nbatches
540 starts_array(imem) = bsum + 1
541 bsum = bsum + sum(sizes(starts_array_block(imem):ends_array_block(imem)))
542 ends_array(imem) = bsum
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
subroutine, public cp_blacs_env_create(blacs_env, para_env, blacs_grid_layout, blacs_repeatable, row_major, grid_2d)
allocates and initializes a type that represent a blacs context
This is the start of a dbt_api, all publically needed functions are exported here....
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
subroutine, public distribution_2d_create(distribution_2d, blacs_env, local_rows_ptr, n_local_rows, local_cols_ptr, row_distribution_ptr, col_distribution_ptr, n_local_cols, n_row_distribution, n_col_distribution)
initializes the distribution_2d
subroutine, public distribution_2d_release(distribution_2d)
...
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Define the data structure for the particle information.
Define the neighbor list data types and the corresponding functionality.
Utility methods to build 3-center integral tensors of various types.
integer, parameter, public symmetrik_ik
subroutine, public distribution_3d_create(dist_3d, dist1, dist2, dist3, nkind, particle_set, mp_comm_3d, own_comm)
Create a 3d distribution.
integer, parameter, public default_block_size
integer, parameter, public symmetric_jk
integer, parameter, public symmetric_ijk
subroutine, public contiguous_tensor_dist(nel, nbin, weights, limits_start, limits_end, dist)
contiguous distribution of weighted elements
subroutine, public create_2c_tensor(t2c, dist_1, dist_2, pgrid, sizes_1, sizes_2, order, name)
...
subroutine, public split_block_sizes(blk_sizes, blk_sizes_split, max_size)
...
subroutine, public pgf_block_sizes(atomic_kind_set, basis, min_blk_size, pgf_blk_sizes)
...
integer, parameter, public symmetric_ij
integer, parameter, public symmetric_none
subroutine, public distribution_3d_destroy(dist)
Destroy a 3d distribution.
subroutine, public create_tensor_batches(sizes, nbatches, starts_array, ends_array, starts_array_block, ends_array_block)
...
subroutine, public create_3c_tensor(t3c, dist_1, dist_2, dist_3, pgrid, sizes_1, sizes_2, sizes_3, map1, map2, name)
...
Provides all information about an atomic kind.
represent a pointer to a 1d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
distributes pairs on a 2d grid of processors
stores all the informations relevant to an mpi environment