56 #include "../base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pw_pool_types'
62 INTEGER,
PARAMETER :: default_max_cache = 75, max_max_cache = 150
64 PUBLIC :: pw_pool_type, pw_pool_p_type
67 pw_pools_create_pws, pw_pools_give_back_pws
84 INTEGER :: ref_count = 0, max_cache = 0
85 TYPE(pw_grid_type),
POINTER :: pw_grid => null()
86 TYPE(cp_sll_1d_r_type),
POINTER :: r1d_array => null()
87 TYPE(cp_sll_3d_r_type),
POINTER :: r3d_array => null()
88 TYPE(cp_sll_1d_c_type),
POINTER :: c1d_array => null()
89 TYPE(cp_sll_3d_c_type),
POINTER :: c3d_array => null()
91 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: retain => pw_pool_retain
92 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_r1d_rs
93 generic,
PUBLIC :: create_pw => pw_pool_create_pw_r1d_rs
94 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_r1d_rs
95 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_r1d_rs
96 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_r3d_rs
97 generic,
PUBLIC :: create_pw => pw_pool_create_pw_r3d_rs
98 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_r3d_rs
99 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_r3d_rs
100 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_c1d_rs
101 generic,
PUBLIC :: create_pw => pw_pool_create_pw_c1d_rs
102 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_c1d_rs
103 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_c1d_rs
104 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_c3d_rs
105 generic,
PUBLIC :: create_pw => pw_pool_create_pw_c3d_rs
106 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_c3d_rs
107 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_c3d_rs
108 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_r1d_gs
109 generic,
PUBLIC :: create_pw => pw_pool_create_pw_r1d_gs
110 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_r1d_gs
111 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_r1d_gs
112 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_r3d_gs
113 generic,
PUBLIC :: create_pw => pw_pool_create_pw_r3d_gs
114 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_r3d_gs
115 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_r3d_gs
116 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_c1d_gs
117 generic,
PUBLIC :: create_pw => pw_pool_create_pw_c1d_gs
118 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_c1d_gs
119 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_c1d_gs
120 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_create_pw_c3d_gs
121 generic,
PUBLIC :: create_pw => pw_pool_create_pw_c3d_gs
122 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: pw_pool_give_back_pw_c3d_gs
123 generic,
PUBLIC :: give_back_pw => pw_pool_give_back_pw_c3d_gs
124 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: create_cr3d => pw_pool_create_cr3d
125 PROCEDURE,
PUBLIC, NON_OVERRIDABLE :: give_back_cr3d => pw_pool_give_back_cr3d
126 END TYPE pw_pool_type
136 TYPE(pw_pool_type),
POINTER :: pool => null()
137 END TYPE pw_pool_p_type
139 INTERFACE pw_pools_create_pws
140 MODULE PROCEDURE pw_pools_create_pws_r1d_rs
141 MODULE PROCEDURE pw_pools_create_pws_r3d_rs
142 MODULE PROCEDURE pw_pools_create_pws_c1d_rs
143 MODULE PROCEDURE pw_pools_create_pws_c3d_rs
144 MODULE PROCEDURE pw_pools_create_pws_r1d_gs
145 MODULE PROCEDURE pw_pools_create_pws_r3d_gs
146 MODULE PROCEDURE pw_pools_create_pws_c1d_gs
147 MODULE PROCEDURE pw_pools_create_pws_c3d_gs
150 INTERFACE pw_pools_give_back_pws
151 MODULE PROCEDURE pw_pools_give_back_pws_r1d_rs
152 MODULE PROCEDURE pw_pools_give_back_pws_r3d_rs
153 MODULE PROCEDURE pw_pools_give_back_pws_c1d_rs
154 MODULE PROCEDURE pw_pools_give_back_pws_c3d_rs
155 MODULE PROCEDURE pw_pools_give_back_pws_r1d_gs
156 MODULE PROCEDURE pw_pools_give_back_pws_r3d_gs
157 MODULE PROCEDURE pw_pools_give_back_pws_c1d_gs
158 MODULE PROCEDURE pw_pools_give_back_pws_c3d_gs
173 TYPE(pw_pool_type),
POINTER :: pool
174 TYPE(pw_grid_type),
POINTER :: pw_grid
175 INTEGER,
OPTIONAL :: max_cache
178 pool%pw_grid => pw_grid
181 pool%max_cache = default_max_cache
182 IF (
PRESENT(max_cache)) pool%max_cache = max_cache
183 pool%max_cache = min(max_max_cache, pool%max_cache)
193 SUBROUTINE pw_pool_retain(pool)
194 CLASS(pw_pool_type),
INTENT(INOUT) :: pool
196 cpassert(pool%ref_count > 0)
198 pool%ref_count = pool%ref_count + 1
199 END SUBROUTINE pw_pool_retain
208 SUBROUTINE pw_pool_flush_cache(pool)
209 TYPE(pw_pool_type),
INTENT(INOUT) :: pool
211 REAL(kind=
dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: r1d_att
212 TYPE(cp_sll_1d_r_type),
POINTER :: r1d_iterator
213 REAL(kind=
dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: r3d_att
214 TYPE(cp_sll_3d_r_type),
POINTER :: r3d_iterator
215 COMPLEX(KIND=dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: c1d_att
216 TYPE(cp_sll_1d_c_type),
POINTER :: c1d_iterator
217 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: c3d_att
218 TYPE(cp_sll_3d_c_type),
POINTER :: c3d_iterator
220 NULLIFY (r1d_iterator, r1d_att)
221 r1d_iterator => pool%r1d_array
223 IF (.NOT. cp_sll_1d_r_next(r1d_iterator, el_att=r1d_att))
EXIT
226 CALL cp_sll_1d_r_dealloc(pool%r1d_array)
227 NULLIFY (r3d_iterator, r3d_att)
228 r3d_iterator => pool%r3d_array
230 IF (.NOT. cp_sll_3d_r_next(r3d_iterator, el_att=r3d_att))
EXIT
233 CALL cp_sll_3d_r_dealloc(pool%r3d_array)
234 NULLIFY (c1d_iterator, c1d_att)
235 c1d_iterator => pool%c1d_array
237 IF (.NOT. cp_sll_1d_c_next(c1d_iterator, el_att=c1d_att))
EXIT
240 CALL cp_sll_1d_c_dealloc(pool%c1d_array)
241 NULLIFY (c3d_iterator, c3d_att)
242 c3d_iterator => pool%c3d_array
249 END SUBROUTINE pw_pool_flush_cache
259 TYPE(pw_pool_type),
POINTER :: pool
261 IF (
ASSOCIATED(pool))
THEN
262 cpassert(pool%ref_count > 0)
263 pool%ref_count = pool%ref_count - 1
264 IF (pool%ref_count == 0)
THEN
265 CALL pw_pool_flush_cache(pool)
284 FUNCTION try_pop_r1d (list)
RESULT(res)
285 TYPE(cp_sll_1d_r_type),
POINTER ::
list
286 REAL(kind=
dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: res
288 IF (
ASSOCIATED(
list))
THEN
289 res => cp_sll_1d_r_get_first_el(
list)
290 CALL cp_sll_1d_r_rm_first_el(
list)
294 END FUNCTION try_pop_r1d
304 SUBROUTINE pw_pool_create_pw_r1d_rs (pool, pw)
305 CLASS(pw_pool_type),
INTENT(IN) :: pool
306 TYPE(pw_r1d_rs_type),
INTENT(OUT) :: pw
308 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
311 REAL(kind=
dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: array_ptr
313 CALL timeset(routinen, handle)
316 array_ptr => try_pop_r1d(pool%r1d_array)
317 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
319 CALL timestop(handle)
321 END SUBROUTINE pw_pool_create_pw_r1d_rs
331 SUBROUTINE pw_pool_give_back_pw_r1d_rs (pool, pw)
332 CLASS(pw_pool_type),
INTENT(IN) :: pool
333 TYPE(pw_r1d_rs_type),
INTENT(INOUT) :: pw
335 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
339 CALL timeset(routinen, handle)
340 IF (
ASSOCIATED(pw%pw_grid))
THEN
342 IF (
ASSOCIATED(pw%array))
THEN
343 IF (cp_sll_1d_r_get_length(pool%r1d_array) < pool%max_cache)
THEN
344 CALL cp_sll_1d_r_insert_el(pool%r1d_array, el=pw%array)
346 ELSE IF (max_max_cache >= 0)
THEN
347 cpwarn(
"hit max_cache")
353 CALL timestop(handle)
354 END SUBROUTINE pw_pool_give_back_pw_r1d_rs
364 SUBROUTINE pw_pools_create_pws_r1d_rs (pools, pws)
365 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
366 TYPE(pw_r1d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
371 ALLOCATE (pws(
SIZE(pools)))
372 DO i = 1,
SIZE(pools)
373 CALL pw_pool_create_pw_r1d_rs (pools(i)%pool, pws(i))
375 END SUBROUTINE pw_pools_create_pws_r1d_rs
385 SUBROUTINE pw_pools_give_back_pws_r1d_rs (pools, pws)
386 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
387 TYPE(pw_r1d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
392 cpassert(
SIZE(pws) ==
SIZE(pools))
393 DO i = 1,
SIZE(pools)
394 CALL pw_pool_give_back_pw_r1d_rs (pools(i)%pool, pws(i))
397 END SUBROUTINE pw_pools_give_back_pws_r1d_rs
406 SUBROUTINE pw_pool_create_pw_r1d_gs (pool, pw)
407 CLASS(pw_pool_type),
INTENT(IN) :: pool
408 TYPE(pw_r1d_gs_type),
INTENT(OUT) :: pw
410 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
413 REAL(kind=
dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: array_ptr
415 CALL timeset(routinen, handle)
418 array_ptr => try_pop_r1d(pool%r1d_array)
419 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
421 CALL timestop(handle)
423 END SUBROUTINE pw_pool_create_pw_r1d_gs
433 SUBROUTINE pw_pool_give_back_pw_r1d_gs (pool, pw)
434 CLASS(pw_pool_type),
INTENT(IN) :: pool
435 TYPE(pw_r1d_gs_type),
INTENT(INOUT) :: pw
437 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
441 CALL timeset(routinen, handle)
442 IF (
ASSOCIATED(pw%pw_grid))
THEN
444 IF (
ASSOCIATED(pw%array))
THEN
445 IF (cp_sll_1d_r_get_length(pool%r1d_array) < pool%max_cache)
THEN
446 CALL cp_sll_1d_r_insert_el(pool%r1d_array, el=pw%array)
448 ELSE IF (max_max_cache >= 0)
THEN
449 cpwarn(
"hit max_cache")
455 CALL timestop(handle)
456 END SUBROUTINE pw_pool_give_back_pw_r1d_gs
466 SUBROUTINE pw_pools_create_pws_r1d_gs (pools, pws)
467 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
468 TYPE(pw_r1d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
473 ALLOCATE (pws(
SIZE(pools)))
474 DO i = 1,
SIZE(pools)
475 CALL pw_pool_create_pw_r1d_gs (pools(i)%pool, pws(i))
477 END SUBROUTINE pw_pools_create_pws_r1d_gs
487 SUBROUTINE pw_pools_give_back_pws_r1d_gs (pools, pws)
488 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
489 TYPE(pw_r1d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
494 cpassert(
SIZE(pws) ==
SIZE(pools))
495 DO i = 1,
SIZE(pools)
496 CALL pw_pool_give_back_pw_r1d_gs (pools(i)%pool, pws(i))
499 END SUBROUTINE pw_pools_give_back_pws_r1d_gs
510 FUNCTION try_pop_r3d (list)
RESULT(res)
511 TYPE(cp_sll_3d_r_type),
POINTER ::
list
512 REAL(kind=
dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: res
514 IF (
ASSOCIATED(
list))
THEN
515 res => cp_sll_3d_r_get_first_el(
list)
516 CALL cp_sll_3d_r_rm_first_el(
list)
520 END FUNCTION try_pop_r3d
530 SUBROUTINE pw_pool_create_pw_r3d_rs (pool, pw)
531 CLASS(pw_pool_type),
INTENT(IN) :: pool
532 TYPE(pw_r3d_rs_type),
INTENT(OUT) :: pw
534 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
537 REAL(kind=
dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: array_ptr
539 CALL timeset(routinen, handle)
542 array_ptr => try_pop_r3d(pool%r3d_array)
543 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
545 CALL timestop(handle)
547 END SUBROUTINE pw_pool_create_pw_r3d_rs
557 SUBROUTINE pw_pool_give_back_pw_r3d_rs (pool, pw)
558 CLASS(pw_pool_type),
INTENT(IN) :: pool
559 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: pw
561 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
565 CALL timeset(routinen, handle)
566 IF (
ASSOCIATED(pw%pw_grid))
THEN
568 IF (
ASSOCIATED(pw%array))
THEN
569 IF (cp_sll_3d_r_get_length(pool%r3d_array) < pool%max_cache)
THEN
570 CALL cp_sll_3d_r_insert_el(pool%r3d_array, el=pw%array)
572 ELSE IF (max_max_cache >= 0)
THEN
573 cpwarn(
"hit max_cache")
579 CALL timestop(handle)
580 END SUBROUTINE pw_pool_give_back_pw_r3d_rs
590 SUBROUTINE pw_pools_create_pws_r3d_rs (pools, pws)
591 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
592 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
597 ALLOCATE (pws(
SIZE(pools)))
598 DO i = 1,
SIZE(pools)
599 CALL pw_pool_create_pw_r3d_rs (pools(i)%pool, pws(i))
601 END SUBROUTINE pw_pools_create_pws_r3d_rs
611 SUBROUTINE pw_pools_give_back_pws_r3d_rs (pools, pws)
612 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
613 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
618 cpassert(
SIZE(pws) ==
SIZE(pools))
619 DO i = 1,
SIZE(pools)
620 CALL pw_pool_give_back_pw_r3d_rs (pools(i)%pool, pws(i))
623 END SUBROUTINE pw_pools_give_back_pws_r3d_rs
632 SUBROUTINE pw_pool_create_pw_r3d_gs (pool, pw)
633 CLASS(pw_pool_type),
INTENT(IN) :: pool
634 TYPE(pw_r3d_gs_type),
INTENT(OUT) :: pw
636 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
639 REAL(kind=
dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: array_ptr
641 CALL timeset(routinen, handle)
644 array_ptr => try_pop_r3d(pool%r3d_array)
645 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
647 CALL timestop(handle)
649 END SUBROUTINE pw_pool_create_pw_r3d_gs
659 SUBROUTINE pw_pool_give_back_pw_r3d_gs (pool, pw)
660 CLASS(pw_pool_type),
INTENT(IN) :: pool
661 TYPE(pw_r3d_gs_type),
INTENT(INOUT) :: pw
663 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
667 CALL timeset(routinen, handle)
668 IF (
ASSOCIATED(pw%pw_grid))
THEN
670 IF (
ASSOCIATED(pw%array))
THEN
671 IF (cp_sll_3d_r_get_length(pool%r3d_array) < pool%max_cache)
THEN
672 CALL cp_sll_3d_r_insert_el(pool%r3d_array, el=pw%array)
674 ELSE IF (max_max_cache >= 0)
THEN
675 cpwarn(
"hit max_cache")
681 CALL timestop(handle)
682 END SUBROUTINE pw_pool_give_back_pw_r3d_gs
692 SUBROUTINE pw_pools_create_pws_r3d_gs (pools, pws)
693 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
694 TYPE(pw_r3d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
699 ALLOCATE (pws(
SIZE(pools)))
700 DO i = 1,
SIZE(pools)
701 CALL pw_pool_create_pw_r3d_gs (pools(i)%pool, pws(i))
703 END SUBROUTINE pw_pools_create_pws_r3d_gs
713 SUBROUTINE pw_pools_give_back_pws_r3d_gs (pools, pws)
714 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
715 TYPE(pw_r3d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
720 cpassert(
SIZE(pws) ==
SIZE(pools))
721 DO i = 1,
SIZE(pools)
722 CALL pw_pool_give_back_pw_r3d_gs (pools(i)%pool, pws(i))
725 END SUBROUTINE pw_pools_give_back_pws_r3d_gs
736 FUNCTION try_pop_c1d (list)
RESULT(res)
737 TYPE(cp_sll_1d_c_type),
POINTER ::
list
738 COMPLEX(KIND=dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: res
740 IF (
ASSOCIATED(
list))
THEN
741 res => cp_sll_1d_c_get_first_el(
list)
742 CALL cp_sll_1d_c_rm_first_el(
list)
746 END FUNCTION try_pop_c1d
756 SUBROUTINE pw_pool_create_pw_c1d_rs (pool, pw)
757 CLASS(pw_pool_type),
INTENT(IN) :: pool
758 TYPE(pw_c1d_rs_type),
INTENT(OUT) :: pw
760 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
763 COMPLEX(KIND=dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: array_ptr
765 CALL timeset(routinen, handle)
768 array_ptr => try_pop_c1d(pool%c1d_array)
769 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
771 CALL timestop(handle)
773 END SUBROUTINE pw_pool_create_pw_c1d_rs
783 SUBROUTINE pw_pool_give_back_pw_c1d_rs (pool, pw)
784 CLASS(pw_pool_type),
INTENT(IN) :: pool
785 TYPE(pw_c1d_rs_type),
INTENT(INOUT) :: pw
787 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
791 CALL timeset(routinen, handle)
792 IF (
ASSOCIATED(pw%pw_grid))
THEN
794 IF (
ASSOCIATED(pw%array))
THEN
795 IF (cp_sll_1d_c_get_length(pool%c1d_array) < pool%max_cache)
THEN
796 CALL cp_sll_1d_c_insert_el(pool%c1d_array, el=pw%array)
798 ELSE IF (max_max_cache >= 0)
THEN
799 cpwarn(
"hit max_cache")
805 CALL timestop(handle)
806 END SUBROUTINE pw_pool_give_back_pw_c1d_rs
816 SUBROUTINE pw_pools_create_pws_c1d_rs (pools, pws)
817 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
818 TYPE(pw_c1d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
823 ALLOCATE (pws(
SIZE(pools)))
824 DO i = 1,
SIZE(pools)
825 CALL pw_pool_create_pw_c1d_rs (pools(i)%pool, pws(i))
827 END SUBROUTINE pw_pools_create_pws_c1d_rs
837 SUBROUTINE pw_pools_give_back_pws_c1d_rs (pools, pws)
838 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
839 TYPE(pw_c1d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
844 cpassert(
SIZE(pws) ==
SIZE(pools))
845 DO i = 1,
SIZE(pools)
846 CALL pw_pool_give_back_pw_c1d_rs (pools(i)%pool, pws(i))
849 END SUBROUTINE pw_pools_give_back_pws_c1d_rs
858 SUBROUTINE pw_pool_create_pw_c1d_gs (pool, pw)
859 CLASS(pw_pool_type),
INTENT(IN) :: pool
860 TYPE(pw_c1d_gs_type),
INTENT(OUT) :: pw
862 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
865 COMPLEX(KIND=dp),
DIMENSION(:),
CONTIGUOUS,
POINTER :: array_ptr
867 CALL timeset(routinen, handle)
870 array_ptr => try_pop_c1d(pool%c1d_array)
871 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
873 CALL timestop(handle)
875 END SUBROUTINE pw_pool_create_pw_c1d_gs
885 SUBROUTINE pw_pool_give_back_pw_c1d_gs (pool, pw)
886 CLASS(pw_pool_type),
INTENT(IN) :: pool
887 TYPE(pw_c1d_gs_type),
INTENT(INOUT) :: pw
889 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
893 CALL timeset(routinen, handle)
894 IF (
ASSOCIATED(pw%pw_grid))
THEN
896 IF (
ASSOCIATED(pw%array))
THEN
897 IF (cp_sll_1d_c_get_length(pool%c1d_array) < pool%max_cache)
THEN
898 CALL cp_sll_1d_c_insert_el(pool%c1d_array, el=pw%array)
900 ELSE IF (max_max_cache >= 0)
THEN
901 cpwarn(
"hit max_cache")
907 CALL timestop(handle)
908 END SUBROUTINE pw_pool_give_back_pw_c1d_gs
918 SUBROUTINE pw_pools_create_pws_c1d_gs (pools, pws)
919 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
920 TYPE(pw_c1d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
925 ALLOCATE (pws(
SIZE(pools)))
926 DO i = 1,
SIZE(pools)
927 CALL pw_pool_create_pw_c1d_gs (pools(i)%pool, pws(i))
929 END SUBROUTINE pw_pools_create_pws_c1d_gs
939 SUBROUTINE pw_pools_give_back_pws_c1d_gs (pools, pws)
940 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
941 TYPE(pw_c1d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
946 cpassert(
SIZE(pws) ==
SIZE(pools))
947 DO i = 1,
SIZE(pools)
948 CALL pw_pool_give_back_pw_c1d_gs (pools(i)%pool, pws(i))
951 END SUBROUTINE pw_pools_give_back_pws_c1d_gs
962 FUNCTION try_pop_c3d (list)
RESULT(res)
963 TYPE(cp_sll_3d_c_type),
POINTER ::
list
964 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: res
966 IF (
ASSOCIATED(
list))
THEN
972 END FUNCTION try_pop_c3d
982 SUBROUTINE pw_pool_create_pw_c3d_rs (pool, pw)
983 CLASS(pw_pool_type),
INTENT(IN) :: pool
984 TYPE(pw_c3d_rs_type),
INTENT(OUT) :: pw
986 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
989 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: array_ptr
991 CALL timeset(routinen, handle)
994 array_ptr => try_pop_c3d(pool%c3d_array)
995 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
997 CALL timestop(handle)
999 END SUBROUTINE pw_pool_create_pw_c3d_rs
1009 SUBROUTINE pw_pool_give_back_pw_c3d_rs (pool, pw)
1010 CLASS(pw_pool_type),
INTENT(IN) :: pool
1011 TYPE(pw_c3d_rs_type),
INTENT(INOUT) :: pw
1013 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
1017 CALL timeset(routinen, handle)
1018 IF (
ASSOCIATED(pw%pw_grid))
THEN
1020 IF (
ASSOCIATED(pw%array))
THEN
1024 ELSE IF (max_max_cache >= 0)
THEN
1025 cpwarn(
"hit max_cache")
1031 CALL timestop(handle)
1032 END SUBROUTINE pw_pool_give_back_pw_c3d_rs
1042 SUBROUTINE pw_pools_create_pws_c3d_rs (pools, pws)
1043 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
1044 TYPE(pw_c3d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
1049 ALLOCATE (pws(
SIZE(pools)))
1050 DO i = 1,
SIZE(pools)
1051 CALL pw_pool_create_pw_c3d_rs (pools(i)%pool, pws(i))
1053 END SUBROUTINE pw_pools_create_pws_c3d_rs
1063 SUBROUTINE pw_pools_give_back_pws_c3d_rs (pools, pws)
1064 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
1065 TYPE(pw_c3d_rs_type),
ALLOCATABLE,
DIMENSION(:), &
1066 INTENT(INOUT) :: pws
1070 cpassert(
SIZE(pws) ==
SIZE(pools))
1071 DO i = 1,
SIZE(pools)
1072 CALL pw_pool_give_back_pw_c3d_rs (pools(i)%pool, pws(i))
1075 END SUBROUTINE pw_pools_give_back_pws_c3d_rs
1084 SUBROUTINE pw_pool_create_pw_c3d_gs (pool, pw)
1085 CLASS(pw_pool_type),
INTENT(IN) :: pool
1086 TYPE(pw_c3d_gs_type),
INTENT(OUT) :: pw
1088 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_create_pw'
1091 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
CONTIGUOUS,
POINTER :: array_ptr
1093 CALL timeset(routinen, handle)
1096 array_ptr => try_pop_c3d(pool%c3d_array)
1097 CALL pw%create(pool%pw_grid, array_ptr=array_ptr)
1099 CALL timestop(handle)
1101 END SUBROUTINE pw_pool_create_pw_c3d_gs
1111 SUBROUTINE pw_pool_give_back_pw_c3d_gs (pool, pw)
1112 CLASS(pw_pool_type),
INTENT(IN) :: pool
1113 TYPE(pw_c3d_gs_type),
INTENT(INOUT) :: pw
1115 CHARACTER(len=*),
PARAMETER :: routinen =
'pw_pool_give_back_pw'
1119 CALL timeset(routinen, handle)
1120 IF (
ASSOCIATED(pw%pw_grid))
THEN
1122 IF (
ASSOCIATED(pw%array))
THEN
1126 ELSE IF (max_max_cache >= 0)
THEN
1127 cpwarn(
"hit max_cache")
1133 CALL timestop(handle)
1134 END SUBROUTINE pw_pool_give_back_pw_c3d_gs
1144 SUBROUTINE pw_pools_create_pws_c3d_gs (pools, pws)
1145 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
1146 TYPE(pw_c3d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
1151 ALLOCATE (pws(
SIZE(pools)))
1152 DO i = 1,
SIZE(pools)
1153 CALL pw_pool_create_pw_c3d_gs (pools(i)%pool, pws(i))
1155 END SUBROUTINE pw_pools_create_pws_c3d_gs
1165 SUBROUTINE pw_pools_give_back_pws_c3d_gs (pools, pws)
1166 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: pools
1167 TYPE(pw_c3d_gs_type),
ALLOCATABLE,
DIMENSION(:), &
1168 INTENT(INOUT) :: pws
1172 cpassert(
SIZE(pws) ==
SIZE(pools))
1173 DO i = 1,
SIZE(pools)
1174 CALL pw_pool_give_back_pw_c3d_gs (pools(i)%pool, pws(i))
1177 END SUBROUTINE pw_pools_give_back_pws_c3d_gs
1188 SUBROUTINE pw_pool_create_cr3d(pw_pool, cr3d)
1189 CLASS(pw_pool_type),
INTENT(IN) :: pw_pool
1190 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: cr3d
1192 IF (
ASSOCIATED(pw_pool%r3d_array))
THEN
1193 cr3d => cp_sll_3d_r_get_first_el(pw_pool%r3d_array)
1194 CALL cp_sll_3d_r_rm_first_el(pw_pool%r3d_array)
1196 IF (.NOT.
ASSOCIATED(cr3d))
THEN
1197 ALLOCATE (cr3d(pw_pool%pw_grid%bounds_local(1, 1):pw_pool%pw_grid%bounds_local(2, 1), &
1198 pw_pool%pw_grid%bounds_local(1, 2):pw_pool%pw_grid%bounds_local(2, 2), &
1199 pw_pool%pw_grid%bounds_local(1, 3):pw_pool%pw_grid%bounds_local(2, 3)))
1201 END SUBROUTINE pw_pool_create_cr3d
1212 SUBROUTINE pw_pool_give_back_cr3d(pw_pool, cr3d)
1213 CLASS(pw_pool_type),
INTENT(IN) :: pw_pool
1214 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
1217 LOGICAL :: compatible
1219 IF (
ASSOCIATED(cr3d))
THEN
1220 compatible = all(merge(pw_pool%pw_grid%bounds_local(1, :) == lbound(cr3d) .AND. &
1221 pw_pool%pw_grid%bounds_local(2, :) == ubound(cr3d), &
1222 pw_pool%pw_grid%bounds_local(2, :) < pw_pool%pw_grid%bounds_local(1, :), &
1223 ubound(cr3d) >= lbound(cr3d)))
1224 IF (compatible)
THEN
1225 IF (cp_sll_3d_r_get_length(pw_pool%r3d_array) < pw_pool%max_cache)
THEN
1226 CALL cp_sll_3d_r_insert_el(pw_pool%r3d_array, el=cr3d)
1228 IF (max_max_cache >= 0) &
1229 cpwarn(
"hit max_cache")
1237 END SUBROUTINE pw_pool_give_back_cr3d
1248 TYPE(pw_pool_p_type),
DIMENSION(:),
INTENT(IN) :: source_pools
1249 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: target_pools
1253 ALLOCATE (target_pools(
SIZE(source_pools)))
1254 DO i = 1,
SIZE(source_pools)
1255 target_pools(i)%pool => source_pools(i)%pool
1256 CALL source_pools(i)%pool%retain()
1269 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pools
1273 IF (
ASSOCIATED(pools))
THEN
1274 DO i = 1,
SIZE(pools)
integer function, public cp_sll_1d_r_get_length(sll)
returns the length of the list
subroutine, public cp_sll_1d_c_dealloc(sll)
deallocates the singly linked list starting at sll. Does not work if loops are present!
integer function, public cp_sll_3d_r_get_length(sll)
returns the length of the list
integer function, public cp_sll_3d_c_get_length(sll)
returns the length of the list
subroutine, public cp_sll_1d_r_rm_first_el(sll)
remove the first element of the linked list
subroutine, public cp_sll_1d_r_dealloc(sll)
deallocates the singly linked list starting at sll. Does not work if loops are present!
subroutine, public cp_sll_1d_c_insert_el(sll, el)
insert an element at the beginning of the list
subroutine, public cp_sll_3d_c_rm_first_el(sll)
remove the first element of the linked list
real(kind=dp) function, dimension(:), pointer, contiguous, public cp_sll_1d_r_get_first_el(sll)
returns the first element stored in the list
logical function, public cp_sll_3d_c_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
logical function, public cp_sll_1d_r_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
complex(kind=dp) function, dimension(:), pointer, contiguous, public cp_sll_1d_c_get_first_el(sll)
returns the first element stored in the list
subroutine, public cp_sll_3d_r_insert_el(sll, el)
insert an element at the beginning of the list
subroutine, public cp_sll_1d_c_rm_first_el(sll)
remove the first element of the linked list
subroutine, public cp_sll_3d_c_dealloc(sll)
deallocates the singly linked list starting at sll. Does not work if loops are present!
logical function, public cp_sll_3d_r_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
integer function, public cp_sll_1d_c_get_length(sll)
returns the length of the list
complex(kind=dp) function, dimension(:,:,:), pointer, contiguous, public cp_sll_3d_c_get_first_el(sll)
returns the first element stored in the list
real(kind=dp) function, dimension(:,:,:), pointer, contiguous, public cp_sll_3d_r_get_first_el(sll)
returns the first element stored in the list
subroutine, public cp_sll_1d_r_insert_el(sll, el)
insert an element at the beginning of the list
subroutine, public cp_sll_3d_c_insert_el(sll, el)
insert an element at the beginning of the list
subroutine, public cp_sll_3d_r_rm_first_el(sll)
remove the first element of the linked list
subroutine, public cp_sll_3d_r_dealloc(sll)
deallocates the singly linked list starting at sll. Does not work if loops are present!
logical function, public cp_sll_1d_c_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
Defines the basic variable types.
integer, parameter, public dp
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
This module defines the grid data type and some basic operations on it.
logical function, public pw_grid_compare(grida, gridb)
Check if two pw_grids are equal.
subroutine, public pw_grid_release(pw_grid)
releases the given pw grid
subroutine, public pw_grid_retain(pw_grid)
retains the given pw grid
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public pw_pools_dealloc(pools)
deallocates the given pools (releasing each of the underlying pools)
subroutine, public pw_pools_copy(source_pools, target_pools)
copies a multigrid pool, the underlying pools are shared
subroutine, public pw_pool_release(pool)
releases the given pool (see cp2k/doc/ReferenceCounting.html)
subroutine, public pw_pool_create(pool, pw_grid, max_cache)
creates a pool for pw