Eigenvalue SoLvers for Petaflop-Applications (ELPA)  2017.05.001
elpa_index.h
Go to the documentation of this file.
1 /*
2 !
3 ! Copyright 2017, L. Hüdepohl and A. Marek, MPCDF
4 !
5 ! This file is part of ELPA.
6 !
7 ! The ELPA library was originally created by the ELPA consortium,
8 ! consisting of the following organizations:
9 !
10 ! - Max Planck Computing and Data Facility (MPCDF), formerly known as
11 ! Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
12 ! - Bergische Universität Wuppertal, Lehrstuhl für angewandte
13 ! Informatik,
14 ! - Technische Universität München, Lehrstuhl für Informatik mit
15 ! Schwerpunkt Wissenschaftliches Rechnen ,
16 ! - Fritz-Haber-Institut, Berlin, Abt. Theorie,
17 ! - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
18 ! Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
19 ! and
20 ! - IBM Deutschland GmbH
21 !
22 ! This particular source code file contains additions, changes and
23 ! enhancements authored by Intel Corporation which is not part of
24 ! the ELPA consortium.
25 !
26 ! More information can be found here:
27 ! http://elpa.mpcdf.mpg.de/
28 !
29 ! ELPA is free software: you can redistribute it and/or modify
30 ! it under the terms of the version 3 of the license of the
31 ! GNU Lesser General Public License as published by the Free
32 ! Software Foundation.
33 !
34 ! ELPA is distributed in the hope that it will be useful,
35 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
36 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 ! GNU Lesser General Public License for more details.
38 !
39 ! You should have received a copy of the GNU Lesser General Public License
40 ! along with ELPA. If not, see <http://www.gnu.org/licenses/>
41 !
42 ! ELPA reflects a substantial effort on the part of the original
43 ! ELPA consortium, and we ask you to respect the spirit of the
44 ! license that we chose: i.e., please contribute any changes you
45 ! may have back to the original ELPA library distribution, and keep
46 ! any derivatives of ELPA under the same license that we chose for
47 ! the original distribution, the GNU Lesser General Public License.
48 !
49 */
50 #pragma once
51 #include <stdlib.h>
52 #include <stdio.h>
53 #include <string.h>
54 #include <search.h>
55 #include <math.h>
56 
57 #include <elpa/elpa.h>
58 
59 #define nelements(x) (sizeof(x)/sizeof(x[0]))
60 
61 #define FOR_ALL_TYPES(X) \
62  X(int, "%d", -1) \
63  X(double, "%g", NAN)
64 
65 /* A simple structure for storing values to a pre-set
66  * number of keys */
67 
68 /* Forward declaration of configuration structure */
70 
71 /* Function type for the cardinality */
72 typedef int (*elpa_index_cardinality_t)(void);
73 
74 /* Function type to enumerate all possible values, starting from 0 */
75 typedef int (*elpa_index_enumerate_int_option_t)(int i);
76 
77 /* Function types to check the validity of a value */
78 typedef int (*elpa_index_valid_int_t)(elpa_index_t index, int n, int new_value);
79 typedef int (*elpa_index_valid_double_t)(elpa_index_t index, int n, double new_value);
80 
81 /* Function type to give a string representation of a value */
82 typedef const char* (*elpa_index_to_string_int_t)(int n);
83 
84 
85 typedef struct {
86  char *name;
87  char *description;
88  char *env_default;
89  char *env_force;
90  int once;
91  int readonly;
92  int private;
94 
95 
96 typedef struct {
104 
105 
106 typedef struct {
111 
115 };
116 
118 #define STRUCT_MEMBERS(TYPE, ...) \
119  struct { \
120  TYPE *values; \
121  int *is_set; \
122  int *notified; \
123  } TYPE##_options;
125 };
126 
127 
128 /*
129  !f> interface
130  !f> function elpa_index_instance_c() result(index) bind(C, name="elpa_index_instance")
131  !f> import c_ptr
132  !f> type(c_ptr) :: index
133  !f> end function
134  !f> end interface
135  */
136 elpa_index_t elpa_index_instance();
137 
138 
139 /*
140  !f> interface
141  !f> subroutine elpa_index_free_c(index) bind(C, name="elpa_index_free")
142  !f> import c_ptr
143  !f> type(c_ptr), value :: index
144  !f> end subroutine
145  !f> end interface
146  */
147 void elpa_index_free(elpa_index_t index);
148 
149 
150 /*
151  !f> interface
152  !f> function elpa_index_get_int_value_c(index, name, success) result(value) &
153  !f> bind(C, name="elpa_index_get_int_value")
154  !f> import c_ptr, c_int, c_char
155  !f> type(c_ptr), value :: index
156  !f> character(kind=c_char), intent(in) :: name(*)
157  !f> integer(kind=c_int), intent(out), optional :: success
158  !f> integer(kind=c_int) :: value
159  !f> end function
160  !f> end interface
161  */
162 int elpa_index_get_int_value(elpa_index_t index, char *name, int *success);
163 
164 
165 /*
166  !f> interface
167  !f> function elpa_index_set_int_value_c(index, name, value, force_writable) result(success) &
168  !f> bind(C, name="elpa_index_set_int_value")
169  !f> import c_ptr, c_int, c_char
170  !f> type(c_ptr), value :: index
171  !f> character(kind=c_char), intent(in) :: name(*)
172  !f> integer(kind=c_int),intent(in), value :: value
173  !f> integer(kind=c_int),intent(in), value :: force_writable
174  !f> integer(kind=c_int) :: success
175  !f> end function
176  !f> end interface
177  */
178 int elpa_index_set_int_value(elpa_index_t index, char *name, int value, int force_writable);
179 
180 
181 /*
182  !f> interface
183  !f> function elpa_index_int_value_is_set_c(index, name) result(success) bind(C, name="elpa_index_int_value_is_set")
184  !f> import c_ptr, c_int, c_char
185  !f> type(c_ptr), value :: index
186  !f> character(kind=c_char), intent(in) :: name(*)
187  !f> integer(kind=c_int) :: success
188  !f> end function
189  !f> end interface
190  */
191 int elpa_index_int_value_is_set(elpa_index_t index, char *name);
192 
193 
194 /*
195  !f> interface
196  !f> function elpa_index_int_is_private_c(name) result(success) bind(C, name="elpa_index_int_is_private")
197  !f> import c_int, c_char
198  !f> character(kind=c_char), intent(in) :: name(*)
199  !f> integer(kind=c_int) :: success
200  !f> end function
201  !f> end interface
202  */
203 int elpa_index_int_is_private(char *name);
204 
205 
206 /*
207  !f> interface
208  !f> function elpa_index_double_is_private_c(name) result(success) bind(C, name="elpa_index_double_is_private")
209  !f> import c_int, c_char
210  !f> character(kind=c_char), intent(in) :: name(*)
211  !f> integer(kind=c_int) :: success
212  !f> end function
213  !f> end interface
214  */
215 int elpa_index_double_is_private(char *name);
216 
217 
218 /*
219  !f> interface
220  !f> function elpa_index_get_int_loc_c(index, name) result(loc) bind(C, name="elpa_index_get_int_loc")
221  !f> import c_ptr, c_char
222  !f> type(c_ptr), value :: index
223  !f> character(kind=c_char), intent(in) :: name(*)
224  !f> type(c_ptr) :: loc
225  !f> end function
226  !f> end interface
227  */
228 int* elpa_index_get_int_loc(elpa_index_t index, char *name);
229 
230 
231 /*
232  !f> interface
233  !f> function elpa_index_get_double_value_c(index, name, success) result(value) bind(C, name="elpa_index_get_double_value")
234  !f> import c_ptr, c_int, c_double, c_char
235  !f> type(c_ptr), value :: index
236  !f> character(kind=c_char), intent(in) :: name(*)
237  !f> integer(kind=c_int), intent(out), optional :: success
238  !f> real(kind=c_double) :: value
239  !f> end function
240  !f> end interface
241  */
242 double elpa_index_get_double_value(elpa_index_t index, char *name, int *success);
243 
244 
245 /*
246  !f> interface
247  !f> function elpa_index_set_double_value_c(index, name, value, force_writable) result(success) &
248  !f> bind(C, name="elpa_index_set_double_value")
249  !f> import c_ptr, c_int, c_double, c_char
250  !f> type(c_ptr), value :: index
251  !f> character(kind=c_char), intent(in) :: name(*)
252  !f> real(kind=c_double),intent(in), value :: value
253  !f> integer(kind=c_int),intent(in), value :: force_writable
254  !f> integer(kind=c_int) :: success
255  !f> end function
256  !f> end interface
257  */
258 int elpa_index_set_double_value(elpa_index_t index, char *name, double value, int force_writable);
259 
260 
261 /*
262  !f> interface
263  !f> function elpa_index_double_value_is_set_c(index, name) result(success) &
264  !f> bind(C, name="elpa_index_double_value_is_set")
265  !f> import c_ptr, c_int, c_char
266  !f> type(c_ptr), value :: index
267  !f> character(kind=c_char), intent(in) :: name(*)
268  !f> integer(kind=c_int) :: success
269  !f> end function
270  !f> end interface
271  */
272 int elpa_index_double_value_is_set(elpa_index_t index, char *name);
273 
274 
275 /*
276  !f> interface
277  !f> function elpa_index_get_double_loc_c(index, name) result(loc) bind(C, name="elpa_index_get_double_loc")
278  !f> import c_ptr, c_char
279  !f> type(c_ptr), value :: index
280  !f> character(kind=c_char), intent(in) :: name(*)
281  !f> type(c_ptr) :: loc
282  !f> end function
283  !f> end interface
284  */
285 double* elpa_index_get_double_loc(elpa_index_t index, char *name);
286 
287 
288 /*
289  !f> interface
290  !f> function elpa_index_value_is_set_c(index, name) result(success) bind(C, name="elpa_index_value_is_set")
291  !f> import c_ptr, c_int, c_char
292  !f> type(c_ptr), value :: index
293  !f> character(kind=c_char), intent(in) :: name(*)
294  !f> integer(kind=c_int) :: success
295  !f> end function
296  !f> end interface
297  */
298 int elpa_index_value_is_set(elpa_index_t index, char *name);
299 
300 
301 /*
302  !pf> interface
303  !pf> function elpa_int_value_to_string_c(name, value, string) &
304  !pf> result(error) bind(C, name="elpa_int_value_to_string")
305  !pf> import c_int, c_ptr, c_char
306  !pf> character(kind=c_char), intent(in) :: name(*)
307  !pf> integer(kind=c_int), intent(in), value :: value
308  !pf> type(c_ptr), intent(out) :: string
309  !pf> integer(kind=c_int) :: error
310  !pf> end function
311  !pf> end interface
312  !pf>
313  */
314 int elpa_int_value_to_string(char *name, int value, const char **string);
315 
316 
317 /*
318  !pf> interface
319  !pf> pure function elpa_int_value_to_strlen_c(name, value) &
320  !pf> result(length) bind(C, name="elpa_int_value_to_strlen")
321  !pf> import c_int, c_ptr, c_char
322  !pf> character(kind=c_char), intent(in) :: name(*)
323  !pf> integer(kind=c_int), intent(in), value :: value
324  !pf> integer(kind=c_int) :: length
325  !pf> end function
326  !pf> end interface
327  !pf>
328  */
329 int elpa_int_value_to_strlen(char *name, int value);
330 
331 
332 /*
333  !f> interface
334  !f> pure function elpa_index_int_value_to_strlen_c(index, name) &
335  !f> result(length) bind(C, name="elpa_index_int_value_to_strlen")
336  !f> import c_int, c_ptr, c_char
337  !f> type(c_ptr), intent(in), value :: index
338  !f> character(kind=c_char), intent(in) :: name(*)
339  !f> integer(kind=c_int) :: length
340  !f> end function
341  !f> end interface
342  !f>
343  */
344 int elpa_index_int_value_to_strlen(elpa_index_t index, char *name);
345 
346 
347 /*
348  !f> interface
349  !f> function elpa_int_string_to_value_c(name, string, value) result(error) bind(C, name="elpa_int_string_to_value")
350  !f> import c_int, c_ptr, c_char
351  !f> character(kind=c_char), intent(in) :: name(*)
352  !f> character(kind=c_char), intent(in) :: string(*)
353  !f> integer(kind=c_int), intent(out) :: value
354  !f> integer(kind=c_int) :: error
355  !f> end function
356  !f> end interface
357  !f>
358  */
359 int elpa_int_string_to_value(char *name, char *string, int *value);
360 
361 
362 /*
363  !f> interface
364  !f> function elpa_option_cardinality_c(name) result(n) bind(C, name="elpa_option_cardinality")
365  !f> import c_int, c_char
366  !f> character(kind=c_char), intent(in) :: name(*)
367  !f> integer(kind=c_int) :: n
368  !f> end function
369  !f> end interface
370  !f>
371  */
372 int elpa_option_cardinality(char *name);
373 
374 /*
375  !f> interface
376  !f> function elpa_option_enumerate_c(name, i) result(value) bind(C, name="elpa_option_enumerate")
377  !f> import c_int, c_char
378  !f> character(kind=c_char), intent(in) :: name(*)
379  !f> integer(kind=c_int), intent(in), value :: i
380  !f> integer(kind=c_int) :: value
381  !f> end function
382  !f> end interface
383  !f>
384  */
385 int elpa_option_enumerate(char *name, int i);
386 
387 
388 /*
389  !f> interface
390  !f> function elpa_index_int_is_valid_c(index, name, new_value) result(success) bind(C, name="elpa_index_int_is_valid")
391  !f> import c_int, c_ptr, c_char
392  !f> type(c_ptr), intent(in), value :: index
393  !f> character(kind=c_char), intent(in) :: name(*)
394  !f> integer(kind=c_int), intent(in), value :: new_value
395  !f> integer(kind=c_int) :: success
396  !f> end function
397  !f> end interface
398  !f>
399  */
400 int elpa_index_int_is_valid(elpa_index_t index, char *name, int new_value);
Definition: elpa_index.h:96
int elpa_index_int_value_is_set(elpa_index_t index, char *name)
int elpa_index_int_is_private(char *name)
#define FOR_ALL_TYPES(X)
Definition: elpa_index.h:61
int elpa_index_set_int_value(elpa_index_t index, char *name, int value, int force_writable)
int(* elpa_index_valid_int_t)(elpa_index_t index, int n, int new_value)
Definition: elpa_index.h:78
elpa_index_t elpa_index_instance()
int elpa_index_value_is_set(elpa_index_t index, char *name)
Definition: elpa_index.h:113
elpa_index_valid_double_t valid
Definition: elpa_index.h:109
int elpa_index_double_value_is_set(elpa_index_t index, char *name)
double * elpa_index_get_double_loc(elpa_index_t index, char *name)
int elpa_int_string_to_value(char *name, char *string, int *value)
elpa_index_to_string_int_t to_string
Definition: elpa_index.h:102
elpa_index_cardinality_t cardinality
Definition: elpa_index.h:100
double elpa_index_get_double_value(elpa_index_t index, char *name, int *success)
Definition: elpa_index.h:114
int(* elpa_index_valid_double_t)(elpa_index_t index, int n, double new_value)
Definition: elpa_index.h:79
elpa_index_entry_t base
Definition: elpa_index.h:107
int elpa_index_int_is_valid(elpa_index_t index, char *name, int new_value)
int default_value
Definition: elpa_index.h:98
Definition: elpa_index.h:117
Definition: elpa_index.h:85
#define STRUCT_MEMBERS(TYPE,...)
Definition: elpa_index.h:118
void elpa_index_free(elpa_index_t index)
elpa_index_entry_t base
Definition: elpa_index.h:97
int(* elpa_index_enumerate_int_option_t)(int i)
Definition: elpa_index.h:75
int * elpa_index_get_int_loc(elpa_index_t index, char *name)
int(* elpa_index_cardinality_t)(void)
Definition: elpa_index.h:72
int elpa_index_get_int_value(elpa_index_t index, char *name, int *success)
struct elpa_index_struct * elpa_index_t
Definition: elpa_index.h:69
int once
Definition: elpa_index.h:90
double default_value
Definition: elpa_index.h:108
int elpa_index_set_double_value(elpa_index_t index, char *name, double value, int force_writable)
int elpa_index_double_is_private(char *name)
char * env_default
Definition: elpa_index.h:88
elpa_index_valid_int_t valid
Definition: elpa_index.h:99
Definition: elpa_index.h:106
char * env_force
Definition: elpa_index.h:89
NOTIFY_FLAGS
Definition: elpa_index.h:112
char * description
Definition: elpa_index.h:87
int readonly
Definition: elpa_index.h:91
int elpa_int_value_to_string(char *name, int value, const char **string)
elpa_index_enumerate_int_option_t enumerate
Definition: elpa_index.h:101
const char *(* elpa_index_to_string_int_t)(int n)
Definition: elpa_index.h:82
int elpa_index_int_value_to_strlen(elpa_index_t index, char *name)
char * name
Definition: elpa_index.h:86
int elpa_option_enumerate(char *name, int i)
int elpa_option_cardinality(char *name)
int elpa_int_value_to_strlen(char *name, int value)