From 4549276e866a30f24bf99beff3b70c6bd66144de Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 4 Jun 2021 15:00:13 +0200 Subject: [PATCH] Add trexio_set_one_based in fortran interface --- src/templates_front/templator_front.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 374dcbb..4e013ff 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -612,6 +612,15 @@ trexio_exit_code trexio_set_one_based(trexio_t* file) } #+end_src + #+begin_src f90 :tangle prefix_fortran.f90 +interface + integer function trexio_set_one_based(trex_file) bind(C) + use, intrinsic :: iso_c_binding + integer(8), intent(in), value :: trex_file + end function trexio_open_c +end interface + #+end_src + ** File closing ~trexio_close~ closes an existing ~trexio_t~ file. @@ -1554,10 +1563,20 @@ contains character(len=*) :: filename character, intent(in), value :: mode integer, intent(in), value :: backend + character(len=len_trim(filename)+1) :: filename_c + integer :: rc filename_c = trim(filename) // c_null_char trexio_open = trexio_open_c(filename_c, mode, backend) + if (trexio_open == 0_8) then + return + endif + rc = trexio_set_one_based(trexio_open) + if (rc /= TREXIO_SUCCESS) then + call trexio_close(trexio_open) + trexio_open = 0_8 + endif end function trexio_open #+end_src