16 #include "./base/base_uses.f90"
21 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'negf_green_cache'
22 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .true.
24 PUBLIC :: green_functions_cache_type
34 TYPE green_functions_cache_type
36 TYPE(cp_cfm_type),
ALLOCATABLE,
DIMENSION(:, :) :: g_surf_contacts
41 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: tnodes
42 END TYPE green_functions_cache_type
53 TYPE(green_functions_cache_type),
INTENT(inout) :: cache
54 INTEGER,
INTENT(in) :: ncontacts, nnodes_extra
56 INTEGER :: nentries_exist
58 TYPE(cp_cfm_type),
ALLOCATABLE,
DIMENSION(:, :) :: g_surf_contacts
60 is_alloc =
ALLOCATED(cache%g_surf_contacts)
63 cpassert(
SIZE(cache%g_surf_contacts, 1) == ncontacts)
64 nentries_exist =
SIZE(cache%g_surf_contacts, 2)
70 ALLOCATE (g_surf_contacts(ncontacts, nentries_exist + nnodes_extra))
73 g_surf_contacts(1:ncontacts, 1:nentries_exist) = cache%g_surf_contacts(1:ncontacts, 1:nentries_exist)
74 DEALLOCATE (cache%g_surf_contacts)
77 CALL move_alloc(g_surf_contacts, cache%g_surf_contacts)
87 TYPE(green_functions_cache_type),
INTENT(inout) :: cache
88 REAL(kind=
dp),
DIMENSION(:),
INTENT(in) :: tnodes
90 INTEGER :: ind_new, ind_old, ncontacts, nnodes
91 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indices
92 TYPE(cp_cfm_type),
ALLOCATABLE,
DIMENSION(:, :) :: g_surf_contacts
96 cpassert(
ALLOCATED(cache%g_surf_contacts))
97 cpassert(
SIZE(cache%g_surf_contacts, 2) == nnodes)
99 ncontacts =
SIZE(cache%g_surf_contacts, 1)
101 IF (
ALLOCATED(cache%tnodes))
DEALLOCATE (cache%tnodes)
103 ALLOCATE (g_surf_contacts(ncontacts, nnodes))
104 ALLOCATE (cache%tnodes(nnodes))
105 ALLOCATE (indices(nnodes))
107 cache%tnodes(:) = tnodes(:)
108 CALL sort(cache%tnodes, nnodes, indices)
110 DO ind_new = 1, nnodes
111 ind_old = indices(ind_new)
112 g_surf_contacts(1:ncontacts, ind_new) = cache%g_surf_contacts(1:ncontacts, ind_old)
115 CALL move_alloc(g_surf_contacts, cache%g_surf_contacts)
124 TYPE(green_functions_cache_type),
INTENT(inout) :: cache
126 INTEGER :: icontact, ipoint, ncontacts
128 IF (
ALLOCATED(cache%tnodes))
DEALLOCATE (cache%tnodes)
130 IF (
ALLOCATED(cache%g_surf_contacts))
THEN
131 ncontacts =
SIZE(cache%g_surf_contacts, 1)
132 DO ipoint =
SIZE(cache%g_surf_contacts, 2), 1, -1
133 DO icontact = ncontacts, 1, -1
138 DEALLOCATE (cache%g_surf_contacts)
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
Defines the basic variable types.
integer, parameter, public dp
Storage to keep precomputed surface Green's functions.
subroutine, public green_functions_cache_reorder(cache, tnodes)
Sort cached items in ascending order.
subroutine, public green_functions_cache_release(cache)
Release storage.
subroutine, public green_functions_cache_expand(cache, ncontacts, nnodes_extra)
Reallocate storage so it can handle extra 'nnodes_extra' items for each contact.
All kind of helpful little routines.