From 569b78666ea42409b042e93d6cd1f356adaac6b3 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 23 Jun 2021 23:44:20 +0200 Subject: [PATCH] Added Fortran interfaces --- org/qmckl_nucleus.org | 84 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/org/qmckl_nucleus.org b/org/qmckl_nucleus.org index cc7dce6..bdd8cb8 100644 --- a/org/qmckl_nucleus.org +++ b/org/qmckl_nucleus.org @@ -102,10 +102,10 @@ typedef struct qmckl_nucleus_struct { Some values are initialized by default, and are not concerned by this mechanism. - #+begin_src c :comments org :tangle (eval h_private_func) + #+begin_src c :comments org :tangle (eval h_private_func) qmckl_exit_code qmckl_init_nucleus(qmckl_context context); #+end_src - + #+begin_src c :comments org :tangle (eval c) qmckl_exit_code qmckl_init_nucleus(qmckl_context context) { @@ -124,11 +124,11 @@ qmckl_exit_code qmckl_init_nucleus(qmckl_context context) { return QMCKL_SUCCESS; } #+end_src - - + + ** Access functions - + #+begin_src c :comments org :tangle (eval h_func) :exports none qmckl_exit_code qmckl_get_nucleus_num (const qmckl_context context, int64_t* const num); qmckl_exit_code qmckl_get_nucleus_charge (const qmckl_context context, double* const charge); @@ -244,11 +244,11 @@ qmckl_get_nucleus_rescale_factor (const qmckl_context context, qmckl_exit_code qmckl_get_nucleus_coord (const qmckl_context context, const char transp, double* const coord) { - + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; } - + if (transp != 'N' && transp != 'T') { return qmckl_failwith( context, QMCKL_INVALID_ARG_2, @@ -331,6 +331,40 @@ qmckl_exit_code qmckl_set_nucleus_coord (qmckl_context context, const char tra qmckl_exit_code qmckl_set_nucleus_rescale_factor (qmckl_context context, const double rescale_factor_kappa); #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_set_nucleus_num(context, num) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: num + end function +end interface +interface + integer(c_int32_t) function qmckl_set_nucleus_charge(context, charge) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double) , intent(in) :: charge(*) + end function +end interface +interface + integer(c_int32_t) function qmckl_set_nucleus_coord(context, transp, coord) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + character(c_char) , intent(in) , value :: transp + real (c_double) , intent(in) :: coord(*) + end function +end interface + #+end_src + #+NAME:pre2 #+begin_src c :exports none if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { @@ -415,7 +449,7 @@ qmckl_set_nucleus_charge(qmckl_context context, const double* charge) { <> } #+end_src - + The following function sets the rescale parameter for the nuclear distances. #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none @@ -488,7 +522,7 @@ qmckl_set_nucleus_coord(qmckl_context context, const char transp, const double* const int64_t nucl_num = chbrclf_nucl_num; const double* nucl_charge = chbrclf_charge; const double* nucl_coord = &(chbrclf_nucl_coord[0][0]); -const double nucl_rescale_factor_kappa = 2.0; +const double nucl_rescale_factor_kappa = 2.0; /* --- */ @@ -561,7 +595,7 @@ for (size_t i=0 ; i