WriteCharacter_HDF5_serial Subroutine

private subroutine WriteCharacter_HDF5_serial(fileId, name, hfField)

Arguments

TypeIntentOptionalAttributesName
integer(kind=HID_T), intent(in) :: fileId
character(len=*), intent(in) :: name
character(len=*), intent(in) :: hfField

Calls

proc~~writecharacter_hdf5_serial~~CallsGraph proc~writecharacter_hdf5_serial WriteCharacter_HDF5_serial h5tcopy_f h5tcopy_f proc~writecharacter_hdf5_serial->h5tcopy_f h5sclose_f h5sclose_f proc~writecharacter_hdf5_serial->h5sclose_f h5dwrite_vl_f h5dwrite_vl_f proc~writecharacter_hdf5_serial->h5dwrite_vl_f h5tset_strpad_f h5tset_strpad_f proc~writecharacter_hdf5_serial->h5tset_strpad_f h5screate_simple_f h5screate_simple_f proc~writecharacter_hdf5_serial->h5screate_simple_f h5dcreate_f h5dcreate_f proc~writecharacter_hdf5_serial->h5dcreate_f h5dclose_f h5dclose_f proc~writecharacter_hdf5_serial->h5dclose_f

Called by

proc~~writecharacter_hdf5_serial~~CalledByGraph proc~writecharacter_hdf5_serial WriteCharacter_HDF5_serial interface~writecharacter_hdf5 WriteCharacter_HDF5 interface~writecharacter_hdf5->proc~writecharacter_hdf5_serial proc~writehdf5_metadata WriteHDF5_Metadata proc~writehdf5_metadata->interface~writecharacter_hdf5

Contents


Source Code

  subroutine WriteCharacter_HDF5_serial(fileid,name,hfField)
    ! adapted from https://forum.hdfgroup.org/t/writing-a-string-array-as-attribute-in-fortran/8503/6
    implicit none
    integer(HID_T),intent(in) :: fileId
    character(len=*),intent(in) :: name
    character(len=*),intent(in) :: hfField
    ! Local
    integer(HID_T) :: h5_strtype,h5_dspace,h5_dset
    integer(HSIZE_T),dimension(2) :: size
    character(len=len(hfField)+1),dimension(1) :: str_data
    integer(SIZE_T),dimension(1) :: str_len
    integer :: error

    ! string output requires to open a file local = non-parallel

    str_len(1) = len_trim(hfField)
    size(1) = str_len(1)
    size(2) = 1
    str_data(1) = hfField//char(0)

    ! create data space
    call H5Tcopy_f(H5T_STRING,h5_strtype,error)
    call H5Tset_strpad_f(h5_strtype,H5T_STR_NULLPAD_F,error)
    call h5screate_simple_f(1,size(2),h5_dspace,error)
    call h5dcreate_f(fileid,trim(name),h5_strtype,h5_dspace,h5_dset,error)
    call h5dwrite_vl_f(h5_dset,h5_strtype,str_data,size,str_len,error,h5_dspace)
    call h5dclose_f(h5_dset,error)
    call h5sclose_f(h5_dspace,error)

  endsubroutine WriteCharacter_HDF5_serial