1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-23 04:44:03 +01:00

Fixed cppcheck

This commit is contained in:
Anthony Scemama 2022-04-05 11:44:17 +02:00
parent 6fb261d635
commit c7dd46da05
6 changed files with 154 additions and 172 deletions

View File

@ -4,7 +4,6 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
x86_ubuntu:

View File

@ -2634,9 +2634,10 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) {
}
}
rc = QMCKL_SUCCESS;
#ifdef HAVE_HPC
rc = qmckl_finalize_basis_hpc(context);
#else
rc = QMCKL_SUCCESS;
#endif
return rc;

View File

@ -84,8 +84,8 @@ are not intended to be passed to external codes.
#+begin_src c :comments org :tangle (eval h_private_type) :exports none
typedef struct qmckl_vector {
int64_t size;
double* restrict data;
int64_t size;
} qmckl_vector;
#+end_src
@ -160,8 +160,8 @@ qmckl_vector_free( qmckl_context context,
#+begin_src c :comments org :tangle (eval h_private_type) :exports none
typedef struct qmckl_matrix {
int64_t size[2];
double* restrict data;
int64_t size[2];
} qmckl_matrix;
#+end_src
@ -245,9 +245,9 @@ qmckl_matrix_free( qmckl_context context,
#define QMCKL_TENSOR_ORDER_MAX 16
typedef struct qmckl_tensor {
double* restrict data;
int64_t order;
int64_t size[QMCKL_TENSOR_ORDER_MAX];
double* restrict data;
} qmckl_tensor;
#+end_src

View File

@ -837,7 +837,7 @@ qmckl_set_jastrow_type_nucl_vector(qmckl_context context,
}
if (ctx->jastrow.type_nucl_vector != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.type_nucl_vector);
rc = qmckl_free(context, ctx->jastrow.type_nucl_vector);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc,
"qmckl_set_type_nucl_vector",
@ -896,7 +896,7 @@ qmckl_set_jastrow_aord_vector(qmckl_context context,
}
if (ctx->jastrow.aord_vector != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.aord_vector);
rc = qmckl_free(context, ctx->jastrow.aord_vector);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc,
"qmckl_set_ord_vector",
@ -959,7 +959,7 @@ qmckl_set_jastrow_bord_vector(qmckl_context context,
}
if (ctx->jastrow.bord_vector != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.bord_vector);
rc = qmckl_free(context, ctx->jastrow.bord_vector);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc,
"qmckl_set_ord_vector",
@ -1029,7 +1029,7 @@ qmckl_set_jastrow_cord_vector(qmckl_context context,
}
if (ctx->jastrow.cord_vector != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->jastrow.cord_vector);
rc = qmckl_free(context, ctx->jastrow.cord_vector);
if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc,
"qmckl_set_ord_vector",
@ -1388,12 +1388,11 @@ qmckl_exit_code qmckl_provide_asymp_jasb(qmckl_context context)
ctx->jastrow.asymp_jasb = asymp_jasb;
}
qmckl_exit_code rc =
qmckl_compute_asymp_jasb(context,
ctx->jastrow.bord_num,
ctx->jastrow.bord_vector,
rescale_factor_kappa_ee,
ctx->jastrow.asymp_jasb);
rc = qmckl_compute_asymp_jasb(context,
ctx->jastrow.bord_num,
ctx->jastrow.bord_vector,
rescale_factor_kappa_ee,
ctx->jastrow.asymp_jasb);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -1470,10 +1469,6 @@ qmckl_exit_code qmckl_compute_asymp_jasb (
const double rescale_factor_kappa_ee,
double* const asymp_jasb ) {
double kappa_inv, x, asym_one;
kappa_inv = 1.0 / rescale_factor_kappa_ee;
if (context == QMCKL_NULL_CONTEXT){
return QMCKL_INVALID_CONTEXT;
}
@ -1482,14 +1477,15 @@ qmckl_exit_code qmckl_compute_asymp_jasb (
return QMCKL_INVALID_ARG_2;
}
asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1] * kappa_inv);
const double kappa_inv = 1.0 / rescale_factor_kappa_ee;
const double asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1] * kappa_inv);
asymp_jasb[0] = asym_one;
asymp_jasb[1] = 0.5 * asym_one;
for (int i = 0 ; i <= 1; ++i) {
x = kappa_inv;
double x = kappa_inv;
for (int p = 1; p < bord_num; ++p){
x = x * kappa_inv;
x *= kappa_inv;
asymp_jasb[i] = asymp_jasb[i] + bord_vector[p + 1] * x;
}
}
@ -1672,16 +1668,15 @@ qmckl_exit_code qmckl_provide_factor_ee(qmckl_context context)
ctx->jastrow.factor_ee = factor_ee;
}
qmckl_exit_code rc =
qmckl_compute_factor_ee(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->electron.up_num,
ctx->jastrow.bord_num,
ctx->jastrow.bord_vector,
ctx->electron.ee_distance_rescaled,
ctx->jastrow.asymp_jasb,
ctx->jastrow.factor_ee);
rc = qmckl_compute_factor_ee(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->electron.up_num,
ctx->jastrow.bord_num,
ctx->jastrow.bord_vector,
ctx->electron.ee_distance_rescaled,
ctx->jastrow.asymp_jasb,
ctx->jastrow.factor_ee);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -2014,17 +2009,16 @@ qmckl_exit_code qmckl_provide_factor_ee_deriv_e(qmckl_context context)
ctx->jastrow.factor_ee_deriv_e = factor_ee_deriv_e;
}
qmckl_exit_code rc =
qmckl_compute_factor_ee_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->electron.up_num,
ctx->jastrow.bord_num,
ctx->jastrow.bord_vector,
ctx->electron.ee_distance_rescaled,
ctx->electron.ee_distance_rescaled_deriv_e,
ctx->jastrow.asymp_jasb,
ctx->jastrow.factor_ee_deriv_e);
rc = qmckl_compute_factor_ee_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->electron.up_num,
ctx->jastrow.bord_num,
ctx->jastrow.bord_vector,
ctx->electron.ee_distance_rescaled,
ctx->electron.ee_distance_rescaled_deriv_e,
ctx->jastrow.asymp_jasb,
ctx->jastrow.factor_ee_deriv_e);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -2437,21 +2431,20 @@ qmckl_exit_code qmckl_provide_factor_en(qmckl_context context)
ctx->jastrow.factor_en = factor_en;
}
qmckl_exit_code rc =
qmckl_compute_factor_en(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.type_nucl_num,
ctx->jastrow.type_nucl_vector,
ctx->jastrow.aord_num,
ctx->jastrow.aord_vector,
ctx->electron.en_distance_rescaled,
ctx->jastrow.factor_en);
rc = qmckl_compute_factor_en(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.type_nucl_num,
ctx->jastrow.type_nucl_vector,
ctx->jastrow.aord_num,
ctx->jastrow.aord_vector,
ctx->electron.en_distance_rescaled,
ctx->jastrow.factor_en);
if (rc != QMCKL_SUCCESS) {
return rc;
}
ctx->jastrow.factor_en_date = ctx->date;
}
@ -2784,18 +2777,17 @@ qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context)
ctx->jastrow.factor_en_deriv_e = factor_en_deriv_e;
}
qmckl_exit_code rc =
qmckl_compute_factor_en_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.type_nucl_num,
ctx->jastrow.type_nucl_vector,
ctx->jastrow.aord_num,
ctx->jastrow.aord_vector,
ctx->electron.en_distance_rescaled,
ctx->electron.en_distance_rescaled_deriv_e,
ctx->jastrow.factor_en_deriv_e);
rc = qmckl_compute_factor_en_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.type_nucl_num,
ctx->jastrow.type_nucl_vector,
ctx->jastrow.aord_num,
ctx->jastrow.aord_vector,
ctx->electron.en_distance_rescaled,
ctx->electron.en_distance_rescaled_deriv_e,
ctx->jastrow.factor_en_deriv_e);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -3203,14 +3195,13 @@ qmckl_exit_code qmckl_provide_een_rescaled_e(qmckl_context context)
ctx->jastrow.een_rescaled_e = een_rescaled_e;
}
qmckl_exit_code rc =
qmckl_compute_een_rescaled_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_ee,
ctx->electron.ee_distance,
ctx->jastrow.een_rescaled_e);
rc = qmckl_compute_een_rescaled_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_ee,
ctx->electron.ee_distance,
ctx->jastrow.een_rescaled_e);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -3537,16 +3528,15 @@ qmckl_exit_code qmckl_provide_een_rescaled_e_deriv_e(qmckl_context context)
ctx->jastrow.een_rescaled_e_deriv_e = een_rescaled_e_deriv_e;
}
qmckl_exit_code rc =
qmckl_compute_factor_een_rescaled_e_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_ee,
ctx->electron.coord_new.data,
ctx->electron.ee_distance,
ctx->jastrow.een_rescaled_e,
ctx->jastrow.een_rescaled_e_deriv_e);
rc = qmckl_compute_factor_een_rescaled_e_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_ee,
ctx->electron.coord_new.data,
ctx->electron.ee_distance,
ctx->jastrow.een_rescaled_e,
ctx->jastrow.een_rescaled_e_deriv_e);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -3917,15 +3907,14 @@ qmckl_exit_code qmckl_provide_een_rescaled_n(qmckl_context context)
ctx->jastrow.een_rescaled_n = een_rescaled_n;
}
qmckl_exit_code rc =
qmckl_compute_een_rescaled_n(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_en,
ctx->electron.en_distance,
ctx->jastrow.een_rescaled_n);
rc = qmckl_compute_een_rescaled_n(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_en,
ctx->electron.en_distance,
ctx->jastrow.een_rescaled_n);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -4256,18 +4245,17 @@ qmckl_exit_code qmckl_provide_een_rescaled_n_deriv_e(qmckl_context context)
ctx->jastrow.een_rescaled_n_deriv_e = een_rescaled_n_deriv_e;
}
qmckl_exit_code rc =
qmckl_compute_factor_een_rescaled_n_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_en,
ctx->electron.coord_new.data,
ctx->nucleus.coord.data,
ctx->electron.en_distance,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.een_rescaled_n_deriv_e);
rc = qmckl_compute_factor_een_rescaled_n_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->electron.rescale_factor_kappa_en,
ctx->electron.coord_new.data,
ctx->nucleus.coord.data,
ctx->electron.en_distance,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.een_rescaled_n_deriv_e);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -4758,14 +4746,13 @@ qmckl_exit_code qmckl_provide_cord_vect_full(qmckl_context context)
ctx->jastrow.cord_vect_full = cord_vect_full;
}
qmckl_exit_code rc =
qmckl_compute_cord_vect_full(context,
ctx->nucleus.num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.type_nucl_num,
ctx->jastrow.type_nucl_vector,
ctx->jastrow.cord_vector,
ctx->jastrow.cord_vect_full);
rc = qmckl_compute_cord_vect_full(context,
ctx->nucleus.num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.type_nucl_num,
ctx->jastrow.type_nucl_vector,
ctx->jastrow.cord_vector,
ctx->jastrow.cord_vect_full);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -4809,11 +4796,10 @@ qmckl_exit_code qmckl_provide_lkpm_combined_index(qmckl_context context)
ctx->jastrow.lkpm_combined_index = lkpm_combined_index;
}
qmckl_exit_code rc =
qmckl_compute_lkpm_combined_index(context,
ctx->jastrow.cord_num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.lkpm_combined_index);
rc = qmckl_compute_lkpm_combined_index(context,
ctx->jastrow.cord_num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.lkpm_combined_index);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -4858,15 +4844,14 @@ qmckl_exit_code qmckl_provide_tmp_c(qmckl_context context)
ctx->jastrow.tmp_c = tmp_c;
}
qmckl_exit_code rc =
qmckl_compute_tmp_c(context,
ctx->jastrow.cord_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->electron.walk_num,
ctx->jastrow.een_rescaled_e,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.tmp_c);
rc = qmckl_compute_tmp_c(context,
ctx->jastrow.cord_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->electron.walk_num,
ctx->jastrow.een_rescaled_e,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.tmp_c);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -4899,7 +4884,7 @@ qmckl_exit_code qmckl_provide_dtmp_c(qmckl_context context)
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = (ctx->jastrow.cord_num) * (ctx->jastrow.cord_num + 1)
* 4 * ctx->electron.num * ctx->nucleus.num * ctx->electron.walk_num * sizeof(double);
,* 4 * ctx->electron.num * ctx->nucleus.num * ctx->electron.walk_num * sizeof(double);
double* dtmp_c = (double*) qmckl_malloc(context, mem_info);
if (dtmp_c == NULL) {
@ -4911,15 +4896,14 @@ qmckl_exit_code qmckl_provide_dtmp_c(qmckl_context context)
ctx->jastrow.dtmp_c = dtmp_c;
}
qmckl_exit_code rc =
qmckl_compute_dtmp_c(context,
ctx->jastrow.cord_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->electron.walk_num,
ctx->jastrow.een_rescaled_e_deriv_e,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.dtmp_c);
rc = qmckl_compute_dtmp_c(context,
ctx->jastrow.cord_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->electron.walk_num,
ctx->jastrow.een_rescaled_e_deriv_e,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.dtmp_c);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -5943,18 +5927,17 @@ qmckl_exit_code qmckl_provide_factor_een(qmckl_context context)
ctx->jastrow.factor_een = factor_een;
}
qmckl_exit_code rc =
qmckl_compute_factor_een(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.cord_vect_full,
ctx->jastrow.lkpm_combined_index,
ctx->jastrow.tmp_c,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.factor_een);
rc = qmckl_compute_factor_een(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.cord_vect_full,
ctx->jastrow.lkpm_combined_index,
ctx->jastrow.tmp_c,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.factor_een);
if (rc != QMCKL_SUCCESS) {
return rc;
}
@ -6456,20 +6439,19 @@ qmckl_exit_code qmckl_provide_factor_een_deriv_e(qmckl_context context)
ctx->jastrow.factor_een_deriv_e = factor_een_deriv_e;
}
qmckl_exit_code rc =
qmckl_compute_factor_een_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.cord_vect_full,
ctx->jastrow.lkpm_combined_index,
ctx->jastrow.tmp_c,
ctx->jastrow.dtmp_c,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.een_rescaled_n_deriv_e,
ctx->jastrow.factor_een_deriv_e);
rc = qmckl_compute_factor_een_deriv_e(context,
ctx->electron.walk_num,
ctx->electron.num,
ctx->nucleus.num,
ctx->jastrow.cord_num,
ctx->jastrow.dim_cord_vect,
ctx->jastrow.cord_vect_full,
ctx->jastrow.lkpm_combined_index,
ctx->jastrow.tmp_c,
ctx->jastrow.dtmp_c,
ctx->jastrow.een_rescaled_n,
ctx->jastrow.een_rescaled_n_deriv_e,
ctx->jastrow.factor_een_deriv_e);
if (rc != QMCKL_SUCCESS) {
return rc;
}

