Unable to Create Statepoint File

I am running OpenMC in a different directory than the one it is located in by using cwd in model.run() as well as the ‘path’ key in model.settings.output, but for some reason the statepoint file cannot be written. I’m getting the following error:

H5F.c line 532 in H5Fcreate(): unable to create file

All packages are up-to-date, any thoughts on why this is occurring?

Thanks in advance for any help.

When you use the cwd argument of Model.run, it will change the directory before writing the XML input files. This means that whatever ‘path’ you specify in model.settings.output needs to be relative to the directory specified in the cwd argument.

That fixed it, thank you!

@paulromano greetings.
I am new to openmc and i want to take value from openmc.StatePoint(). it reads from it successfully first time but when the simulation starts again(because i used loop so that i can get some readings for plot) it gives error while wring to HDF5 file. what could be the possible cause of the error.
Thank you

Hi @Rihan_khan and welcome to the forum! The problem here is that if you open a statepoint in the Python API but don’t close the file, when OpenMC runs again and tries to write to the file, it is locked from the Python side. The solution is to make sure the statepoint is closed before running again. There are two ways you can do this. You can either explicitly close the statepoint:

sp = openmc.StatePoint(...)
# get needed information from statepoint
...
sp.close()

or you can use the statepoint in a context manager, in which case it is automatically closed at the end of the with block:

with openmc.StatePoint(...) as sp:
    # get needed information from statepoint
    ...

Thank you so much @paulromano

1 Like