jrglez
jrglez

Reputation: 238

Error opening a file with h5fopen_f in FORTRAN / MPI / HDF5 ( 1.10.1 )

I am using a Fortran code that uses HDF5 (1.10.1). At some point there is a call to open a file using h5fopen_f:

H5FileName = "+hdf5/Temperature_00000_00001.h5"
CALL h5fopen_f(H5FileName, H5F_ACC_RDWR_F, file, hdferr)
Scalardataset = 'Temperature_00001_0000'
call h5ltget_dataset_info_f(file, Scalardataset, dimstmp, type_class, type_size, hdferr)
call h5fclose_f(file,hdferr)

which is giving me an error:

HDF5-DIAG: Error detected in HDF5 (1.10.1) MPI-process 0:
  #000: H5F.c line 586 in H5Fopen(): unable to open file
    major: File accessibilty
    minor: Unable to open file
  #001: H5Fint.c line 1305 in H5F_open(): unable to lock the file
    major: File accessibilty
    minor: Unable to open file
  #002: H5FD.c line 1839 in H5FD_lock(): driver lock request failed
    major: Virtual File Layer
    minor: Can't update object
  #003: H5FDsec2.c line 940 in H5FD_sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: File accessibilty
    minor: Bad file ID accessed

I have checked that the file exists, it's where it should and that I have the right permissions. Also, the code works fine when I just use one process, and when I use more than one, one of the processes is able to open the file ( err=0 ), but the rest can't ( err=-1 ). Finally, I have this same code installed somewhere else and it works just fine (with version 1.8.14).

Can this be a problem with the version?

Upvotes: 4

Views: 2358

Answers (2)

William Gurecky
William Gurecky

Reputation: 158

I had a very similar issue with HDF5 1.10.1. We are using multiple readers to access a file in H5F_ACC_RDONLY mode.

Disabling file locking by setting the environment variable seems to resolve the H5FDsec2.c line 940 in H5FD_sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable':

export HDF5_USE_FILE_LOCKING="FALSE"

This env var is checked at runtime by hdf5. See: https://support.hdfgroup.org/ftp/HDF5/current/src/unpacked/release_docs/RELEASE.txt

Upvotes: 1

jrglez
jrglez

Reputation: 238

I found two ways of fixing this:

  • Opening the files as read only, using H5F_ACC_RDONLY_F instead of H5F_ACC_RDWR_F (this is fine for me because I don't need to write.
  • Recompiling everything using HDF5 1.8.14. I guess that read and write permissions are more restrictive in version 1.10.x than in version 1.8.x.

Ideally I would like to be able to use a more up to date version of HDF5 together with H5F_ACC_RDWR_F, but for now it works for me.

Upvotes: 2

Related Questions