mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-23 04:44:03 +01:00
Compliant with CERT standard
This commit is contained in:
parent
271c4cfe84
commit
a295cfe22e
@ -10,7 +10,7 @@ Gaussian ($p=2$):
|
|||||||
\[
|
\[
|
||||||
R_s(\mathbf{r}) = \mathcal{N}_s |\mathbf{r}-\mathbf{R}_A|^{n_s}
|
R_s(\mathbf{r}) = \mathcal{N}_s |\mathbf{r}-\mathbf{R}_A|^{n_s}
|
||||||
\sum_{k=1}^{N_{\text{prim}}} a_{ks}
|
\sum_{k=1}^{N_{\text{prim}}} a_{ks}
|
||||||
\exp \left( - \gamma_{ks} | \mathbf{r}-\mathbf{R}_A | ^p \right). |
|
\exp \left( - \gamma_{ks} | \mathbf{r}-\mathbf{R}_A | ^p \right).
|
||||||
\]
|
\]
|
||||||
|
|
||||||
In the case of Gaussian functions, $n_s$ is always zero.
|
In the case of Gaussian functions, $n_s$ is always zero.
|
||||||
@ -570,7 +570,7 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
|
|||||||
| ~context~ | input | Global state |
|
| ~context~ | input | Global state |
|
||||||
| ~X(3)~ | input | Array containing the coordinates of the points |
|
| ~X(3)~ | input | Array containing the coordinates of the points |
|
||||||
| ~R(3)~ | input | Array containing the x,y,z coordinates of the center |
|
| ~R(3)~ | input | Array containing the x,y,z coordinates of the center |
|
||||||
| ~n~ | input | Number of computed gaussians |
|
| ~n~ | input | Number of computed Gaussians |
|
||||||
| ~A(n)~ | input | Exponents of the Gaussians |
|
| ~A(n)~ | input | Exponents of the Gaussians |
|
||||||
| ~VGL(ldv,5)~ | output | Value, gradients and Laplacian of the Gaussians |
|
| ~VGL(ldv,5)~ | output | Value, gradients and Laplacian of the Gaussians |
|
||||||
| ~ldv~ | input | Leading dimension of array ~VGL~ |
|
| ~ldv~ | input | Leading dimension of array ~VGL~ |
|
||||||
|
@ -427,9 +427,7 @@ qmckl_context qmckl_context_destroy(const qmckl_context context) {
|
|||||||
|
|
||||||
qmckl_exit_code rc;
|
qmckl_exit_code rc;
|
||||||
rc = qmckl_context_remove_memory(context,ctx);
|
rc = qmckl_context_remove_memory(context,ctx);
|
||||||
/*
|
|
||||||
assert (rc == QMCKL_SUCCESS);
|
assert (rc == QMCKL_SUCCESS);
|
||||||
*/
|
|
||||||
|
|
||||||
ctx->tag = INVALID_TAG;
|
ctx->tag = INVALID_TAG;
|
||||||
|
|
||||||
@ -442,9 +440,6 @@ qmckl_context qmckl_context_destroy(const qmckl_context context) {
|
|||||||
rc = qmckl_free(context,ctx);
|
rc = qmckl_free(context,ctx);
|
||||||
assert (rc == QMCKL_SUCCESS);
|
assert (rc == QMCKL_SUCCESS);
|
||||||
|
|
||||||
//memset(ctx, 0, sizeof(qmckl_context_struct));
|
|
||||||
|
|
||||||
|
|
||||||
return prev_context;
|
return prev_context;
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -534,7 +529,7 @@ qmckl_exit_code qmckl_context_append_memory(qmckl_context context,
|
|||||||
if (alloc == NULL) {
|
if (alloc == NULL) {
|
||||||
ctx->alloc = new_alloc;
|
ctx->alloc = new_alloc;
|
||||||
} else {
|
} else {
|
||||||
while (alloc != NULL) {
|
while (alloc->next != NULL) {
|
||||||
alloc = alloc->next;
|
alloc = alloc->next;
|
||||||
}
|
}
|
||||||
alloc->next = new_alloc;
|
alloc->next = new_alloc;
|
||||||
@ -670,8 +665,8 @@ qmckl_context_update_error(qmckl_context context,
|
|||||||
qmckl_error_struct* error =
|
qmckl_error_struct* error =
|
||||||
(qmckl_error_struct*) qmckl_malloc (context, sizeof(qmckl_error_struct));
|
(qmckl_error_struct*) qmckl_malloc (context, sizeof(qmckl_error_struct));
|
||||||
error->exit_code = exit_code;
|
error->exit_code = exit_code;
|
||||||
strcpy(error->function, function_name);
|
strncpy(error->function, function_name, QMCKL_MAX_FUN_LEN);
|
||||||
strcpy(error->message, message);
|
strncpy(error->message, message, QMCKL_MAX_MSG_LEN);
|
||||||
|
|
||||||
ctx->error = error;
|
ctx->error = error;
|
||||||
|
|
||||||
@ -797,8 +792,7 @@ if (x < 0) {
|
|||||||
# -*- org-src-preserve-indentation: t
|
# -*- org-src-preserve-indentation: t
|
||||||
|
|
||||||
#+begin_src python :var table=table-precision :results drawer :exports result
|
#+begin_src python :var table=table-precision :results drawer :exports result
|
||||||
""" This script generates the C and Fortran constants for the error
|
""" This script generates the C and Fortran constants from the org-mode table.
|
||||||
codes from the org-mode table.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = [ "#+begin_src c :comments org :tangle (eval h)" ]
|
result = [ "#+begin_src c :comments org :tangle (eval h)" ]
|
||||||
@ -898,8 +892,6 @@ qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, cons
|
|||||||
"qmckl_context_update_precision",
|
"qmckl_context_update_precision",
|
||||||
"ctx->fp");
|
"ctx->fp");
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->fp->precision = QMCKL_DEFAULT_PRECISION;
|
|
||||||
ctx->fp->range = QMCKL_DEFAULT_RANGE;
|
ctx->fp->range = QMCKL_DEFAULT_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,7 +1029,6 @@ qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const in
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->fp->precision = QMCKL_DEFAULT_PRECISION;
|
ctx->fp->precision = QMCKL_DEFAULT_PRECISION;
|
||||||
ctx->fp->range = QMCKL_DEFAULT_RANGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->fp->range = range;
|
ctx->fp->range = range;
|
||||||
|
@ -151,7 +151,7 @@ void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGT
|
|||||||
The text strings are extracted from the previous table.
|
The text strings are extracted from the previous table.
|
||||||
|
|
||||||
#+NAME:cases
|
#+NAME:cases
|
||||||
#+begin_src python :var table=table-exit-codes :exports none
|
#+begin_src python :var table=table-exit-codes :exports none :noweb yes
|
||||||
""" This script extracts the text associated with the error codes
|
""" This script extracts the text associated with the error codes
|
||||||
from the table.
|
from the table.
|
||||||
"""
|
"""
|
||||||
@ -161,7 +161,7 @@ for (text, code, message) in table:
|
|||||||
text = text.replace("~","")
|
text = text.replace("~","")
|
||||||
message = message.replace("'",'"')
|
message = message.replace("'",'"')
|
||||||
result += [ f"""case {text}:
|
result += [ f"""case {text}:
|
||||||
message = {message};
|
strncpy(string,{message},<<MAX_STRING_LENGTH()>>);
|
||||||
break;""" ]
|
break;""" ]
|
||||||
return '\n'.join(result)
|
return '\n'.join(result)
|
||||||
|
|
||||||
@ -170,11 +170,9 @@ return '\n'.join(result)
|
|||||||
# Source
|
# Source
|
||||||
#+begin_src c :comments org :tangle (eval c) :noweb yes
|
#+begin_src c :comments org :tangle (eval c) :noweb yes
|
||||||
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]) {
|
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]) {
|
||||||
char* message;
|
|
||||||
switch (error) {
|
switch (error) {
|
||||||
<<cases()>>
|
<<cases()>>
|
||||||
}
|
}
|
||||||
strncpy(string,message,<<MAX_STRING_LENGTH()>>);
|
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ echo "#+begin_src c :tangle no"
|
|||||||
for file in $files
|
for file in $files
|
||||||
do
|
do
|
||||||
routine=test_${file%.c}
|
routine=test_${file%.c}
|
||||||
echo " { (char*) \"${routine}\", ${routine}, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},"
|
echo " { (const char*) \"${routine}\", ${routine}, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},"
|
||||||
done
|
done
|
||||||
echo "#+end_src"
|
echo "#+end_src"
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -63,11 +63,11 @@ echo "#+end_src"
|
|||||||
:results:
|
:results:
|
||||||
#+NAME: calls
|
#+NAME: calls
|
||||||
#+begin_src c :tangle no
|
#+begin_src c :tangle no
|
||||||
{ (char*) "test_qmckl_error", test_qmckl_error, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
{ (const char*) "test_qmckl_error", test_qmckl_error, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||||
{ (char*) "test_qmckl_context", test_qmckl_context, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
{ (const char*) "test_qmckl_context", test_qmckl_context, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||||
{ (char*) "test_qmckl_memory", test_qmckl_memory, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
{ (const char*) "test_qmckl_memory", test_qmckl_memory, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||||
{ (char*) "test_qmckl_distance", test_qmckl_distance, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
{ (const char*) "test_qmckl_distance", test_qmckl_distance, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||||
{ (char*) "test_qmckl_ao", test_qmckl_ao, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
{ (const char*) "test_qmckl_ao", test_qmckl_ao, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||||
#+end_src
|
#+end_src
|
||||||
:end:
|
:end:
|
||||||
|
|
||||||
@ -91,12 +91,13 @@ int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
|
|||||||
|
|
||||||
static const MunitSuite test_suite =
|
static const MunitSuite test_suite =
|
||||||
{
|
{
|
||||||
(char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
|
(const char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int result = munit_suite_main(&test_suite, (void*) "µnit", argc, argv);
|
int result = munit_suite_main(&test_suite, (const void*) "µnit", argc, argv);
|
||||||
muntrace();
|
muntrace();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user