From c388ab97c955e1fd9dffea2e03976d138d63e999 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 25 Jul 2021 09:43:52 +0200 Subject: [PATCH] trying to make sense of HDF5 pointer magic --- src/HDF5_utilities.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 index 37ca2563a..afc6738be 100644 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -312,7 +312,7 @@ subroutine HDF5_addAttribute_str(loc_id,attrLabel,attrValue,path) logical :: attrExists integer :: hdferr character(len=:), allocatable :: p - character(len=len_trim(attrValue)+1,kind=C_CHAR), target :: attrValue_ + character(len=len_trim(attrValue)+1,kind=C_CHAR), dimension(1), target :: attrValue_ type(C_PTR), target, dimension(1) :: ptr @@ -322,8 +322,8 @@ subroutine HDF5_addAttribute_str(loc_id,attrLabel,attrValue,path) p = '.' endif - attrValue_ = trim(attrValue)//C_NULL_CHAR - ptr(1) = c_loc(attrValue_) + attrValue_(1) = trim(attrValue)//C_NULL_CHAR + ptr(1) = c_loc(attrValue_(1)) call h5screate_f(H5S_SCALAR_F,space_id,hdferr) if(hdferr < 0) error stop 'HDF5 error' @@ -339,7 +339,7 @@ subroutine HDF5_addAttribute_str(loc_id,attrLabel,attrValue,path) call h5acreate_by_name_f(loc_id,trim(p),trim(attrLabel),type_id,space_id,attr_id,hdferr) if(hdferr < 0) error stop 'HDF5 error' - call h5awrite_f(attr_id, type_id, c_loc(ptr(1)), hdferr) + call h5awrite_f(attr_id, type_id, ptr, hdferr) if(hdferr < 0) error stop 'HDF5 error' call h5aclose_f(attr_id,hdferr) @@ -452,7 +452,7 @@ subroutine HDF5_addAttribute_str_array(loc_id,attrLabel,attrValue,path) character(len=*), intent(in), dimension(:) :: attrValue character(len=*), intent(in), optional :: path - integer(HID_T) :: attr_id, space_id, filetype_id, type_id + integer(HID_T) :: attr_id, space_id, type_id logical :: attrExists integer :: hdferr,i character(len=:), allocatable :: p