1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-11-03 20:54:07 +01:00

more fortran-ic interface + flexible dtypes for dsets

This commit is contained in:
q-posev 2021-03-24 16:05:38 +01:00
parent 8d3b35736c
commit f7c78e73d2
2 changed files with 28 additions and 17 deletions

View File

@ -82,6 +82,7 @@ templ_path_front = join(fileDir,'templates_front')
files_exclude = ['prefix_hdf5.c', 'prefix_hdf5.h', 'suffix_hdf5.h', files_exclude = ['prefix_hdf5.c', 'prefix_hdf5.h', 'suffix_hdf5.h',
'prefix_text.c', 'prefix_text.h', 'suffix_text.h', 'prefix_text.c', 'prefix_text.h', 'suffix_text.h',
'prefix_front.c', 'prefix_front.h', 'suffix_front.h', 'prefix_front.c', 'prefix_front.h', 'suffix_front.h',
'prefix_fortran.f90', 'suffix_fortran.f90',
'prefix_s_front.h', 'suffix_s_front.h', 'prefix_s_front.h', 'suffix_s_front.h',
'templator_front.org', 'templator_hdf5.org', 'templator_text.org'] 'templator_front.org', 'templator_hdf5.org', 'templator_text.org']
@ -259,12 +260,16 @@ for fname in files_funcs_dsets:
if params['dtype'] == 'double': if params['dtype'] == 'double':
h5_dtype = 'double' h5_dtype = 'double'
f_dtype = 'real(8)'
elif params['dtype'] == 'int64_t': elif params['dtype'] == 'int64_t':
h5_dtype = 'long' h5_dtype = 'long'
f_dtype = 'integer(8)'
templine1 = templine2.replace('$group_dset_h5_dtype$', h5_dtype) templine1 = templine2.replace('$group_dset_h5_dtype$', h5_dtype)
templine2 = templine1.replace('$group_dset_h5_dtype$'.upper(), h5_dtype.upper()) templine2 = templine1.replace('$group_dset_h5_dtype$'.upper(), h5_dtype.upper())
templine1 = templine2.replace('$group_dset_f_dtype$', f_dtype)
templine2 = templine1.replace('$group_dset_f_dtype$'.upper(), f_dtype.upper())
templine1 = templine2.replace('$group_dset_rank$', str(params['rank'])) templine1 = templine2.replace('$group_dset_rank$', str(params['rank']))
templine2 = templine1 templine2 = templine1

View File

@ -16,6 +16,12 @@
module trexio module trexio
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
implicit none
integer, parameter :: TREXIO_HDF5 = 0
integer, parameter :: TREXIO_TEXT = 1
! integer, parameter :: TREXIO_JSON = 2
integer, parameter :: TREXIO_INVALID_BACK_END = 3
#+end_src #+end_src
@ -289,11 +295,11 @@ trexio_t* trexio_open(const char* file_name, const char mode, const back_end_t b
#+begin_src fortran :tangle prefix_fortran.f90 #+begin_src fortran :tangle prefix_fortran.f90
interface interface
type (c_ptr) function trexio_open (filename, mode, backend) bind(C) integer(8) function trexio_open (filename, mode, backend) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
character(kind=c_char), dimension(*) :: filename character(kind=c_char), dimension(*) :: filename
character(kind=c_char), intent(in), value :: mode character, intent(in), value :: mode
integer (c_int32_t), intent(in), value :: backend integer, intent(in), value :: backend
end function trexio_open end function trexio_open
end interface end interface
#+end_src #+end_src
@ -374,9 +380,9 @@ trexio_exit_code trexio_close(trexio_t* file) {
#+begin_src fortran :tangle prefix_fortran.f90 #+begin_src fortran :tangle prefix_fortran.f90
interface interface
integer (c_int32_t) function trexio_close (trex_file) bind(C) integer function trexio_close (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
type (c_ptr), intent(in), value :: trex_file integer(8), intent(in), value :: trex_file
end function trexio_close end function trexio_close
end interface end interface
#+end_src #+end_src
@ -452,10 +458,10 @@ trexio_exit_code trexio_write_$group_num$(trexio_t* file, const int64_t num) {
#+begin_src fortran :tangle write_num_front_fortran.f90 #+begin_src fortran :tangle write_num_front_fortran.f90
interface interface
integer (c_int32_t) function trexio_write_$group_num$ (trex_file, num) bind(C) integer function trexio_write_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
type (c_ptr), intent(in), value :: trex_file integer(8), intent(in), value :: trex_file
integer (c_int64_t), intent(in), value :: num integer(8), intent(in), value :: num
end function trexio_write_$group_num$ end function trexio_write_$group_num$
end interface end interface
@ -465,10 +471,10 @@ end interface
#+begin_src fortran :tangle read_num_front_fortran.f90 #+begin_src fortran :tangle read_num_front_fortran.f90
interface interface
integer (c_int32_t) function trexio_read_$group_num$ (trex_file, num) bind(C) integer function trexio_read_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
type (c_ptr), intent(in), value :: trex_file integer(8), intent(in), value :: trex_file
type (c_ptr), value :: num integer(8), intent(out) :: num
end function trexio_read_$group_num$ end function trexio_read_$group_num$
end interface end interface
@ -586,10 +592,10 @@ trexio_exit_code trexio_write_$group$_$group_dset$(trexio_t* file, const $group_
#+begin_src fortran :tangle write_dset_front_fortran.f90 #+begin_src fortran :tangle write_dset_front_fortran.f90
interface interface
integer (c_int32_t) function trexio_write_$group$_$group_dset$ (trex_file, dset) bind(C) integer function trexio_write_$group$_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
type (c_ptr), intent(in), value :: trex_file integer(8), intent(in), value :: trex_file
type (c_ptr), value :: dset $group_dset_f_dtype$, intent(in) :: dset(*)
end function trexio_write_$group$_$group_dset$ end function trexio_write_$group$_$group_dset$
end interface end interface
@ -598,10 +604,10 @@ end interface
#+begin_src fortran :tangle read_dset_front_fortran.f90 #+begin_src fortran :tangle read_dset_front_fortran.f90
interface interface
integer (c_int32_t) function trexio_read_$group$_$group_dset$ (trex_file, dset) bind(C) integer function trexio_read_$group$_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
type (c_ptr), intent(in), value :: trex_file integer(8), intent(in), value :: trex_file
type (c_ptr), value :: dset $group_dset_f_dtype$, intent(out) :: dset(*)
end function trexio_read_$group$_$group_dset$ end function trexio_read_$group$_$group_dset$
end interface end interface