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 : MODULE cp_dlaf_utils_api
9 :
10 : #include "../base/base_uses.f90"
11 :
12 : #if defined(__DLAF)
13 : USE dlaf_fortran, ONLY: dlaf_create_grid_from_blacs, &
14 : dlaf_finalize, &
15 : dlaf_free_grid, &
16 : dlaf_free_all_grids, &
17 : dlaf_initialize
18 : #endif
19 :
20 : IMPLICIT NONE
21 :
22 : PRIVATE
23 :
24 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_dlaf_utils_api'
25 :
26 : PUBLIC :: cp_dlaf_initialize, cp_dlaf_finalize
27 : PUBLIC :: cp_dlaf_create_grid, cp_dlaf_free_grid, cp_dlaf_free_all_grids
28 :
29 : CONTAINS
30 :
31 : ! **************************************************************************************************
32 : !> \brief Initialize DLA-Future and pika runtime
33 : !> \author Rocco Meli
34 : !> \author Mikael Simberg
35 : !> \author Mathieu Taillefumier
36 : ! **************************************************************************************************
37 0 : SUBROUTINE cp_dlaf_initialize()
38 : CHARACTER(len=*), PARAMETER :: routineN = 'cp_dlaf_initialize'
39 :
40 : INTEGER :: handle
41 :
42 0 : CALL timeset(routineN, handle)
43 : #if defined(__DLAF)
44 : CALL dlaf_initialize()
45 : #endif
46 0 : CALL timestop(handle)
47 0 : END SUBROUTINE cp_dlaf_initialize
48 :
49 : ! **************************************************************************************************
50 : !> \brief Finalize DLA-Future and pika runtime
51 : !> \author Rocco Meli
52 : !> \author Mikael Simberg
53 : !> \author Mathieu Taillefumier
54 : ! **************************************************************************************************
55 9238 : SUBROUTINE cp_dlaf_finalize()
56 : CHARACTER(len=*), PARAMETER :: routineN = 'cp_dlaf_finalize'
57 :
58 : INTEGER :: handle
59 :
60 9238 : CALL timeset(routineN, handle)
61 : #if defined(__DLAF)
62 : CALL dlaf_finalize()
63 : #endif
64 9238 : CALL timestop(handle)
65 9238 : END SUBROUTINE cp_dlaf_finalize
66 :
67 : ! **************************************************************************************************
68 : !> \brief Create DLA-Future grid from BLACS context
69 : !> \param blacs_context ...
70 : !> \author Rocco Meli
71 : !> \author Mikael Simberg
72 : !> \author Mathieu Taillefumier
73 : ! **************************************************************************************************
74 0 : SUBROUTINE cp_dlaf_create_grid(blacs_context)
75 : INTEGER, INTENT(IN) :: blacs_context
76 :
77 : CHARACTER(len=*), PARAMETER :: routineN = 'cp_dlaf_create_grid'
78 :
79 : INTEGER :: handle
80 :
81 0 : CALL timeset(routineN, handle)
82 : #if defined(__DLAF)
83 : CALL dlaf_create_grid_from_blacs(blacs_context)
84 : #else
85 : MARK_USED(blacs_context)
86 0 : CPABORT("CP2K compiled without the DLA-Future library.")
87 : #endif
88 0 : CALL timestop(handle)
89 0 : END SUBROUTINE cp_dlaf_create_grid
90 :
91 : ! **************************************************************************************************
92 : !> \brief Free DLA-Future grid corresponding to BLACS context
93 : !> \param blacs_context ...
94 : !> \author Rocco Meli
95 : !> \author Mikael Simberg
96 : !> \author Mathieu Taillefumier
97 : ! **************************************************************************************************
98 0 : SUBROUTINE cp_dlaf_free_grid(blacs_context)
99 : INTEGER, INTENT(IN) :: blacs_context
100 :
101 : CHARACTER(len=*), PARAMETER :: routineN = 'cp_dlaf_free_grid'
102 :
103 : INTEGER :: handle
104 :
105 0 : CALL timeset(routineN, handle)
106 : #if defined(__DLAF)
107 : CALL dlaf_free_grid(blacs_context)
108 : #else
109 : MARK_USED(blacs_context)
110 0 : CPABORT("CP2K compiled without the DLA-Future library.")
111 : #endif
112 0 : CALL timestop(handle)
113 0 : END SUBROUTINE cp_dlaf_free_grid
114 :
115 : ! **************************************************************************************************
116 : !> \brief Free all DLA-Future grids
117 : !> \author Rocco Meli
118 : ! **************************************************************************************************
119 9238 : SUBROUTINE cp_dlaf_free_all_grids()
120 : CHARACTER(len=*), PARAMETER :: routineN = 'cp_dlaf_free_all_grids'
121 :
122 : INTEGER :: handle
123 :
124 9238 : CALL timeset(routineN, handle)
125 : #if defined(__DLAF)
126 : CALL dlaf_free_all_grids()
127 : #endif
128 9238 : CALL timestop(handle)
129 9238 : END SUBROUTINE cp_dlaf_free_all_grids
130 :
131 : END MODULE cp_dlaf_utils_api
|