How to close xdmf/h5 view file after mpi abort?

Hello,

I was running a simulation in parallel and saving results to an xdmf file. The process was terminated and I cannot open my results files in paraview. I know this is because the file filename.close() command was never called before exiting. Is there a way to close the xdmf/h5 files after the process has exited? I’d like to be able to use the results.

Thank you!

I would suggest using the ContextManager functionality (contextlib — Utilities for with-statement contexts — Python 3.11.2 documentation) of the XDMFFile

with XDMFFile("mesh.xdmf") as xdmf:
    # do stuff with `xdmf`


# Do other stuff unrelated to `xdmf`

Thank you. When I try that, it looks like there’s a problem with the h5 file. I get the following error:

HDF5-DIAG: Error detected in HDF5 (1.12.2) MPI-process 0:
  #000: H5F.c line 620 in H5Fopen(): unable to open file
    major: File accessibility
    minor: Unable to open file
  #001: H5VLcallback.c line 3502 in H5VL_file_open(): failed to iterate over available VOL connector plugins
    major: Virtual Object Layer
    minor: Iteration failed
  #002: H5PLpath.c line 579 in H5PL__path_table_iterate(): can't iterate over plugins in plugin path '(null)'
    major: Plugin for dynamically loaded library
    minor: Iteration failed
  #003: H5PLpath.c line 620 in H5PL__path_table_iterate_process_path(): can't open directory: /usr/local/anaconda3/envs/fenicsx-env/lib/hdf5/plugin
    major: Plugin for dynamically loaded library
    minor: Can't open directory or file
  #004: H5VLcallback.c line 3351 in H5VL__file_open(): open failed
    major: Virtual Object Layer
    minor: Can't open object
  #005: H5VLnative_file.c line 97 in H5VL__native_file_open(): unable to open file
    major: File accessibility
    minor: Unable to open file
  #006: H5Fint.c line 1990 in H5F_open(): unable to read superblock
    major: File accessibility
    minor: Read failed
  #007: H5Fsuper.c line 405 in H5F__super_read(): file signature not found
    major: File accessibility
    minor: Not an HDF5 file

You need to produce a minimal reproducable example for anyone to be able to help you.

I can’t seem to make a simple reproducible example and the file itself is too large. It must be that something is messed up in the h5 file from the process terminating possibly mid-write.