29#include "../base/base_uses.f90"
34 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
35 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_fm_pool_types'
57 TYPE(cp_fm_struct_type),
POINTER :: el_struct => null()
73 MODULE PROCEDURE fm_pools_create_fm_m1_p_type_pointer
74 MODULE PROCEDURE fm_pools_create_fm_m1_p_type_alloc
75 MODULE PROCEDURE fm_pools_create_fm_m1_array_pointer
76 MODULE PROCEDURE fm_pools_create_fm_m1_array_alloc
80 MODULE PROCEDURE fm_pools_give_back_fm_m1_p_type_pointer
81 MODULE PROCEDURE fm_pools_give_back_fm_m1_p_type_alloc
82 MODULE PROCEDURE fm_pools_give_back_fm_m1_array_pointer
83 MODULE PROCEDURE fm_pools_give_back_fm_m1_array_alloc
102 pool%el_struct => el_struct
114 SUBROUTINE fm_pool_flush_cache(pool)
120 iterator => pool%cache
128 END SUBROUTINE fm_pool_flush_cache
140 IF (
ASSOCIATED(pool))
THEN
141 CALL fm_pool_flush_cache(pool)
162 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
167 IF (
ASSOCIATED(pool%cache))
THEN
171 IF (
ASSOCIATED(el))
THEN
175 CALL cp_fm_create(element, matrix_struct=pool%el_struct, set_zero=.true.)
178 IF (
PRESENT(name))
THEN
202 IF (.NOT.
ASSOCIATED(pool%el_struct, element%matrix_struct))
THEN
210 NULLIFY (element%matrix_struct, element%local_data)
225 TYPE(cp_fm_struct_type),
POINTER :: res
227 res => pool%el_struct
244 IF (
ASSOCIATED(pools))
THEN
245 DO i = 1,
SIZE(pools)
262 SUBROUTINE fm_pools_create_fm_m1_array_alloc (pools, elements, &
265 TYPE(cp_fm_type),
DIMENSION(:),
ALLOCATABLE :: elements
266 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
273 ALLOCATE (elements(
SIZE(pools)))
274 DO i = 1,
SIZE(pools)
275 pool => pools(i)%pool
276 IF (
PRESENT(name))
THEN
278 name=name//
"-"//adjustl(cp_to_string(i)))
285 END SUBROUTINE fm_pools_create_fm_m1_array_alloc
298 SUBROUTINE fm_pools_give_back_fm_m1_array_alloc (pools, elements)
300 TYPE(cp_fm_type),
DIMENSION(:),
ALLOCATABLE :: elements
304 IF (
ALLOCATED (elements))
THEN
305 cpassert(
SIZE(pools) ==
SIZE(elements))
306 DO i = 1,
SIZE(pools)
310 DEALLOCATE (elements)
312 END SUBROUTINE fm_pools_give_back_fm_m1_array_alloc
322 SUBROUTINE fm_pools_create_fm_m1_array_pointer (pools, elements, &
325 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: elements
326 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
333 ALLOCATE (elements(
SIZE(pools)))
334 DO i = 1,
SIZE(pools)
335 pool => pools(i)%pool
336 IF (
PRESENT(name))
THEN
338 name=name//
"-"//adjustl(cp_to_string(i)))
345 END SUBROUTINE fm_pools_create_fm_m1_array_pointer
358 SUBROUTINE fm_pools_give_back_fm_m1_array_pointer (pools, elements)
360 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: elements
364 IF (
ASSOCIATED (elements))
THEN
365 cpassert(
SIZE(pools) ==
SIZE(elements))
366 DO i = 1,
SIZE(pools)
370 DEALLOCATE (elements)
373 END SUBROUTINE fm_pools_give_back_fm_m1_array_pointer
383 SUBROUTINE fm_pools_create_fm_m1_p_type_alloc (pools, elements, &
386 TYPE(cp_fm_p_type),
DIMENSION(:),
ALLOCATABLE :: elements
387 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
394 ALLOCATE (elements(
SIZE(pools)))
395 DO i = 1,
SIZE(pools)
396 pool => pools(i)%pool
397 ALLOCATE (elements(i)%matrix)
398 IF (
PRESENT(name))
THEN
400 name=name//
"-"//adjustl(cp_to_string(i)))
407 END SUBROUTINE fm_pools_create_fm_m1_p_type_alloc
420 SUBROUTINE fm_pools_give_back_fm_m1_p_type_alloc (pools, elements)
422 TYPE(cp_fm_p_type),
DIMENSION(:),
ALLOCATABLE :: elements
426 IF (
ALLOCATED (elements))
THEN
427 cpassert(
SIZE(pools) ==
SIZE(elements))
428 DO i = 1,
SIZE(pools)
431 DEALLOCATE (elements(i)%matrix)
433 DEALLOCATE (elements)
435 END SUBROUTINE fm_pools_give_back_fm_m1_p_type_alloc
445 SUBROUTINE fm_pools_create_fm_m1_p_type_pointer (pools, elements, &
448 TYPE(cp_fm_p_type),
DIMENSION(:),
POINTER :: elements
449 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
456 ALLOCATE (elements(
SIZE(pools)))
457 DO i = 1,
SIZE(pools)
458 pool => pools(i)%pool
459 ALLOCATE (elements(i)%matrix)
460 IF (
PRESENT(name))
THEN
462 name=name//
"-"//adjustl(cp_to_string(i)))
469 END SUBROUTINE fm_pools_create_fm_m1_p_type_pointer
482 SUBROUTINE fm_pools_give_back_fm_m1_p_type_pointer (pools, elements)
484 TYPE(cp_fm_p_type),
DIMENSION(:),
POINTER :: elements
488 IF (
ASSOCIATED (elements))
THEN
489 cpassert(
SIZE(pools) ==
SIZE(elements))
490 DO i = 1,
SIZE(pools)
493 DEALLOCATE (elements(i)%matrix)
495 DEALLOCATE (elements)
498 END SUBROUTINE fm_pools_give_back_fm_m1_p_type_pointer
pool for for elements that are retained and released
subroutine, public fm_pool_create_fm(pool, element, name)
returns an element, allocating it if none is in the pool
subroutine, public fm_pool_create(pool, el_struct)
creates a pool of elements
subroutine, public fm_pool_release(pool)
releases the given pool (see cp2k/doc/ReferenceCounting.html)
subroutine, public fm_pool_give_back_fm(pool, element)
returns the element to the pool
subroutine, public fm_pools_dealloc(pools)
deallocate an array of pools (releasing each pool)
type(cp_fm_struct_type) function, pointer, public fm_pool_get_el_struct(pool)
returns the structure of the elements in this pool
represent the structure of a full matrix
subroutine, public cp_fm_struct_retain(fmstruct)
retains a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_sll_fm_insert_el(sll, el)
insert an element at the beginning of the list
logical function, public cp_sll_fm_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
type(cp_fm_type) function, pointer, public cp_sll_fm_get_first_el(sll)
returns the first element stored in the list
subroutine, public cp_sll_fm_dealloc(sll)
deallocates the singly linked list starting at sll. Does not work if loops are present!
subroutine, public cp_sll_fm_rm_first_el(sll)
remove the first element of the linked list
various routines to log and control the output. The idea is that decisions about where to log should ...
to create arrays of pools
represent a pool of elements with the same structure
keeps the information about the structure of a full matrix
just to build arrays of pointers to matrices
represent a single linked list that stores pointers to the elements