1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-11-03 12:43:55 +01:00

Merge pull request #145 from stefabat/master

Fix interface return type and remove unused dummy argument
This commit is contained in:
Evgeny Posenitskiy 2024-05-13 15:15:01 +02:00 committed by GitHub
commit cffdef1dc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4521,7 +4521,7 @@ end interface
if (rc /= TREXIO_SUCCESS) then if (rc /= TREXIO_SUCCESS) then
trexio_write_$group_dset$ = rc trexio_write_$group_dset$ = rc
else else
call trexio_strarray2str(dset, $group_dset_dim$, max_str_len, str_compiled) call trexio_strarray2str(dset, $group_dset_dim$, str_compiled)
trexio_write_$group_dset$ = trexio_write_$group_dset$_low(trex_file, str_compiled, max_str_len) trexio_write_$group_dset$ = trexio_write_$group_dset$_low(trex_file, str_compiled, max_str_len)
endif endif
@ -6332,9 +6332,9 @@ trexio_mark_safety (trexio_t* const file, const int32_t safety_flag)
#+begin_src f90 :tangle prefix_fortran.f90 #+begin_src f90 :tangle prefix_fortran.f90
interface interface
integer function trexio_info () bind(C) integer(c_int32_t) function trexio_info_c () bind(C, name="trexio_info")
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
end function trexio_info end function trexio_info_c
end interface end interface
#+end_src #+end_src
@ -6647,13 +6647,20 @@ def evaluate_nao_radial_all(nucleus_index, nucleus_coords, grid_start,
* Fortran helper/wrapper functions * Fortran helper/wrapper functions
#+begin_src f90 :tangle helper_fortran.f90
contains
integer function trexio_info ()
implicit none
trexio_info = trexio_info_c()
end function trexio_info
#+end_src
The function below adapts the original C-based ~trexio_open~ for Fortran. The function below adapts the original C-based ~trexio_open~ for Fortran.
This is needed due to the fact that strings in C are terminated by ~NULL~ character ~\0~ This is needed due to the fact that strings in C are terminated by ~NULL~ character ~\0~
unlike strings in Fortran. unlike strings in Fortran.
Note, that Fortran interface calls the main ~TREXIO~ API, which is written in C. Note, that Fortran interface calls the main ~TREXIO~ API, which is written in C.
#+begin_src f90 :tangle helper_fortran.f90 #+begin_src f90 :tangle helper_fortran.f90
contains
integer(trexio_t) function trexio_open (filename, mode, back_end, rc_open) integer(trexio_t) function trexio_open (filename, mode, back_end, rc_open)
use, intrinsic :: iso_c_binding, only : c_null_char use, intrinsic :: iso_c_binding, only : c_null_char
implicit none implicit none
@ -6790,12 +6797,11 @@ contains
C API. This is needed due to the fact that strings in C are terminated by ~NULL~ character ~\0~. C API. This is needed due to the fact that strings in C are terminated by ~NULL~ character ~\0~.
#+begin_src f90 :tangle helper_fortran.f90 #+begin_src f90 :tangle helper_fortran.f90
subroutine trexio_strarray2str(str_array, max_num_str, max_len_str, str_res) subroutine trexio_strarray2str(str_array, max_num_str, str_res)
use, intrinsic :: iso_c_binding, only : c_null_char use, intrinsic :: iso_c_binding, only : c_null_char
implicit none implicit none
integer(c_int64_t), intent(in), value :: max_num_str ! number of elements in strign array integer(c_int64_t), intent(in), value :: max_num_str ! number of elements in string array
integer, intent(in), value :: max_len_str ! maximum length of a string in an array
character(len=*), intent(in) :: str_array(*) character(len=*), intent(in) :: str_array(*)
character(len=:), allocatable, intent(out) :: str_res character(len=:), allocatable, intent(out) :: str_res
integer(c_int64_t) :: i integer(c_int64_t) :: i