From 7a995a0f6bba5fb889d2c66bd0c53c1b0ef447ad Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Sep 2023 13:02:13 +0200 Subject: [PATCH] Simplify Fortran call --- org/qmckl_jastrow_champ.org | 276 +++++++++++------------------------- 1 file changed, 81 insertions(+), 195 deletions(-) diff --git a/org/qmckl_jastrow_champ.org b/org/qmckl_jastrow_champ.org index e4b1a51d..d123d526 100644 --- a/org/qmckl_jastrow_champ.org +++ b/org/qmckl_jastrow_champ.org @@ -1794,39 +1794,21 @@ qmckl_exit_code qmckl_provide_jastrow_champ_asymp_jasb(qmckl_context context) | ~rescale_factor_ee~ | ~double~ | in | Electron coordinates | | ~asymp_jasb~ | ~double[2]~ | out | Asymptotic value | - # #+CALL: generate_c_interface(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_jastrow_champ_asymp_jasb_doc & - (context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) & - 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 :: bord_num - real (c_double ) , intent(in) :: b_vector(bord_num+1) - real (c_double ) , intent(in) , value :: rescale_factor_ee - real (c_double ) , intent(out) :: asymp_jasb(2) - - integer(c_int32_t), external :: qmckl_compute_jastrow_champ_asymp_jasb_doc_f - info = qmckl_compute_jastrow_champ_asymp_jasb_doc_f & - (context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) - - end function qmckl_compute_jastrow_champ_asymp_jasb_doc - #+end_src - #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_jastrow_champ_asymp_jasb_doc_f(context, bord_num, b_vector, rescale_factor_ee, asymp_jasb) & - result(info) +function qmckl_compute_jastrow_champ_asymp_jasb_doc(context, & + bord_num, b_vector, rescale_factor_ee, asymp_jasb) & + bind(C) result(info) + use, intrinsic :: iso_c_binding + use qmckl implicit none - integer(qmckl_context), intent(in) :: context - integer*8 , intent(in) :: bord_num - double precision , intent(in) :: b_vector(bord_num + 1) - double precision , intent(in) :: rescale_factor_ee - double precision , intent(out) :: asymp_jasb(2) + + integer (qmckl_context) , intent(in) , value :: context + integer (c_int64_t) , intent(in) , value :: bord_num + real (c_double ) , intent(in) :: b_vector(bord_num+1) + real (c_double ) , intent(in) , value :: rescale_factor_ee + real (c_double ) , intent(out) :: asymp_jasb(2) + integer(qmckl_exit_code) :: info integer*8 :: i, p double precision :: kappa_inv, x, asym_one @@ -1855,7 +1837,7 @@ integer function qmckl_compute_jastrow_champ_asymp_jasb_doc_f(context, bord_num, end do end do -end function qmckl_compute_jastrow_champ_asymp_jasb_doc_f +end function qmckl_compute_jastrow_champ_asymp_jasb_doc #+end_src #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none @@ -2238,17 +2220,25 @@ qmckl_exit_code qmckl_provide_jastrow_champ_factor_ee(qmckl_context context) # #+CALL: generate_c_interface(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_jastrow_champ_factor_ee_doc_f(context, walk_num, elec_num, up_num, bord_num, & - b_vector, ee_distance_rescaled, asymp_jasb, factor_ee) & - result(info) +function qmckl_compute_jastrow_champ_factor_ee_doc(context, & + walk_num, elec_num, up_num, bord_num, & + b_vector, ee_distance_rescaled, asymp_jasb, factor_ee) & + bind(C) result(info) + use, intrinsic :: iso_c_binding + use qmckl implicit none - integer(qmckl_context), intent(in) :: context - integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num - double precision , intent(in) :: b_vector(bord_num + 1) - double precision , intent(in) :: ee_distance_rescaled(elec_num, elec_num, walk_num) - double precision , intent(in) :: asymp_jasb(2) - double precision , intent(out) :: factor_ee(walk_num) + + integer (qmckl_context), 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) :: b_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(qmckl_exit_code) :: info integer*8 :: i, j, k, nw double precision :: x, xk @@ -2298,34 +2288,9 @@ integer function qmckl_compute_jastrow_champ_factor_ee_doc_f(context, walk_num, end do -end function qmckl_compute_jastrow_champ_factor_ee_doc_f +end function qmckl_compute_jastrow_champ_factor_ee_doc #+end_src - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_jastrow_champ_factor_ee_doc & - (context, walk_num, elec_num, up_num, bord_num, b_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) :: b_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_jastrow_champ_factor_ee_doc_f - info = qmckl_compute_jastrow_champ_factor_ee_doc_f & - (context, walk_num, elec_num, up_num, bord_num, b_vector, ee_distance_rescaled, asymp_jasb, factor_ee) - - end function qmckl_compute_jastrow_champ_factor_ee_doc - #+end_src - #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none qmckl_exit_code qmckl_compute_jastrow_champ_factor_ee_doc ( const qmckl_context context, @@ -2699,19 +2664,26 @@ qmckl_exit_code qmckl_provide_jastrow_champ_factor_ee_gl(qmckl_context context) | ~factor_ee_gl~ | ~double[walk_num][4][elec_num]~ | out | Electron-electron distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_jastrow_champ_factor_ee_gl_doc_f( & +function qmckl_compute_jastrow_champ_factor_ee_gl_doc( & context, walk_num, elec_num, up_num, bord_num, & b_vector, ee_distance_rescaled, ee_distance_rescaled_gl, & factor_ee_gl) & - result(info) + bind(C) result(info) + use, intrinsic :: iso_c_binding + use qmckl implicit none - integer(qmckl_context), intent(in) :: context - integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num - double precision , intent(in) :: b_vector(bord_num + 1) - double precision , intent(in) :: ee_distance_rescaled(elec_num, elec_num,walk_num) - double precision , intent(in) :: ee_distance_rescaled_gl(4,elec_num, elec_num,walk_num) !TODO - double precision , intent(out) :: factor_ee_gl(elec_num,4,walk_num) + + integer (qmckl_context), 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) :: b_vector(bord_num+1) + real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num) + real (c_double ) , intent(in) :: ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num) + real (c_double ) , intent(out) :: factor_ee_gl(elec_num,4,walk_num) + integer(qmckl_exit_code) :: info integer*8 :: i, j, k, nw, ii double precision :: x, x1, kf @@ -2793,7 +2765,7 @@ integer function qmckl_compute_jastrow_champ_factor_ee_gl_doc_f( & end do -end function qmckl_compute_jastrow_champ_factor_ee_gl_doc_f +end function qmckl_compute_jastrow_champ_factor_ee_gl_doc #+end_src #+begin_src c :comments org :tangle (eval c) :noweb yes @@ -2900,50 +2872,6 @@ qmckl_exit_code qmckl_compute_jastrow_champ_factor_ee_gl_hpc( #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_ee_gl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_jastrow_champ_factor_ee_gl_doc") - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none -integer(c_int32_t) function qmckl_compute_jastrow_champ_factor_ee_gl_doc & - (context, & - walk_num, & - elec_num, & - up_num, & - bord_num, & - b_vector, & - ee_distance_rescaled, & - ee_distance_rescaled_gl, & - factor_ee_gl) & - 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) :: b_vector(bord_num+1) - real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num) - real (c_double ) , intent(in) :: ee_distance_rescaled_gl(elec_num,elec_num,4,walk_num) - real (c_double ) , intent(out) :: factor_ee_gl(elec_num,4,walk_num) - - integer(c_int32_t), external :: qmckl_compute_jastrow_champ_factor_ee_gl_doc_f - info = qmckl_compute_jastrow_champ_factor_ee_gl_doc_f & - (context, & - walk_num, & - elec_num, & - up_num, & - bord_num, & - b_vector, & - ee_distance_rescaled, & - ee_distance_rescaled_gl, & - factor_ee_gl) - - end function qmckl_compute_jastrow_champ_factor_ee_gl_doc - #+end_src - #+begin_src c :tangle (eval h_private_func) :comments org qmckl_exit_code qmckl_compute_jastrow_champ_factor_ee_gl_hpc ( const qmckl_context context, @@ -3264,17 +3192,21 @@ qmckl_exit_code qmckl_provide_ee_distance_rescaled(qmckl_context context) | ~ee_distance~ | ~double[walk_num][elec_num][elec_num]~ | out | Electron-electron rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_ee_distance_rescaled_doc_f(context, elec_num, rescale_factor_ee, walk_num, & +function qmckl_compute_ee_distance_rescaled_doc(context, & + elec_num, rescale_factor_ee, walk_num, & coord, ee_distance_rescaled) & - result(info) + bind(C) result(info) + use, intrinsic :: iso_c_binding use qmckl implicit none - integer(qmckl_context), intent(in) :: context - integer*8 , intent(in) :: elec_num - double precision , intent(in) :: rescale_factor_ee - integer*8 , intent(in) :: walk_num - double precision , intent(in) :: coord(elec_num,walk_num,3) - double precision , intent(out) :: ee_distance_rescaled(elec_num,elec_num,walk_num) + + integer(qmckl_context), intent(in), value :: context + integer (c_int64_t) , intent(in) , value :: elec_num + real (c_double ) , intent(in) , value :: rescale_factor_ee + integer (c_int64_t) , intent(in) , value :: walk_num + real (c_double ) , intent(in) :: coord(elec_num,walk_num,3) + real (c_double ) , intent(out) :: ee_distance_rescaled(elec_num,elec_num,walk_num) + integer(qmckl_exit_code) :: info integer*8 :: k @@ -3305,7 +3237,7 @@ integer function qmckl_compute_ee_distance_rescaled_doc_f(context, elec_num, res endif end do -end function qmckl_compute_ee_distance_rescaled_doc_f +end function qmckl_compute_ee_distance_rescaled_doc #+end_src #+begin_src c :tangle (eval h_private_func) :comments org :exports none @@ -3403,30 +3335,6 @@ qmckl_exit_code qmckl_compute_ee_distance_rescaled ( (context, elec_num, rescale_factor_ee, walk_num, coord, ee_distance_rescaled); } #+end_src - #+CALL: generate_c_interface(table=qmckl_ee_distance_rescaled_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ee_distance_rescaled_doc") - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_ee_distance_rescaled_doc & - (context, elec_num, rescale_factor_ee, walk_num, coord, ee_distance) & - 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 :: elec_num - real (c_double ) , intent(in) , value :: rescale_factor_ee - integer (c_int64_t) , intent(in) , value :: walk_num - real (c_double ) , intent(in) :: coord(elec_num,walk_num,3) - real (c_double ) , intent(out) :: ee_distance(elec_num,elec_num,walk_num) - - integer(c_int32_t), external :: qmckl_compute_ee_distance_rescaled_doc_f - info = qmckl_compute_ee_distance_rescaled_doc_f & - (context, elec_num, rescale_factor_ee, walk_num, coord, ee_distance) - - end function qmckl_compute_ee_distance_rescaled_doc - #+end_src **** Test @@ -3597,27 +3505,30 @@ qmckl_exit_code qmckl_provide_ee_distance_rescaled_gl(qmckl_context context) :END: #+NAME: qmckl_ee_distance_rescaled_gl_args - | Variable | Type | In/Out | Description | - |---------------------+-------------------------------------------+--------+-------------------------------------------------| - | ~context~ | ~qmckl_context~ | in | Global state | - | ~elec_num~ | ~int64_t~ | in | Number of electrons | - | ~rescale_factor_ee~ | ~double~ | in | Factor to rescale ee distances | - | ~walk_num~ | ~int64_t~ | in | Number of walkers | - | ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | - | ~ee_distance_gl~ | ~double[walk_num][4][elec_num][elec_num]~ | out | Electron-electron rescaled distance derivatives | + | Variable | Type | In/Out | Description | + |---------------------------+-------------------------------------------+--------+-------------------------------------------------| + | ~context~ | ~qmckl_context~ | in | Global state | + | ~elec_num~ | ~int64_t~ | in | Number of electrons | + | ~rescale_factor_ee~ | ~double~ | in | Factor to rescale ee distances | + | ~walk_num~ | ~int64_t~ | in | Number of walkers | + | ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | + | ~ee_distance_rescaled_gl~ | ~double[walk_num][elec_num][elec_num][4]~ | out | Electron-electron rescaled distance derivatives | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_ee_distance_rescaled_gl_doc_f(context, elec_num, rescale_factor_ee, walk_num, & - coord, ee_distance_rescaled_gl) & - result(info) +function qmckl_compute_ee_distance_rescaled_gl_doc(context, & + elec_num, rescale_factor_ee, walk_num, coord, ee_distance_rescaled_gl) & + bind(C) result(info) + use, intrinsic :: iso_c_binding use qmckl implicit none - integer(qmckl_context), intent(in) :: context - integer*8 , intent(in) :: elec_num - double precision , intent(in) :: rescale_factor_ee - integer*8 , intent(in) :: walk_num - double precision , intent(in) :: coord(elec_num,walk_num,3) - double precision , intent(out) :: ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num) + + integer(qmckl_context), intent(in), value :: context + integer (c_int64_t) , intent(in) , value :: elec_num + real (c_double ) , intent(in) , value :: rescale_factor_ee + integer (c_int64_t) , intent(in) , value :: walk_num + real (c_double ) , intent(in) :: coord(elec_num,walk_num,3) + real (c_double ) , intent(out) :: ee_distance_rescaled_gl(4,elec_num,elec_num,walk_num) + integer(qmckl_exit_code) :: info integer*8 :: k @@ -3648,7 +3559,7 @@ integer function qmckl_compute_ee_distance_rescaled_gl_doc_f(context, elec_num, endif end do -end function qmckl_compute_ee_distance_rescaled_gl_doc_f +end function qmckl_compute_ee_distance_rescaled_gl_doc #+end_src #+begin_src c :tangle (eval h_private_func) :comments org :exports none @@ -3735,31 +3646,6 @@ qmckl_exit_code qmckl_compute_ee_distance_rescaled_gl ( } #+end_src - #+CALL: generate_c_interface(table=qmckl_ee_distance_rescaled_gl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ee_distance_rescaled_gl_doc") - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_ee_distance_rescaled_gl_doc & - (context, elec_num, rescale_factor_ee, walk_num, coord, ee_distance_gl) & - 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 :: elec_num - real (c_double ) , intent(in) , value :: rescale_factor_ee - integer (c_int64_t) , intent(in) , value :: walk_num - real (c_double ) , intent(in) :: coord(elec_num,walk_num,3) - real (c_double ) , intent(out) :: ee_distance_gl(elec_num,elec_num,4,walk_num) - - integer(c_int32_t), external :: qmckl_compute_ee_distance_rescaled_gl_doc_f - info = qmckl_compute_ee_distance_rescaled_gl_doc_f & - (context, elec_num, rescale_factor_ee, walk_num, coord, ee_distance_gl) - - end function qmckl_compute_ee_distance_rescaled_gl_doc - #+end_src - **** Test #+begin_src python :results output :exports none