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

translation completed; error at accessing ee_distance_rescaled

This commit is contained in:
Gianfranco Abrusci 2022-02-03 17:10:31 +01:00
parent 1f31183be4
commit b0bfb3157c

View File

@ -1642,7 +1642,7 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num,
end function qmckl_compute_factor_ee_f
#+end_src
#+begin_src c :tangle (eval h_func) :comments org
#+begin_src c :comments org :tangle (eval c) :noweb yes
qmckl_exit_code qmckl_compute_factor_ee (
const qmckl_context context,
const int64_t walk_num,
@ -1654,8 +1654,56 @@ end function qmckl_compute_factor_ee_f
const double* asymp_jasb,
double* const factor_ee ) {
int64_t ipar; // can we use a smaller integer?
double pow_ser, x, spin_fact, power_ser;
if (context == QMCKL_NULL_CONTEXT) {
return QMCKL_INVALID_CONTEXT;
}
if (walk_num <= 0) {
return QMCKL_INVALID_ARG_2;
}
if (elec_num <= 0) {
return QMCKL_INVALID_ARG_3;
}
if (bord_num <= 0) {
return QMCKL_INVALID_ARG_4;
}
for (int nw = 0; nw < walk_num; ++nw) {
factor_ee[nw] = 0.0; // put init array here.
for (int j = 0; j < elec_num; ++j ) {
for (int i = 0; i < j; ++i) {
x = ee_distance_rescaled[nw][i][j];
power_ser = 0.0;
spin_fact = 1.0;
ipar = 0; // index of asymp_jasb
for (int p = 1; p < bord_num; ++p) {
x = x * ee_distance_rescaled[nw][i][j];
power_ser = power_ser + bord_vector[p + 1] * x;
}
if(j <= up_num || i > up_num) {
spin_fact = 0.5;
ipar = 1;
}
factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \
ee_distance_rescaled[nw][i][j] / \
(1.0 + bord_vector[1] * \
ee_distance_rescaled[nw][i][j]) \
-asymp_jasb[ipar] + power_ser;
}
}
}
return QMCKL_SUCCESS;
}
#+end_src
#+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
@ -1677,47 +1725,6 @@ end function qmckl_compute_factor_ee_f
#+CALL: generate_c_interface(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_factor_ee &
(context, &
walk_num, &
elec_num, &
up_num, &
bord_num, &
bord_vector, &
ee_distance_rescaled, &
asymp_jasb, &
factor_ee) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: walk_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: up_num
integer (c_int64_t) , intent(in) , value :: bord_num
real (c_double ) , intent(in) :: bord_vector(bord_num + 1)
real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num)
real (c_double ) , intent(in) :: asymp_jasb(2)
real (c_double ) , intent(out) :: factor_ee(walk_num)
integer(c_int32_t), external :: qmckl_compute_factor_ee_f
info = qmckl_compute_factor_ee_f &
(context, &
walk_num, &
elec_num, &
up_num, &
bord_num, &
bord_vector, &
ee_distance_rescaled, &
asymp_jasb, &
factor_ee)
end function qmckl_compute_factor_ee
#+end_src
*** Test
#+begin_src python :results output :exports none :noweb yes