1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 20:36:01 +01:00

Compliant with CERT standard

This commit is contained in:
Anthony Scemama 2021-03-29 01:17:33 +02:00
parent 271c4cfe84
commit a295cfe22e
4 changed files with 17 additions and 27 deletions

View File

@ -10,7 +10,7 @@ Gaussian ($p=2$):
\[
R_s(\mathbf{r}) = \mathcal{N}_s |\mathbf{r}-\mathbf{R}_A|^{n_s}
\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.
@ -570,7 +570,7 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
| ~context~ | input | Global state |
| ~X(3)~ | input | Array containing the coordinates of the points |
| ~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 |
| ~VGL(ldv,5)~ | output | Value, gradients and Laplacian of the Gaussians |
| ~ldv~ | input | Leading dimension of array ~VGL~ |

View File

@ -427,9 +427,7 @@ qmckl_context qmckl_context_destroy(const qmckl_context context) {
qmckl_exit_code rc;
rc = qmckl_context_remove_memory(context,ctx);
/*
assert (rc == QMCKL_SUCCESS);
*/
ctx->tag = INVALID_TAG;
@ -442,9 +440,6 @@ qmckl_context qmckl_context_destroy(const qmckl_context context) {
rc = qmckl_free(context,ctx);
assert (rc == QMCKL_SUCCESS);
//memset(ctx, 0, sizeof(qmckl_context_struct));
return prev_context;
}
#+end_src
@ -534,7 +529,7 @@ qmckl_exit_code qmckl_context_append_memory(qmckl_context context,
if (alloc == NULL) {
ctx->alloc = new_alloc;
} else {
while (alloc != NULL) {
while (alloc->next != NULL) {
alloc = alloc->next;
}
alloc->next = new_alloc;
@ -670,8 +665,8 @@ qmckl_context_update_error(qmckl_context context,
qmckl_error_struct* error =
(qmckl_error_struct*) qmckl_malloc (context, sizeof(qmckl_error_struct));
error->exit_code = exit_code;
strcpy(error->function, function_name);
strcpy(error->message, message);
strncpy(error->function, function_name, QMCKL_MAX_FUN_LEN);
strncpy(error->message, message, QMCKL_MAX_MSG_LEN);
ctx->error = error;
@ -797,8 +792,7 @@ if (x < 0) {
# -*- org-src-preserve-indentation: t
#+begin_src python :var table=table-precision :results drawer :exports result
""" This script generates the C and Fortran constants for the error
codes from the org-mode table.
""" This script generates the C and Fortran constants from the org-mode table.
"""
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",
"ctx->fp");
}
ctx->fp->precision = QMCKL_DEFAULT_PRECISION;
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->range = QMCKL_DEFAULT_RANGE;
}
ctx->fp->range = range;

View File

@ -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.
#+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
from the table.
"""
@ -161,7 +161,7 @@ for (text, code, message) in table:
text = text.replace("~","")
message = message.replace("'",'"')
result += [ f"""case {text}:
message = {message};
strncpy(string,{message},<<MAX_STRING_LENGTH()>>);
break;""" ]
return '\n'.join(result)
@ -170,11 +170,9 @@ return '\n'.join(result)
# Source
#+begin_src c :comments org :tangle (eval c) :noweb yes
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]) {
char* message;
switch (error) {
<<cases()>>
}
strncpy(string,message,<<MAX_STRING_LENGTH()>>);
}
#+end_src

View File

@ -54,7 +54,7 @@ echo "#+begin_src c :tangle no"
for file in $files
do
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
echo "#+end_src"
#+end_src
@ -63,11 +63,11 @@ echo "#+end_src"
:results:
#+NAME: calls
#+begin_src c :tangle no
{ (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},
{ (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},
{ (char*) "test_qmckl_ao", test_qmckl_ao, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
{ (const char*) "test_qmckl_error", test_qmckl_error, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
{ (const char*) "test_qmckl_context", test_qmckl_context, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
{ (const char*) "test_qmckl_memory", test_qmckl_memory, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
{ (const char*) "test_qmckl_distance", test_qmckl_distance, 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:
@ -91,12 +91,13 @@ int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
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();
return result;
}
#+end_src