1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-31 16:45:59 +01:00

working read_num [fortran]

This commit is contained in:
q-posev 2021-03-23 16:34:13 +01:00
parent d680120efe
commit 0a28b5e5a5
2 changed files with 16 additions and 4 deletions

View File

@ -468,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), value :: num
type (c_ptr), value :: num
end function trexio_read_$group_num$
end interface

View File

@ -7,18 +7,30 @@ program test_trexio
type(c_ptr) :: file1
integer :: rc
integer (c_int64_t) :: num
integer (c_int64_t) :: num
type(c_ptr) :: num_test
integer, pointer :: num_read
integer, target :: num666
rc = 0
num = 10
num_test = c_loc(num666)
file1 = trexio_open('trexio_test' // 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'
if (rc == 0) write(*,*) 'SUCCESS WRITE'
rc = trexio_read_nucleus_num(file1, num_test)
call c_f_pointer(num_test, num_read)
if (rc == 0 .and. num_read == num) write(*,*) 'SUCCESS READ'
rc = trexio_close(file1)
if (rc == 0) write(*,*) 'SUCCESS 2'
if (rc == 0) write(*,*) 'SUCCESS CLOSE'
end program test_trexio