(git:374b731)
Loading...
Searching...
No Matches
integration_grid_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7! **************************************************************************************************
9
10 USE kinds, ONLY: dp
11#include "./base/base_uses.f90"
12
13 IMPLICIT NONE
14
15 PRIVATE
16
17 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'integration_grid_types'
18
19 TYPE grid_batch_val_1d_type
20 INTEGER :: np1
21 REAL(KIND=dp), DIMENSION(:), ALLOCATABLE :: val1d
22 END TYPE grid_batch_val_1d_type
23
24 TYPE grid_batch_val_2d_type
25 INTEGER :: np1, np2
26 REAL(KIND=dp), DIMENSION(:, :), ALLOCATABLE :: val2d
27 END TYPE grid_batch_val_2d_type
28
29 TYPE gnlist_type
30 INTEGER, DIMENSION(:), ALLOCATABLE :: atom_list
31 REAL(KIND=dp), DIMENSION(:, :), ALLOCATABLE :: atom_pos
32 END TYPE gnlist_type
33
34 TYPE grid_batch_info_type
35 INTEGER :: np
36 INTEGER :: ref_atom
37 INTEGER :: ibatch
38 TYPE(gnlist_type) :: gnlist
39 REAL(KIND=dp), DIMENSION(3) :: rcenter
40 REAL(KIND=dp) :: radius
41 REAL(dp), DIMENSION(:, :), ALLOCATABLE :: rco
42 REAL(dp), DIMENSION(:), ALLOCATABLE :: weight
43 REAL(dp), DIMENSION(:), ALLOCATABLE :: wref
44 REAL(dp), DIMENSION(:), ALLOCATABLE :: wsum
45 END TYPE grid_batch_info_type
46
48 INTEGER :: nbatch
49 TYPE(grid_batch_info_type), DIMENSION(:), ALLOCATABLE :: grid_batch
51
53 INTEGER :: nbatch
54 TYPE(grid_batch_val_1d_type), DIMENSION(:), ALLOCATABLE :: grid_val_1d
55 TYPE(grid_batch_val_2d_type), DIMENSION(:), ALLOCATABLE :: grid_val_2d
57
60
61! **************************************************************************************************
62
63CONTAINS
64
65! **************************************************************************************************
66!> \brief Initialize integration_grid_type
67!> \param int_grid ...
68!> \date 02.2018
69!> \param
70!> \author JGH
71!> \version 1.0
72! **************************************************************************************************
73 SUBROUTINE allocate_intgrid(int_grid)
74
75 TYPE(integration_grid_type), POINTER :: int_grid
76
77 IF (ASSOCIATED(int_grid)) CALL deallocate_intgrid(int_grid)
78 ALLOCATE (int_grid)
79 int_grid%nbatch = 0
80
81 END SUBROUTINE allocate_intgrid
82
83! **************************************************************************************************
84!> \brief Deallocate integration_grid_type
85!> \param int_grid ...
86!> \date 02.2018
87!> \param
88!> \author JGH
89!> \version 1.0
90! **************************************************************************************************
91 SUBROUTINE deallocate_intgrid(int_grid)
92 TYPE(integration_grid_type), POINTER :: int_grid
93
94 INTEGER :: i
95
96 IF (ASSOCIATED(int_grid)) THEN
97 IF (ALLOCATED(int_grid%grid_batch)) THEN
98 DO i = 1, int_grid%nbatch
99 IF (ALLOCATED(int_grid%grid_batch(i)%rco)) DEALLOCATE (int_grid%grid_batch(i)%rco)
100 IF (ALLOCATED(int_grid%grid_batch(i)%weight)) DEALLOCATE (int_grid%grid_batch(i)%weight)
101 IF (ALLOCATED(int_grid%grid_batch(i)%wref)) DEALLOCATE (int_grid%grid_batch(i)%wref)
102 IF (ALLOCATED(int_grid%grid_batch(i)%wsum)) DEALLOCATE (int_grid%grid_batch(i)%wsum)
103 !
104 IF (ALLOCATED(int_grid%grid_batch(i)%gnlist%atom_list)) DEALLOCATE (int_grid%grid_batch(i)%gnlist%atom_list)
105 IF (ALLOCATED(int_grid%grid_batch(i)%gnlist%atom_pos)) DEALLOCATE (int_grid%grid_batch(i)%gnlist%atom_pos)
106 END DO
107 DEALLOCATE (int_grid%grid_batch)
108 END IF
109 DEALLOCATE (int_grid)
110 ELSE
111 CALL cp_abort(__location__, &
112 "The pointer int_grid is not associated and "// &
113 "cannot be deallocated")
114 END IF
115 END SUBROUTINE deallocate_intgrid
116
117! **************************************************************************************************
118!> \brief Initialize integration_grid_value_type
119!> \param int_grid ...
120!> \date 02.2018
121!> \param
122!> \author JGH
123!> \version 1.0
124! **************************************************************************************************
125 SUBROUTINE allocate_intgrid_val(int_grid)
126
127 TYPE(integration_grid_value_type), POINTER :: int_grid
128
129 IF (ASSOCIATED(int_grid)) CALL deallocate_intgrid_val(int_grid)
130 ALLOCATE (int_grid)
131 int_grid%nbatch = 0
132
133 END SUBROUTINE allocate_intgrid_val
134
135! **************************************************************************************************
136!> \brief Deallocate integration_grid_value_type
137!> \param int_grid ...
138!> \date 02.2018
139!> \param
140!> \author JGH
141!> \version 1.0
142! **************************************************************************************************
143 SUBROUTINE deallocate_intgrid_val(int_grid)
144 TYPE(integration_grid_value_type), POINTER :: int_grid
145
146 INTEGER :: i
147
148 IF (ASSOCIATED(int_grid)) THEN
149 IF (ALLOCATED(int_grid%grid_val_1d)) THEN
150 DO i = 1, int_grid%nbatch
151 IF (ALLOCATED(int_grid%grid_val_1d(i)%val1d)) DEALLOCATE (int_grid%grid_val_1d(i)%val1d)
152 END DO
153 DEALLOCATE (int_grid%grid_val_1d)
154 END IF
155 IF (ALLOCATED(int_grid%grid_val_2d)) THEN
156 DO i = 1, int_grid%nbatch
157 IF (ALLOCATED(int_grid%grid_val_2d(i)%val2d)) DEALLOCATE (int_grid%grid_val_2d(i)%val2d)
158 END DO
159 DEALLOCATE (int_grid%grid_val_2d)
160 END IF
161 DEALLOCATE (int_grid)
162 ELSE
163 CALL cp_abort(__location__, &
164 "The pointer int_grid is not associated and "// &
165 "cannot be deallocated")
166 END IF
167 END SUBROUTINE deallocate_intgrid_val
168
169END MODULE integration_grid_types
subroutine, public deallocate_intgrid(int_grid)
Deallocate integration_grid_type.
subroutine, public allocate_intgrid_val(int_grid)
Initialize integration_grid_value_type.
subroutine, public deallocate_intgrid_val(int_grid)
Deallocate integration_grid_value_type.
subroutine, public allocate_intgrid(int_grid)
Initialize integration_grid_type.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34