diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2024-03-07 11:34:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 11:34:55 (GMT) |
commit | 9d8e8824964af3137b9e4cd400b9b45304fd86ef (patch) | |
tree | db1a7d4d52b5bbca7e368356a12c96e0ec454d5c /fortran/src/H5fortkit.F90 | |
parent | fe5d0d5c535b34b20171d0d7540b11e11412755c (diff) | |
download | hdf5-9d8e8824964af3137b9e4cd400b9b45304fd86ef.zip hdf5-9d8e8824964af3137b9e4cd400b9b45304fd86ef.tar.gz hdf5-9d8e8824964af3137b9e4cd400b9b45304fd86ef.tar.bz2 |
Added new H5E with tests. (#4049)
Added Fortran H5E APIs:
h5eregister_class_f, h5eunregister_class_f, h5ecreate_msg_f, h5eclose_msg_f
h5eget_msg_f, h5epush_f, h5eget_num_f, h5ewalk_f, h5eget_class_name_f,
h5eappend_stack_f, h5eget_current_stack_f, h5eset_current_stack_f, h5ecreate_stack_f,
h5eclose_stack_f, h5epop_f, h5eprint_f (C h5eprint v2 signature)
Addresses Issue #3987
Diffstat (limited to 'fortran/src/H5fortkit.F90')
-rw-r--r-- | fortran/src/H5fortkit.F90 | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/fortran/src/H5fortkit.F90 b/fortran/src/H5fortkit.F90 index b745c22..70d7087 100644 --- a/fortran/src/H5fortkit.F90 +++ b/fortran/src/H5fortkit.F90 @@ -25,6 +25,8 @@ !***** MODULE H5fortkit + USE H5FORTRAN_TYPES, ONLY : SIZE_T + CONTAINS !****if* H5fortkit/HD5c2fstring @@ -32,28 +34,35 @@ CONTAINS ! HD5c2fstring ! INPUTS ! cstring - C string stored as a string array of size 'len' of string size LEN=1 -! len - length of Fortran string +! f_len - length of Fortran string +! c_len - length of C array ! OUTPUT -! fstring - Fortran string array of LEN=1 +! fstring - Fortran string LEN=1 ! PURPOSE -! Copies a Fortran array of strings having a length of one to a fortran string and removes the C Null +! Copies a C array of strings having a length of one to a fortran string and removes the C Null ! terminator. The Null terminator is returned from C when calling the C APIs directly. ! ! The fortran standard does not allow C_LOC to be used on a character string of ! length greater than one, which is why we use the array of characters instead. ! ! SOURCE - SUBROUTINE HD5c2fstring(fstring,cstring,len) + SUBROUTINE HD5c2fstring(fstring,cstring,f_len,c_len) !***** IMPLICIT NONE - INTEGER :: i - INTEGER :: len - CHARACTER(LEN=len) :: fstring - CHARACTER(LEN=1), DIMENSION(1:len) :: cstring + INTEGER(SIZE_T) :: i + INTEGER(SIZE_T) :: f_len + INTEGER(SIZE_T) :: c_len + CHARACTER(*) :: fstring + CHARACTER(LEN=1), DIMENSION(1:c_len) :: cstring + + INTEGER(SIZE_T) :: f_len_max fstring = '' - DO i = 1, len + f_len_max = LEN(fstring, KIND=SIZE_T) + DO i = 1, c_len + IF (i .GT. f_len_max) EXIT + IF (i .GT. f_len) EXIT IF (cstring(i)(1:1)==CHAR(0)) EXIT fstring(i:i) = cstring(i)(1:1) END DO |