subroutine Open_HDF5_parallel(fileName,accessFlag,fileId,mpiComm)
implicit none
character(*),intent(in) :: fileName
integer,intent(in) :: accessFlag
integer(HID_T),intent(inout) :: fileId
integer,intent(in) :: mpiComm
! Local
integer(HID_T) :: plistId
integer :: error
call h5open_f(error)
call h5pcreate_f(H5P_FILE_ACCESS_F,plistId,error)
call h5pset_fapl_mpio_f(plistId,mpiComm,MPI_INFO_NULL,error)
if(accessFlag == H5F_ACC_TRUNC_F) then
call h5fcreate_f(trim(fileName),accessFlag,fileId,error,access_prp=plistId)
else
call h5fopen_f(trim(fileName),accessFlag,fileId,error,access_prp=plistId)
endif
call h5pclose_f(plistId,error)
if(error == -1) then
print*,'Failed to open '//trim(fileName)//'.'
stop 1
endif
endsubroutine Open_HDF5_parallel