Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \par History
10 : !> JGH (20-12-2000) : Parallel data layout
11 : !> \author APSI
12 : ! **************************************************************************************************
13 : MODULE pw_grid_types
14 :
15 : USE kinds, ONLY: dp,&
16 : int_8
17 : USE message_passing, ONLY: mp_cart_type
18 : #include "../base/base_uses.f90"
19 :
20 : IMPLICIT NONE
21 :
22 : PRIVATE
23 : PUBLIC :: pw_grid_type, map_pn
24 :
25 : ! (only for reciprocal grid:) fill in half or full space
26 : INTEGER, PARAMETER, PUBLIC :: HALFSPACE = 211, FULLSPACE = 212
27 : INTEGER, PARAMETER, PUBLIC :: PW_MODE_LOCAL = 0, PW_MODE_DISTRIBUTED = 1
28 :
29 : ! maps to positive and negative g-vectors
30 : ! **************************************************************************************************
31 : TYPE map_pn
32 : INTEGER, DIMENSION(:), ALLOCATABLE :: pos, neg
33 : END TYPE map_pn
34 :
35 : ! info on parallelisation
36 : ! contains only significant information if mode == PW_MODE_DISTRIBUTED
37 : ! **************************************************************************************************
38 : TYPE pw_para_type
39 : INTEGER :: mode = PW_MODE_LOCAL ! 0 = local = PW_MODE_LOCAL ; 1 = distributed = PW_MODE_DISTRIBUTED
40 : LOGICAL :: ray_distribution = .FALSE. ! block or pencil distribution
41 : LOGICAL :: blocked = .FALSE. ! block or pencil distribution
42 : INTEGER, DIMENSION(:, :, :), ALLOCATABLE :: yzp ! g-space rays (xy,k,pe)
43 : INTEGER, DIMENSION(:, :), ALLOCATABLE :: yzq ! local inverse pointer of yzp
44 : INTEGER, DIMENSION(:), ALLOCATABLE :: nyzray ! number of g-space rays (pe)
45 : TYPE(mp_cart_type) :: group = mp_cart_type() ! real space group (2-dim cart)
46 : INTEGER, DIMENSION(:, :, :, :), ALLOCATABLE :: bo ! list of axis distribution
47 : INTEGER, DIMENSION(:), ALLOCATABLE :: pos_of_x ! what my_pos holds a given x plane....should go: hard-codes to plane distributed
48 : END TYPE pw_para_type
49 :
50 : ! all you always wanted to know about grids, but were...
51 : ! **************************************************************************************************
52 : TYPE pw_grid_type
53 : INTEGER(int_8) :: ngpts = 0_int_8 ! # grid points
54 : INTEGER(int_8) :: ngpts_cut = 0_int_8 ! # grid points within cutoff
55 : INTEGER, DIMENSION(2, 3) :: bounds = 0 ! lower and upper bounds
56 : INTEGER, DIMENSION(3) :: npts = 0 ! # point in all directions
57 : INTEGER :: ngpts_local = 0 ! # grid points
58 : INTEGER :: ngpts_cut_local = 0 ! # grid points within cutoff
59 : INTEGER, DIMENSION(2, 3) :: bounds_local = 0 ! bounds on local process
60 : INTEGER, DIMENSION(3) :: npts_local = 0 ! local version of npts
61 : REAL(KIND=dp), DIMENSION(3) :: dr = 0.0_dp ! grid spacing
62 : REAL(KIND=dp), DIMENSION(3, 3) :: dh = 0.0_dp ! incremental cell matrix
63 : REAL(KIND=dp), DIMENSION(3, 3) :: dh_inv = 0.0_dp ! inverse incremental cell matrix
64 : LOGICAL :: orthorhombic = .TRUE. ! cell symmetry
65 : REAL(KIND=dp) :: dvol = 0.0_dp, vol = 0.0_dp ! volume element, volume
66 : REAL(KIND=dp) :: cutoff = 0.0_dp ! cutoff in a.u.
67 : TYPE(map_pn) :: mapl = map_pn(), mapm = map_pn(), mapn = map_pn() ! mapping 1D => 3D
68 : TYPE(pw_para_type) :: para = pw_para_type() ! information on parallelisation
69 : REAL(KIND=dp), DIMENSION(:, :), POINTER, CONTIGUOUS :: g => NULL() ! grid point vectors
70 : REAL(KIND=dp), DIMENSION(:), POINTER, CONTIGUOUS :: gsq => NULL() ! squared vector lengths
71 : INTEGER, DIMENSION(:, :), ALLOCATABLE :: g_hat ! grid point indices (Miller)
72 : INTEGER, DIMENSION(:, :), POINTER, CONTIGUOUS :: g_hatmap => NULL() ! mapped grid point indices (Miller) [CUDA]
73 : INTEGER :: grid_span = FULLSPACE ! type HALFSPACE/FULLSPACE
74 : LOGICAL :: have_g0 = .TRUE. ! whether I have G = [0,0,0]
75 : INTEGER :: first_gne0 = 0 ! first g index /= 0 [1/2]
76 : INTEGER :: id_nr = -1 ! tag of this grid
77 : INTEGER :: reference = 0 ! reference grid identifier
78 : INTEGER, DIMENSION(:), POINTER :: gidx => NULL() ! ref grid index
79 : INTEGER :: ref_count = 0 ! reference count
80 : LOGICAL :: spherical = .FALSE. ! spherical cutoff?
81 : COMPLEX(KIND=dp), DIMENSION(:, :), CONTIGUOUS, POINTER :: grays => NULL() ! used by parallel 3D FFT routine
82 : END TYPE pw_grid_type
83 :
84 0 : END MODULE pw_grid_types
85 :
|