View File

@ -849,13 +849,13 @@ qmckl_compute_mo_basis_mo_vgl_hpc (const qmckl_context context,
int64_t n0 = nidx-4;
n0 = n0 < 0 ? 0 : n0;
for (int64_t n=n0 ; n < nidx ; n+=1) {
const double* restrict ck = coef_normalized_t + idx[n]*mo_num;
const double a1 = av1[n];
const double a2 = av2[n];
const double a3 = av3[n];
const double a4 = av4[n];
const double a5 = av5[n];
for (int64_t m=n0 ; m < nidx ; m+=1) {
const double* restrict ck = coef_normalized_t + idx[m]*mo_num;
const double a1 = av1[m];
const double a2 = av2[m];
const double a3 = av3[m];
const double a4 = av4[m];
const double a5 = av5[m];
#ifdef HAVE_OPENMP
#pragma omp simd

View File

@ -965,7 +965,7 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s(const qmckl_context context,
rc = qmckl_woodbury_3(context, LDS, Dim, Updates_3block, Updates_index_3block, breakdown, Slater_inv, determinant);
if (rc != 0) { // Send the entire block to slagel_splitting
uint64_t l = 0;
rc = qmckl_slagel_splitting(LDS, Dim, 3, Updates_3block, Updates_index_3block,
(void) qmckl_slagel_splitting(LDS, Dim, 3, Updates_3block, Updates_index_3block,
breakdown, Slater_inv, later_updates + (Dim * later), later_index + later, &l, determinant);
later = later + l;
}