ReadSetArray_HDF5 Subroutine

public subroutine ReadSetArray_HDF5(fileId, arrayName, hfArray, elemOffset, nGlobalElem, parallel)

Read this rank's block of arrayName, elements elemOffset+1 .. elemOffset+nLocal, into hfArray(1:Np,1:Np,1:Np,1:nLocal). nLocal may be 0.

The dataset must have shape (Np,Np,Np,nGlobalElem), matching hfArray's nodal extents: a dataset written at another polynomial degree holds values at other nodes, so this stops rather than reading a sub-block of it. The check uses only the dataset's metadata, so every rank, including one with nLocal = 0, reaches the same decision.

Arguments

TypeIntentOptionalAttributesName
integer(kind=HID_T), intent(in) :: fileId
character, intent(in) :: arrayName
real(kind=prec), intent(inout) :: hfArray(:,:,:,:)
integer, intent(in) :: elemOffset
integer, intent(in) :: nGlobalElem
logical, intent(in) :: parallel

Calls

proc~~readsetarray_hdf5~~CallsGraph proc~readsetarray_hdf5 ReadSetArray_HDF5 h5pcreate_f h5pcreate_f proc~readsetarray_hdf5->h5pcreate_f h5pset_dxpl_mpio_f h5pset_dxpl_mpio_f proc~readsetarray_hdf5->h5pset_dxpl_mpio_f h5sclose_f h5sclose_f proc~readsetarray_hdf5->h5sclose_f h5dclose_f h5dclose_f proc~readsetarray_hdf5->h5dclose_f h5dopen_f h5dopen_f proc~readsetarray_hdf5->h5dopen_f h5sget_simple_extent_dims_f h5sget_simple_extent_dims_f proc~readsetarray_hdf5->h5sget_simple_extent_dims_f h5kind_to_type h5kind_to_type proc~readsetarray_hdf5->h5kind_to_type h5dget_space_f h5dget_space_f proc~readsetarray_hdf5->h5dget_space_f h5sget_simple_extent_ndims_f h5sget_simple_extent_ndims_f proc~readsetarray_hdf5->h5sget_simple_extent_ndims_f h5screate_simple_f h5screate_simple_f proc~readsetarray_hdf5->h5screate_simple_f h5sselect_hyperslab_f h5sselect_hyperslab_f proc~readsetarray_hdf5->h5sselect_hyperslab_f h5sselect_none_f h5sselect_none_f proc~readsetarray_hdf5->h5sselect_none_f h5pclose_f h5pclose_f proc~readsetarray_hdf5->h5pclose_f h5dread_f h5dread_f proc~readsetarray_hdf5->h5dread_f

Called by

proc~~readsetarray_hdf5~~CalledByGraph proc~readsetarray_hdf5 ReadSetArray_HDF5 proc~read_multisetmodel3d_t Read_MultiSetModel3D_t proc~read_multisetmodel3d_t->proc~readsetarray_hdf5

Contents

Source Code


Source Code

  subroutine ReadSetArray_HDF5(fileId,arrayName,hfArray,elemOffset,nGlobalElem,parallel)
    !! Read this rank's block of arrayName, elements elemOffset+1 .. elemOffset+nLocal,
    !! into hfArray(1:Np,1:Np,1:Np,1:nLocal). nLocal may be 0.
    !!
    !! The dataset must have shape (Np,Np,Np,nGlobalElem), matching hfArray's nodal
    !! extents: a dataset written at another polynomial degree holds values at other
    !! nodes, so this stops rather than reading a sub-block of it. The check uses only
    !! the dataset's metadata, so every rank, including one with nLocal = 0, reaches the
    !! same decision.
    implicit none
    integer(HID_T),intent(in) :: fileId
    character(*),intent(in) :: arrayName
    real(prec),intent(inout) :: hfArray(:,:,:,:)
    integer,intent(in) :: elemOffset
    integer,intent(in) :: nGlobalElem
    logical,intent(in) :: parallel
    ! Local
    integer(HID_T) :: dsetId,filespace,memspace,plistId,dtype
    integer(HSIZE_T) :: dims(1:4),offset(1:4),fileDims(1:4),maxDims(1:4)
    integer :: error,ndims

    dtype = h5kind_to_type(prec,H5_REAL_KIND)
    dims = shape(hfArray)
    offset = (/0_hsize_t,0_hsize_t,0_hsize_t,int(elemOffset,HSIZE_T)/)

    call h5dopen_f(fileId,trim(arrayName),dsetId,error)
    if(error /= 0) then
      print*,__FILE__," : failed to open ",trim(arrayName)
      error stop "ReadSetArray_HDF5 : dataset open failed"
    endif
    call h5dget_space_f(dsetId,filespace,error)
    call h5sget_simple_extent_ndims_f(filespace,ndims,error)
    if(ndims /= 4) then
      print*,__FILE__," : ",trim(arrayName)," has rank ",ndims,", expected 4"
      error stop "ReadSetArray_HDF5 : dataset shape mismatch"
    endif
    call h5sget_simple_extent_dims_f(filespace,fileDims,maxDims,error)
    if(any(fileDims(1:3) /= dims(1:3)) .or. fileDims(4) /= int(nGlobalElem,HSIZE_T)) then
      print*,__FILE__," : ",trim(arrayName)," has shape ",fileDims, &
        ", expected ",dims(1:3),nGlobalElem
      error stop "ReadSetArray_HDF5 : dataset shape mismatch"
    endif
    call h5screate_simple_f(4,dims,memspace,error)

    if(dims(4) > 0) then
      call h5sselect_hyperslab_f(filespace,H5S_SELECT_SET_F,offset,dims,error)
    else
      call h5sselect_none_f(filespace,error)
      call h5sselect_none_f(memspace,error)
    endif

    call h5pcreate_f(H5P_DATASET_XFER_F,plistId,error)
    if(parallel) call h5pset_dxpl_mpio_f(plistId,H5FD_MPIO_COLLECTIVE_F,error)
    call h5dread_f(dsetId,dtype,hfArray,dims,error, &
                   mem_space_id=memspace,file_space_id=filespace,xfer_prp=plistId)
    if(error /= 0) then
      print*,__FILE__," : failed to read ",trim(arrayName)
      error stop "ReadSetArray_HDF5 : read failed"
    endif

    call h5pclose_f(plistId,error)
    call h5sclose_f(memspace,error)
    call h5sclose_f(filespace,error)
    call h5dclose_f(dsetId,error)

  endsubroutine ReadSetArray_HDF5