mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-23 04:44:03 +01:00
Merge branch 'add-python-api' of github.com:TREX-CoE/qmckl into add-python-api
This commit is contained in:
commit
3886a2c337
@ -1058,11 +1058,11 @@ E_L = KE + PE
|
|||||||
*** Get
|
*** Get
|
||||||
|
|
||||||
#+begin_src c :comments org :tangle (eval h_func) :noweb yes
|
#+begin_src c :comments org :tangle (eval h_func) :noweb yes
|
||||||
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double* const local_energy);
|
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double* const local_energy, const int64_t size_max);
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||||
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const local_energy) {
|
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const local_energy, const int64_t size_max) {
|
||||||
|
|
||||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||||
return QMCKL_NULL_CONTEXT;
|
return QMCKL_NULL_CONTEXT;
|
||||||
@ -1086,8 +1086,14 @@ qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const loc
|
|||||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||||
assert (ctx != NULL);
|
assert (ctx != NULL);
|
||||||
|
|
||||||
size_t sze = ctx->electron.walk_num * sizeof(double);
|
const int64_t sze = ctx->electron.walk_num;
|
||||||
memcpy(local_energy, ctx->local_energy.e_local, sze);
|
if (size_max < sze) {
|
||||||
|
return qmckl_failwith( context,
|
||||||
|
QMCKL_INVALID_ARG_3,
|
||||||
|
"qmckl_get_local_energy",
|
||||||
|
"input array too small");
|
||||||
|
}
|
||||||
|
memcpy(local_energy, ctx->local_energy.e_local, sze * sizeof(double));
|
||||||
|
|
||||||
return QMCKL_SUCCESS;
|
return QMCKL_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1292,7 +1298,7 @@ end function qmckl_compute_local_energy_f
|
|||||||
|
|
||||||
double local_energy[walk_num];
|
double local_energy[walk_num];
|
||||||
|
|
||||||
rc = qmckl_get_local_energy(context, &(local_energy[0]));
|
rc = qmckl_get_local_energy(context, &(local_energy[0]), walk_num);
|
||||||
assert (rc == QMCKL_SUCCESS);
|
assert (rc == QMCKL_SUCCESS);
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user