1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 20:42:50 +01:00

Better error message in trexio read

This commit is contained in:
Anthony Scemama 2023-11-15 13:03:07 +01:00
parent 5d8dfacffe
commit f1764a5717

View File

@ -515,7 +515,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
for (int i=0 ; i<nucleus_num ; ++i) {
nucleus_shell_num[i] = 0;
}
for (int i=0 ; i<shell_num ; ++i) {
const int k = tmp_array[i];
if (k < 0 || k >= nucleus_num) {
@ -601,7 +601,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
if (shell_prim_num == NULL) {
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_shell_prim_num_X",
"qmckl_trexio_read_basis_shell_index",
NULL);
}
@ -617,7 +617,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
shell_prim_num = NULL;
return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
"qmckl_trexio_read_basis_shell_prim_num_X",
"qmckl_trexio_read_basis_shell_index",
NULL);
}
@ -632,7 +632,7 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
tmp_array = NULL;
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_shell_prim_num",
"qmckl_trexio_read_basis_shell_index",
trexio_string_of_error(rcio));
}
@ -640,16 +640,18 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
for (int i=0 ; i<shell_num ; ++i) {
shell_prim_num[i] = 0;
}
for (int i=0 ; i<prim_num ; ++i) {
const int k = tmp_array[i];
if (k < 0 || k >= shell_num) {
qmckl_free(context, tmp_array);
qmckl_free(context, shell_prim_num);
char msg[128];
sprintf(&msg[0], "Irrelevant data in TREXIO file: k = %d", k);
return qmckl_failwith( context,
QMCKL_FAILURE,
"trexio_read_basis_shell_prim_num",
"Irrelevant data in TREXIO file");
"qmckl_trexio_read_basis_shell_index",
&msg[0]);
}
shell_prim_num[k] += 1;
}
@ -657,9 +659,6 @@ qmckl_trexio_read_ao_X(qmckl_context context, trexio_t* const file)
qmckl_free(context, tmp_array);
tmp_array = NULL;
/* Store data */
rc = qmckl_set_ao_basis_shell_prim_num(context, shell_prim_num, shell_num);
qmckl_free(context, shell_prim_num);
shell_prim_num = NULL;
@ -1332,7 +1331,7 @@ double * mo_coef = (double*) malloc (ao_num * mo_num * sizeof(double));
rc = qmckl_get_mo_basis_coefficient(context, mo_coef, mo_num*ao_num);
qmckl_check(context, rc);
for (int i=0 ; i<ao_num * mo_num ; i++) {
printf("%d %e %e %e\n", i, mo_coef[i], chbrclf_mo_coef[i],
printf("%d %e %e %e\n", i, mo_coef[i], chbrclf_mo_coef[i],
( fabs(mo_coef[i] - chbrclf_mo_coef[i])/fabs(mo_coef[i])) );
assert ( fabs(mo_coef[i] - chbrclf_mo_coef[i])/fabs(mo_coef[i]) < 1.e-12 );
}