-
Notifications
You must be signed in to change notification settings - Fork 0
/
libpaw.h
202 lines (164 loc) · 6.81 KB
/
libpaw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/* libpaw.h */
/*
* This file is part of the libPAW library.
* It has to be customized according to the host code.
* For the time being there are 2 known host codes:
* ABINIT (www.abinit.org) and BigDFT (bigdft.org).
*/
/*
* Copyright (C) 2014-2022 ABINIT Group (MT)
* This file is part of the ABINIT software package. For license information,
* please see the COPYING file in the top-level directory of the ABINIT source
* distribution.
*/
/* config.h should contain all preprocessing directives */
#if defined HAVE_CONFIG_H
#include "config.h"
#endif
/* =============================
* ========= ABINIT ============
* ============================= */
#if defined HAVE_LIBPAW_ABINIT
/* ABINIT specific macros */
# include "abi_common.h"
/* Constants and defs */
# define USE_DEFS use defs_basis
/* MPI wrappers */
# define USE_MPI_WRAPPERS use m_xmpi
/* Messages, errors */
/* Other macros already defined in abi_common.h */
# define USE_MSG_HANDLING use m_errors, only : msg_hndl, netcdf_check; use m_abicore
# undef HAVE_YAML
# define LIBPAW_COMMENT(msg) ABI_COMMENT(msg)
# define LIBPAW_WARNING(msg) ABI_WARNING(msg)
# define LIBPAW_ERROR(msg) ABI_ERROR(msg)
# define LIBPAW_BUG(msg) ABI_BUG(msg)
/* Allocation/deallocation with memory profiling */
# define USE_MEMORY_PROFILING use m_profiling_abi
/* Use this to allocate/deallocate basic-type arrays with sizes */
# define LIBPAW_ALLOCATE(ARR,SIZE) ABI_MALLOC(ARR,SIZE)
# define LIBPAW_DEALLOCATE(ARR) ABI_FREE(ARR)
/* Use this to allocate/deallocate basic-type pointers with sizes */
# define LIBPAW_POINTER_ALLOCATE(ARR,SIZE) ABI_MALLOC(ARR,SIZE)
# define LIBPAW_POINTER_DEALLOCATE(ARR) ABI_FREE(ARR)
/* Use this to allocate/deallocate user-defined-type arrays with sizes */
# define LIBPAW_DATATYPE_ALLOCATE(ARR,SIZE) ABI_MALLOC(ARR,SIZE)
# define LIBPAW_DATATYPE_DEALLOCATE(ARR) ABI_FREE(ARR)
/* Use this to allocate basic-type arrays with explicit bounds */
# define LIBPAW_BOUND1_ALLOCATE(ARR,BND1) ABI_MALLOC(ARR,(BND1))
# define LIBPAW_BOUND2_ALLOCATE(ARR,BND1,BND2) ABI_MALLOC(ARR,(BND1,BND2))
# define BOUNDS(LBND,UBND) LBND : UBND
/* libXC support */
# if defined HAVE_LIBXC
# define LIBPAW_HAVE_LIBXC HAVE_LIBXC
# else
# undef LIBPAW_HAVE_LIBXC
# endif
/* Netcdf support */
# if defined HAVE_NETCDF
# define LIBPAW_HAVE_NETCDF HAVE_NETCDF
# else
# undef LIBPAW_HAVE_NETCDF
# endif
/* FoX support */
# undef LIBPAW_HAVE_FOX
/* F2008 support */
# define LIBPAW_CONTIGUOUS ABI_CONTIGUOUS
# define LIBPAW_ISO_C_BINDING 1
/* =============================
* ========= BIGDFT ============
* ============================= */
#elif defined HAVE_LIBPAW_BIGDFT
/* Constants and defs */
# define USE_DEFS use m_libpaw_defs
/* MPI wrappers */
# define USE_MPI_WRAPPERS use m_libpaw_mpi
/* Messages, errors */
# define USE_MSG_HANDLING use m_libpaw_tools, only : wrtout => libpaw_wrtout, libpaw_msg_hndl
# define LIBPAW_COMMENT(msg) call libpaw_msg_hndl(msg,"COMMENT","PERS")
# define LIBPAW_WARNING(msg) call libpaw_msg_hndl(msg,"WARNING","PERS")
# define LIBPAW_ERROR(msg) call libpaw_msg_hndl(msg,"ERROR" ,"PERS")
# define LIBPAW_BUG(msg) call libpaw_msg_hndl(msg,"BUG" ,"PERS")
/*BigDFT should accept long lines...*/
/*#define ABI_ERROR(msg) call libpaw_msg_hndl(msg,"ERROR","PERS",__FILE__,__LINE__)*/
# define HAVE_YAML
/* Allocation/deallocation with memory profiling */
# define USE_MEMORY_PROFILING use dynamic_memory
/* Use this to allocate/deallocate basic-type arrays with sizes */
# define LIBPAW_ALLOCATE(ARR,SIZE) ARR=f_malloc(to_array SIZE )
# define LIBPAW_DEALLOCATE(ARR) call f_free(ARR)
/* Use this to allocate/deallocate basic-type pointers with sizes */
# define LIBPAW_POINTER_ALLOCATE(ARR,SIZE) ARR=f_malloc_ptr(to_array SIZE )
# define LIBPAW_POINTER_DEALLOCATE(ARR) call f_free_ptr(ARR)
/* Use this to allocate/deallocate user-defined-type arrays or pointers with sizes */
# define LIBPAW_DATATYPE_ALLOCATE(ARR,SIZE) allocate(ARR SIZE)
# define LIBPAW_DATATYPE_DEALLOCATE(ARR) deallocate(ARR)
/* Use this to allocate user-defined-type arrays with explicit bounds */
# define LIBPAW_BOUND1_ALLOCATE(ARR,BND1) ARR=f_malloc((/ BND1 /))
# define LIBPAW_BOUND2_ALLOCATE(ARR,BND1,BND2) ARR=f_malloc((/ BND1 , BND2 /))
# define BOUNDS(LBND,UBND) LBND .to. UBND
/* libXC support */
# if (defined HAVE_LIBXC)
# define LIBPAW_HAVE_LIBXC HAVE_LIBXC
# else
# undef LIBPAW_HAVE_LIBXC
# endif
/* Netcdf support */
# undef LIBPAW_HAVE_NETCDF
/* FoX support */
# undef LIBPAW_HAVE_FOX
/* F2008 support */
# define LIBPAW_CONTIGUOUS
# define LIBPAW_ISO_C_BINDING 1
/* =============================
* ========= DEFAULT ===========
* ============================= */
#else
/* Constants and defs */
# define USE_DEFS use m_libpaw_defs
/* MPI wrappers */
# define USE_MPI_WRAPPERS use m_libpaw_mpi
/* Messages, errors */
# define USE_MSG_HANDLING use m_libpaw_tools, only : wrtout => libpaw_wrtout, libpaw_msg_hndl
# define LIBPAW_COMMENT(msg) call libpaw_msg_hndl(msg,"COMMENT","PERS")
# define LIBPAW_WARNING(msg) call libpaw_msg_hndl(msg,"WARNING","PERS")
# define LIBPAW_ERROR(msg) call libpaw_msg_hndl(msg,"ERROR" ,"PERS")
# define LIBPAW_BUG(msg) call libpaw_msg_hndl(msg,"BUG" ,"PERS")
# undef HAVE_YAML
/* Allocation/deallocation */
# define USE_MEMORY_PROFILING
/* Use this to allocate/deallocate basic-type arrays with sizes */
# define LIBPAW_ALLOCATE(ARR,SIZE) allocate(ARR SIZE)
# define LIBPAW_DEALLOCATE(ARR) deallocate(ARR)
/* Use this to allocate/deallocate basic-type pointers with sizes */
# define LIBPAW_POINTER_ALLOCATE(ARR,SIZE) allocate(ARR SIZE)
# define LIBPAW_POINTER_DEALLOCATE(ARR) deallocate(ARR)
/* Use this to allocate/deallocate user-defined-type arrays with sizes */
# define LIBPAW_DATATYPE_ALLOCATE(ARR,SIZE) allocate(ARR SIZE)
# define LIBPAW_DATATYPE_DEALLOCATE(ARR) deallocate(ARR)
/* Use this to allocate user-defined-type arrays with explicit bounds */
# define LIBPAW_BOUND1_ALLOCATE(ARR,BND1) allocate(ARR(BND1))
# define LIBPAW_BOUND2_ALLOCATE(ARR,BND1,BND2) allocate(ARR(BND1,BND2))
# define BOUNDS(LBND,UBND) LBND : UBND
#define ABI_ERROR(msg) call libpaw_msg_hndl(msg,"ERROR","PERS",__FILE__,__LINE__)
#define ABI_BUG(msg) call libpaw_msg_hndl(msg,"BUG" ,"PERS")
/* libXC support */
# undef LIBPAW_HAVE_LIBXC
/* Netcdf support */
# undef LIBPAW_HAVE_NETCDF
/* FoX support */
# undef LIBPAW_HAVE_FOX
/* F2008 support */
# define LIBPAW_CONTIGUOUS
# define LIBPAW_ISO_C_BINDING 1
/* =============================
* =========== END =============
* ============================= */
#endif
/* =============================
* ===== COMMON DEFINITIONS ====
* ============================= */
/* Error handlers for netcdf; libpaw_netcdf_check is defined in m_libpaw_tools */
#ifndef NCF_CHECK
# define NCF_CHECK(ncerr) if (ncerr/=nf90_noerr) call libpaw_netcdf_check(ncerr, "ncf_check")
#endif