WriteArray_HDF5_real_r3_parallel Subroutine

private subroutine WriteArray_HDF5_real_r3_parallel(fileId, arrayName, hfArray, offset, globalDims)

Arguments

TypeIntentOptionalAttributesName
integer(kind=HID_T), intent(in) :: fileId
character, intent(in) :: arrayName
real(kind=prec), intent(in), dimension(:,:,:):: hfArray
integer(kind=HID_T), intent(in) :: offset(1:3)
integer(kind=HID_T), intent(in) :: globalDims(1:3)

Contents


Source Code

  subroutine WriteArray_HDF5_real_r3_parallel(fileId,arrayName,hfArray,offset,globalDims)
    implicit none
    integer(HID_T),intent(in) :: fileId
    character(*),intent(in) :: arrayName
    integer(HID_T),intent(in) :: offset(1:3)
    real(prec),dimension(:,:,:),intent(in) :: hfArray
    integer(HID_T),intent(in) :: globalDims(1:3)
    ! Local
    integer(HID_T) :: plistId
    integer(HID_T) :: dsetId
    integer(HID_T) :: filespace
    integer(HID_T) :: memspace
    integer(HSIZE_T) :: dims(1:3)
    integer :: error

    dims = shape(hfArray)

    call h5screate_simple_f(3,globalDims,filespace,error)
    call h5screate_simple_f(3,dims,memspace,error)

    call h5dcreate_f(fileId,trim(arrayName),HDF5_IO_PREC,filespace,dsetId,error)

    call h5sselect_hyperslab_f(filespace, &
                               H5S_SELECT_SET_F, &
                               offset, &
                               dims, &
                               error)

    call h5pcreate_f(H5P_DATASET_XFER_F,plistId,error)
    call h5pset_dxpl_mpio_f(plistId,H5FD_MPIO_COLLECTIVE_F,error)
    call h5dwrite_f(dsetId,HDF5_IO_PREC,hfArray,dims,error, &
                    mem_space_id=memspace,file_space_id=filespace,xfer_prp=plistId)

    if(error /= 0) then
      print*,'Failure to write dataset'
      stop 1
    endif

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

  endsubroutine WriteArray_HDF5_real_r3_parallel