WriteSetArray_HDF5 Subroutine

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

Create arrayName with shape (Np,Np,Np,nGlobalElem) and write this rank's block hfArray(1:Np,1:Np,1:Np,1:nLocal) at element offset elemOffset.

Input - fileId : open HDF5 file - arrayName : dataset path; its group must exist - hfArray(Np,Np,Np,nLocal) : this rank's elements; nLocal may be 0 - elemOffset : set-global elements on lower ranks - nGlobalElem : set-global element count, >= 1 - parallel : .true. for a file opened with the MPI-IO driver

Arguments

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

Calls

proc~~writesetarray_hdf5~~CallsGraph proc~writesetarray_hdf5 WriteSetArray_HDF5 h5sclose_f h5sclose_f proc~writesetarray_hdf5->h5sclose_f h5dclose_f h5dclose_f proc~writesetarray_hdf5->h5dclose_f h5sselect_hyperslab_f h5sselect_hyperslab_f proc~writesetarray_hdf5->h5sselect_hyperslab_f h5sselect_none_f h5sselect_none_f proc~writesetarray_hdf5->h5sselect_none_f h5dcreate_f h5dcreate_f proc~writesetarray_hdf5->h5dcreate_f h5kind_to_type h5kind_to_type proc~writesetarray_hdf5->h5kind_to_type h5screate_simple_f h5screate_simple_f proc~writesetarray_hdf5->h5screate_simple_f h5pcreate_f h5pcreate_f proc~writesetarray_hdf5->h5pcreate_f h5pset_dxpl_mpio_f h5pset_dxpl_mpio_f proc~writesetarray_hdf5->h5pset_dxpl_mpio_f h5dwrite_f h5dwrite_f proc~writesetarray_hdf5->h5dwrite_f h5pclose_f h5pclose_f proc~writesetarray_hdf5->h5pclose_f

Called by

proc~~writesetarray_hdf5~~CalledByGraph proc~writesetarray_hdf5 WriteSetArray_HDF5 proc~write_multisetmodel3d_t Write_MultiSetModel3D_t proc~write_multisetmodel3d_t->proc~writesetarray_hdf5

Contents

Source Code


Source Code

  subroutine WriteSetArray_HDF5(fileId,arrayName,hfArray,elemOffset,nGlobalElem,parallel)
    !! Create arrayName with shape (Np,Np,Np,nGlobalElem) and write this rank's block
    !! hfArray(1:Np,1:Np,1:Np,1:nLocal) at element offset elemOffset.
    !!
    !!  Input
    !!    - fileId : open HDF5 file
    !!    - arrayName : dataset path; its group must exist
    !!    - hfArray(Np,Np,Np,nLocal) : this rank's elements; nLocal may be 0
    !!    - elemOffset : set-global elements on lower ranks
    !!    - nGlobalElem : set-global element count, >= 1
    !!    - parallel : .true. for a file opened with the MPI-IO driver
    implicit none
    integer(HID_T),intent(in) :: fileId
    character(*),intent(in) :: arrayName
    real(prec),intent(in) :: 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),globalDims(1:4),offset(1:4)
    integer :: error

    dtype = h5kind_to_type(prec,H5_REAL_KIND)
    dims = shape(hfArray)
    globalDims = (/dims(1),dims(2),dims(3),int(nGlobalElem,HSIZE_T)/)
    offset = (/0_hsize_t,0_hsize_t,0_hsize_t,int(elemOffset,HSIZE_T)/)

    call h5screate_simple_f(4,globalDims,filespace,error)
    call h5screate_simple_f(4,dims,memspace,error)
    call h5dcreate_f(fileId,trim(arrayName),dtype,filespace,dsetId,error)
    if(error /= 0) then
      print*,__FILE__," : failed to create ",trim(arrayName)
      error stop "WriteSetArray_HDF5 : dataset creation failed"
    endif

    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 h5dwrite_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 write ",trim(arrayName)
      error stop "WriteSetArray_HDF5 : write failed"
    endif

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

  endsubroutine WriteSetArray_HDF5