From ac44fc29a64b74d2b953103ce7b9a637663e75bc Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 22 Mar 2021 16:40:45 +0100 Subject: [PATCH] add test, works for h5 but failt for txt --- src/templates_front/templator_front.org | 11 +++++------ src/test.f90 | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 src/test.f90 diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index dc7867d..111184d 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -12,7 +12,6 @@ #+end_src #+begin_src fortran :tangle prefix_fortran.f90 :noweb yes -<
> module trexio @@ -292,9 +291,9 @@ trexio_t* trexio_open(const char* file_name, const char mode, const back_end_t b interface type (c_ptr) function trexio_open (filename, mode, backend) bind(C) use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: filename - character(kind=c_char), intent(in) :: mode - integer (c_int32_t), intent(in), value :: backend + character(kind=c_char), dimension(*) :: filename + character(kind=c_char), intent(in), value :: mode + integer (c_int32_t), intent(in), value :: backend end function trexio_open end interface #+end_src @@ -375,7 +374,7 @@ trexio_exit_code trexio_close(trexio_t* file) { #+begin_src fortran :tangle prefix_fortran.f90 interface - type (c_int32_t) function trexio_close (trex_file) bind(C) + integer (c_int32_t) function trexio_close (trex_file) bind(C) use, intrinsic :: iso_c_binding type (c_ptr), intent(in), value :: trex_file end function trexio_close @@ -469,7 +468,7 @@ interface integer (c_int32_t) function trexio_read_$group_num$ (trex_file, num) bind(C) use, intrinsic :: iso_c_binding type (c_ptr), intent(in), value :: trex_file - integer (c_int64_t), intent(inout), value :: num + integer (c_int64_t), value :: num end function trexio_read_$group_num$ end interface diff --git a/src/test.f90 b/src/test.f90 new file mode 100644 index 0000000..3e44ab8 --- /dev/null +++ b/src/test.f90 @@ -0,0 +1,24 @@ +program test_trexio + + use trexio + + implicit none + + type(c_ptr) :: file1 + + integer :: rc + integer (c_int64_t) :: num + + rc = 0 + num = 10 + + file1 = trexio_open('test_fort' // c_null_char, 'w', 1) +! file1 = trexio_open('test_fort.h5' // c_null_char, 'w', 0) + + rc = trexio_write_nucleus_num(file1, num) + if (rc == 0) write(*,*) 'SUCCESS 1' + + rc = trexio_close(file1) + if (rc == 0) write(*,*) 'SUCCESS 2' + +end program test_trexio