29#include "../base/base_uses.f90"
34 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
35 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_fm_pool_types'
58 INTEGER :: ref_count = -1
75 MODULE PROCEDURE fm_pools_create_fm_m1_p_type_pointer
76 MODULE PROCEDURE fm_pools_create_fm_m1_p_type_alloc
77 MODULE PROCEDURE fm_pools_create_fm_m1_array_pointer
78 MODULE PROCEDURE fm_pools_create_fm_m1_array_alloc
82 MODULE PROCEDURE fm_pools_give_back_fm_m1_p_type_pointer
83 MODULE PROCEDURE fm_pools_give_back_fm_m1_p_type_alloc
84 MODULE PROCEDURE fm_pools_give_back_fm_m1_array_pointer
85 MODULE PROCEDURE fm_pools_give_back_fm_m1_array_alloc
104 pool%el_struct => el_struct
120 cpassert(pool%ref_count > 0)
122 pool%ref_count = pool%ref_count + 1
132 SUBROUTINE fm_pool_flush_cache(pool)
138 iterator => pool%cache
146 END SUBROUTINE fm_pool_flush_cache
158 IF (
ASSOCIATED(pool))
THEN
159 cpassert(pool%ref_count > 0)
160 pool%ref_count = pool%ref_count - 1
161 IF (pool%ref_count == 0)
THEN
163 CALL fm_pool_flush_cache(pool)
187 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
192 IF (
ASSOCIATED(pool%cache))
THEN
196 IF (
ASSOCIATED(el))
THEN
200 CALL cp_fm_create(element, matrix_struct=pool%el_struct)
203 IF (
PRESENT(name))
THEN
227 IF (.NOT.
ASSOCIATED(pool%el_struct, element%matrix_struct))
THEN
235 NULLIFY (element%matrix_struct, element%local_data, element%local_data_sp)
250 TYPE(cp_fm_struct_type),
POINTER :: res
252 res => pool%el_struct
265 SUBROUTINE fm_pools_copy(source_pools, target_pools)
270 cpassert(
ASSOCIATED(source_pools))
271 ALLOCATE (target_pools(
SIZE(source_pools)))
272 DO i = 1,
SIZE(source_pools)
273 target_pools(i)%pool => source_pools(i)%pool
276 END SUBROUTINE fm_pools_copy
290 IF (
ASSOCIATED(pools))
THEN
291 DO i = 1,
SIZE(pools)
308 SUBROUTINE fm_pools_create_fm_m1_array_alloc (pools, elements, &
311 TYPE(cp_fm_type),
DIMENSION(:),
ALLOCATABLE :: elements
312 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
319 ALLOCATE (elements(
SIZE(pools)))
320 DO i = 1,
SIZE(pools)
321 pool => pools(i)%pool
322 IF (
PRESENT(name))
THEN
324 name=name//
"-"//adjustl(cp_to_string(i)))
331 END SUBROUTINE fm_pools_create_fm_m1_array_alloc
344 SUBROUTINE fm_pools_give_back_fm_m1_array_alloc (pools, elements)
346 TYPE(cp_fm_type),
DIMENSION(:),
ALLOCATABLE :: elements
350 IF (
ALLOCATED (elements))
THEN
351 cpassert(
SIZE(pools) ==
SIZE(elements))
352 DO i = 1,
SIZE(pools)
356 DEALLOCATE (elements)
358 END SUBROUTINE fm_pools_give_back_fm_m1_array_alloc
368 SUBROUTINE fm_pools_create_fm_m1_array_pointer (pools, elements, &
371 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: elements
372 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
379 ALLOCATE (elements(
SIZE(pools)))
380 DO i = 1,
SIZE(pools)
381 pool => pools(i)%pool
382 IF (
PRESENT(name))
THEN
384 name=name//
"-"//adjustl(cp_to_string(i)))
391 END SUBROUTINE fm_pools_create_fm_m1_array_pointer
404 SUBROUTINE fm_pools_give_back_fm_m1_array_pointer (pools, elements)
406 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: elements
410 IF (
ASSOCIATED (elements))
THEN
411 cpassert(
SIZE(pools) ==
SIZE(elements))
412 DO i = 1,
SIZE(pools)
416 DEALLOCATE (elements)
419 END SUBROUTINE fm_pools_give_back_fm_m1_array_pointer
429 SUBROUTINE fm_pools_create_fm_m1_p_type_alloc (pools, elements, &
432 TYPE(cp_fm_p_type),
DIMENSION(:),
ALLOCATABLE :: elements
433 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
440 ALLOCATE (elements(
SIZE(pools)))
441 DO i = 1,
SIZE(pools)
442 pool => pools(i)%pool
443 ALLOCATE (elements(i)%matrix)
444 IF (
PRESENT(name))
THEN
446 name=name//
"-"//adjustl(cp_to_string(i)))
453 END SUBROUTINE fm_pools_create_fm_m1_p_type_alloc
466 SUBROUTINE fm_pools_give_back_fm_m1_p_type_alloc (pools, elements)
468 TYPE(cp_fm_p_type),
DIMENSION(:),
ALLOCATABLE :: elements
472 IF (
ALLOCATED (elements))
THEN
473 cpassert(
SIZE(pools) ==
SIZE(elements))
474 DO i = 1,
SIZE(pools)
477 DEALLOCATE (elements(i)%matrix)
479 DEALLOCATE (elements)
481 END SUBROUTINE fm_pools_give_back_fm_m1_p_type_alloc
491 SUBROUTINE fm_pools_create_fm_m1_p_type_pointer (pools, elements, &
494 TYPE(cp_fm_p_type),
DIMENSION(:),
POINTER :: elements
495 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: name
502 ALLOCATE (elements(
SIZE(pools)))
503 DO i = 1,
SIZE(pools)
504 pool => pools(i)%pool
505 ALLOCATE (elements(i)%matrix)
506 IF (
PRESENT(name))
THEN
508 name=name//
"-"//adjustl(cp_to_string(i)))
515 END SUBROUTINE fm_pools_create_fm_m1_p_type_pointer
528 SUBROUTINE fm_pools_give_back_fm_m1_p_type_pointer (pools, elements)
530 TYPE(cp_fm_p_type),
DIMENSION(:),
POINTER :: elements
534 IF (
ASSOCIATED (elements))
THEN
535 cpassert(
SIZE(pools) ==
SIZE(elements))
536 DO i = 1,
SIZE(pools)
539 DEALLOCATE (elements(i)%matrix)
541 DEALLOCATE (elements)
544 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_pool_retain(pool)
retains the pool (see cp2k/doc/ReferenceCounting.html)
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, use_sp)
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