Writing XDMF in parallel computing

Hi, I am trying to use parallel computing method and write a XDMF file as a result.

from dolfin import *
import math
from mpi4py import MPI

comm = MPI.COMM_WORLD

height = 1.
width = 1.

t        = Constant(0.0)

set_log_level(30)

parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["representation"] = "uflacs"
parameters["form_compiler"]["cpp_optimize_flags"] = "-O3 -ffast-math -march=native"
parameters["form_compiler"]["quadrature_degree"] = 2

mesh = Mesh()
mesh = BoxMesh(comm, Point(0,0,0), Point(width,height,width), 10, 10, 10)
x = SpatialCoordinate(mesh)
ELEMENT = VectorElement("Lagrange", mesh.ufl_cell(), 1)
FS = FunctionSpace(mesh, ELEMENT)
wtest = TestFunction(FS)
w = Function(FS)
dw = TrialFunction(FS)

output_file = XDMFFile(comm, "output.xdmf")
output_file.parameters["flush_output"] = True
output_file.parameters["functions_share_mesh"] = True
u_v = project(w,FS)
u_v.rename("disp", "Displacement")
output_file.write(u_v, float(t))
output_file.close()

compiled it with: mpirun -n 4 python3 (filename).py
but an errors occur like this:

HDF5-DIAG: Error detected in HDF5 (1.10.7) MPI-process 0:
  #000: ../../../src/H5F.c line 366 in H5Fcreate(): unable to create file
    major: File accessibility
    minor: Unable to open file
  #001: ../../../src/H5Fint.c line 1713 in H5F_open(): unable to lock the file
    major: File accessibility
    minor: Unable to lock file
  #002: ../../../src/H5FD.c line 1675 in H5FD_lock(): driver lock request failed
    major: Virtual File Layer
    minor: Unable to lock file
  #003: ../../../src/H5FDsec2.c line 990 in H5FD__sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: Virtual File Layer
    minor: Unable to lock file
HDF5-DIAG: Error detected in HDF5 (1.10.7) MPI-process 0:
  #000: ../../../src/H5F.c line 366 in H5Fcreate(): unable to create file
    major: File accessibility
    minor: Unable to open file
  #001: ../../../src/H5Fint.c line 1713 in H5F_open(): unable to lock the file
    major: File accessibility
    minor: Unable to lock file
  #002: ../../../src/H5FD.c line 1675 in H5FD_lock(): driver lock request failed
    major: Virtual File Layer
    minor: Unable to lock file
  #003: ../../../src/H5FDsec2.c line 990 in H5FD__sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: Virtual File Layer
    minor: Unable to lock file

befor I ran the code, there is no file on the directory.
I think output.xdmf and output.h5 files were well generated because I could open the xdmf file in paraview, but I don’t know why the errors occur.
Thank you.

I cannot reproduce this with the ghcr.io/scientificcomputing/fenics-gmsh:2024-05-30 docker image.

I would try:

  1. Set "flush_output" to False. Does that help?

Secondly, how did you install dolfin on your system?

Hi dokken,

  1. It also makes errors.
HDF5-DIAG: Error detected in HDF5 (1.10.7) MPI-process 0:
  #000: ../../../src/H5F.c line 366 in H5Fcreate(): unable to create file
    major: File accessibility
HDF5-DIAG: Error detected in HDF5 (1.10.7) MPI-process     minor: Unable to open file
  #001: 0:
  #000: ../../../src/H5F.c ../../../src/H5Fint.c line 1713 in H5F_open()line 366 in H5Fcreate(): unable to create file
    m: unable to lock the file
    major: File accessibility
    miajor: File accessibility
    minor: Unable to open file
nor: Unable to lock file
  #002  #001: ../../../src/H5Fint.c line 1713: ../../../src/H5FD.c line 1675 in  in H5F_open(): unable to lock the file
    major:H5FD_lock(): driver lock request failed
    major:  File accessibility
    minor: Unable to lock file
  #Virtual File Layer
    minor: Unable to lock file
  #002: ../../../src/H5FD.c line 1675 in H5FD_lock(): 003: ../../../src/H5FDsec2.c line 990 in H5FD__sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    majodriver lock request failed
    major: Virtual File Layer
    minor: Unable to lock file
  #003: ../../../src/H5FDsec2.c line r: Virtual File Layer
    minor: Unable to lock file
990 in H5FD__sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: Virtual File Layer
    minor: Unable to lock file
  1. I use fenics (2019.2.0.13.dev0) in ubuntu system. I am not using doker now. I think I should re-install fenics.
    + I updated fenics to 2019.2.0.64.dev0 but it makes same errors.

To me, this seems like you are having issues with the file system you are running this code at, as you are not able to lock the file.
See for instance: OSError: Unable to open file (unable to lock file, errno = 37, error message = 'No locks available') · Issue #1101 · h5py/h5py · GitHub for possible workarounds

1 Like