From 5e35df226a640be17bc7726c1e49f3cd226c3b67 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 27 Feb 2022 11:18:26 +0100 Subject: [PATCH] Fortran interface --- org/qmckl_ao.org | 10 ++++--- org/qmckl_nucleus.org | 62 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 0262c53..c821c67 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -1,3 +1,4 @@ +B #+TITLE: Atomic Orbitals #+SETUPFILE: ../tools/theme.setup #+INCLUDE: ../tools/lib.org @@ -2639,14 +2640,15 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { *** HPC-specific data structures - For faster access, we provide 3D tensors for the shell information - as: + For faster access, we provide extra arrays for the shell information as: - $C_{psa}$ = =coef_per_nucleus (iprim, ishell, inucl)= - $\gamma_{pa}$ =expo_per_nucleus (iprim, inucl)= such that the computation of the radial parts can be vectorized. + Exponents are sorted in increasing order to exit loops quickly, - and only unique exponents are kept. + and only unique exponents are kept. This also allows to pack the + exponents to enable vectorization of exponentials. The computation of the radial part is made as \[ @@ -2655,7 +2657,7 @@ qmckl_exit_code qmckl_finalize_basis(qmckl_context context) { which is a matrix-vector product. #+NAME:HPC_struct - #+begin_src c :comments org :tangle (eval h_private_type) :exports none + #+begin_src c :comments org :exports none /* HPC specific data structures */ qmckl_tensor coef_per_nucleus; qmckl_matrix expo_per_nucleus; diff --git a/org/qmckl_nucleus.org b/org/qmckl_nucleus.org index 0191afe..319d5d1 100644 --- a/org/qmckl_nucleus.org +++ b/org/qmckl_nucleus.org @@ -187,6 +187,19 @@ qmckl_get_nucleus_num (const qmckl_context context, int64_t* const num) { } #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_get_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(out) :: num + end function qmckl_get_nucleus_num +end interface + #+end_src + #+begin_src c :comments org :tangle (eval h_func) :exports none qmckl_exit_code @@ -242,6 +255,20 @@ qmckl_get_nucleus_charge (const qmckl_context context, #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_get_nucleus_charge(context, charge, size_max) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double) , intent(out) :: charge(*) + integer (c_int64_t) , intent(in) , value :: size_max + end function qmckl_get_nucleus_charge +end interface + #+end_src + #+begin_src c :comments org :tangle (eval h_func) :exports none qmckl_exit_code @@ -277,6 +304,18 @@ qmckl_get_nucleus_rescale_factor (const qmckl_context context, } #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_get_nucleus_rescale_factor(context, kappa) & + bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + real (c_double) , intent(out) :: kappa + end function qmckl_get_nucleus_rescale_factor +end interface + #+end_src #+begin_src c :comments org :tangle (eval h_func) :exports none qmckl_exit_code @@ -342,6 +381,21 @@ qmckl_get_nucleus_coord (const qmckl_context context, } #+end_src + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none +interface + integer(c_int32_t) function qmckl_get_nucleus_coord(context, transp, coord, size_max) & + 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(out) :: coord(*) + integer (c_int64_t) , intent(in) , value :: size_max + end function qmckl_get_nucleus_coord +end interface + #+end_src + When all the data relative to nuclei have been set, the following function returns ~true~. @@ -424,7 +478,7 @@ interface implicit none integer (c_int64_t) , intent(in) , value :: context integer (c_int64_t) , intent(in) , value :: num - end function + end function qmckl_set_nucleus_num end interface #+end_src @@ -570,7 +624,7 @@ interface character(c_char) , intent(in) , value :: transp real (c_double) , intent(in) :: coord(*) integer (c_int64_t) , intent(in) , value :: size_max - end function + end function qmckl_set_nucleus_coord end interface #+end_src @@ -604,14 +658,14 @@ qmckl_set_nucleus_rescale_factor(qmckl_context context, #+begin_src f90 :tangle (eval fh_func) :comments org :exports none interface - integer(c_int32_t) function qmckl_set_rescale_factor(context, kappa) & + integer(c_int32_t) function qmckl_set_nucleus_rescale_factor(context, kappa) & bind(C) use, intrinsic :: iso_c_binding import implicit none integer (c_int64_t) , intent(in) , value :: context real (c_double) , intent(in) , value :: kappa - end function + end function qmckl_set_nucleus_rescale_factor end interface #+end_src