subroutine read_cplx_1d_dataset(parent, nm, val, exists, default, required)
integer(hid_t), intent(in) :: parent
character(*), intent(in) :: nm
complex(dp), intent(out), target :: val(:)
logical, intent(out), optional :: exists
logical, intent(in), optional :: required
complex(dp), intent(in), optional :: default(:)
character(*), parameter :: t_r = 'read_dp_1d_dataset'
integer(hid_t) :: dataset, type_id
integer(hdf_err) :: err
integer(hsize_t) :: dims(1)
integer(int32), pointer :: ptr(:)
logical(hdf_log) :: exists_
call h5lexists_f(parent, nm, exists_, err)
if (exists_) then
call h5dopen_f(parent, nm, dataset, err)
call h5dget_type_f(dataset, type_id, err)
! Check dimensions and types.
dims = [size(val, kind=int64)]
call check_dataset_params(dataset, nm, 16_hsize_t, H5T_COMPOUND_F, &
dims)
! And actually read the data.
call ptr_abuse_1d(val, ptr)
call h5dread_f(dataset, type_id, ptr, dims, err)
call h5tclose_f(type_id, err)
call h5dclose_f(dataset, err)
end if
if (present(required)) then
if (required .and. .not. exists_) then
write(stdout, *) nm
call stop_all(t_r, "Required field does not exist")
end if
end if
if (present(exists)) exists = exists_
if (present(default) .and. .not. exists_) val = default
end subroutine read_cplx_1d_dataset