# ERROR: Failed to open HDF5 file with mode 'w': summary.h5

**URL:** https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360
**Category:** User Support
**Created:** [August 4, 2021, 6:30pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360 "2021-08-04T18:30:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![TOWHID](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@TOWHID](https://openmc.discourse.group/u/TOWHID)
#### Post date: [August 4, 2021, 6:30pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/1 "2021-08-04T18:30:29Z")

</div>

Hi all, i am having this error in my code. What might be the reason for that and how to solve it?

Reading c\_H\_in\_H2O from /home/shuvo/Documents/LANL cross section  
libraries/Version VIII.0/lib80x/lib80x\_hdf5/c\_H\_in\_H2O.h5  
Minimum neutron data temperature: 600.000000 K  
Maximum neutron data temperature: 600.000000 K  
Reading tallies XML file…  
Preparing distributed cell instances…  
Writing summary.h5 file…  
HDF5-DIAG: Error detected in HDF5 (1.10.6) thread 140278100912064:  
#000: H5F.c line 444 in H5Fcreate(): unable to create file  
major: File accessibilty  
minor: Unable to open file  
#001: H5Fint.c line 1567 in H5F\_open(): unable to lock the file  
major: File accessibilty  
minor: Unable to open file  
#002: H5FD.c line 1640 in H5FD\_lock(): driver lock request failed  
major: Virtual File Layer  
minor: Can’t update object  
#003: H5FDsec2.c line 959 in H5FD\_sec2\_lock(): unable to lock file, errno = 11, error message = ‘Resource temporarily unavailable’  
major: File accessibilty  
minor: Bad file ID accessed  
ERROR: Failed to open HDF5 file with mode ‘w’: summary.h5

* * *

CalledProcessError Traceback (most recent call last)  
 in   
----\> 1 openmc.run()

~/miniconda3/lib/python3.8/site-packages/openmc/executor.py in run(particles, threads, geometry\_debug, restart\_file, tracks, output, cwd, openmc\_exec, mpi\_args, event\_based)  
216 args = mpi\_args + args  
217  
 → 218 \_run(args, output, cwd)

~/miniconda3/lib/python3.8/site-packages/openmc/executor.py in \_run(args, output, cwd)  
26 # Raise an exception if return status is non-zero  
27 if p.returncode != 0:  
—\> 28 raise subprocess.CalledProcessError(p.returncode, ’ '.join(args),  
29 ‘’.join(lines))  
30

CalledProcessError: Command ‘openmc’ returned non-zero exit status 255

---

<div class="post-metadata">

### Author: ![Sivakorn.SSW](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/sivakorn.ssw/32/1424_2.png) [@Sivakorn.SSW](https://openmc.discourse.group/u/Sivakorn.SSW)
#### Post date: [August 8, 2021, 5:15pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/2 "2021-08-08T17:15:30Z")

</div>

Hi @TOWHID

I had faced this problem before, Not sure whether my solution is relating to yours or not. I solved  
`ERROR: Failed to open HDF5 file with mode ‘w’: summary.h5`

by set the value of the environment variable **HDF5\_USE\_FILE\_LOCKING** to **FALSE** via terminal.

```auto
/bin/nano ~/.bashrc
export HDF5_USE_FILE_LOCKING=FALSE

```

Hope this helps,  
Sivakorn Sansawas

---

<div class="post-metadata">

### Author: ![TOWHID](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@TOWHID](https://openmc.discourse.group/u/TOWHID)
#### Post date: [August 8, 2021, 5:50pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/3 "2021-08-08T17:50:31Z")

</div>

@Sivakorn.SSW thank you so much for your suggestion.  
Apparently i solve this problem in other way.  
In my case what i did, was closing the previously opened script and shutting down all kernels and then restarting them. That’s how i solve this problem.  
But thanks for your solution too.

---

<div class="post-metadata">

### Author: ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)
#### Post date: [September 6, 2022, 4:45pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/4 "2022-09-06T16:45:31Z")

</div>

Hi @TOWHID,

I just wanted to note that the `openmc.StatePoint` object has a `close` method that will allow you to release the HDF5 filehandle of both the `statepoint.*.h5` file and the `summary.h5` file if it is linked.

For others running into this problem and coming across this thread, here’s a link to the troubleshooting section in the docs on this issue.

[https://docs.openmc.org/en/stable/usersguide/troubleshoot.html#runtimeerror-failed-to-open-hdf5-file-with-mode-w-summary-h5](https://docs.openmc.org/en/stable/usersguide/troubleshoot.html#runtimeerror-failed-to-open-hdf5-file-with-mode-w-summary-h5)

This section notes that a more elegant way to manage the statepoint file handle is to retrieve data from the file within a context manager:

```python
with openmc.StatePoint('statepoint.10.h5') as sp:
    k_eff = sp.keff

```

when the interpreter exits this block, the object will be automatically cleaned up and the HDF5 file handle will be released.

Either approach works, just wanted to let you know about both!

-Patrick

---

<div class="post-metadata">

### Author: ![TOWHID](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@TOWHID](https://openmc.discourse.group/u/TOWHID)
#### Post date: [September 7, 2022, 1:27pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/5 "2022-09-07T13:27:15Z")

</div>

@pshriwise thank you so much for your solution.

---

<div class="post-metadata">

### Author: ![Nilormi](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@Nilormi](https://openmc.discourse.group/u/Nilormi)
#### Post date: [May 3, 2023, 1:38pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/6 "2023-05-03T13:38:55Z")

</div>

This has worked for me too. Thank you @TOWHID

---

<div class="post-metadata">

### Author: ![mr.atom](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mr.atom](https://openmc.discourse.group/u/mr.atom)
#### Post date: [March 28, 2024, 4:01am UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/7 "2024-03-28T04:01:35Z")

</div>

Hello there, I have the same issue and honestly I didn’t understand what should I do with this trouble shooting page. I am a bit rookie so can you give more detail regarding this solution?

Thank you

---

<div class="post-metadata">

### Author: ![mr.atom](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mr.atom](https://openmc.discourse.group/u/mr.atom)
#### Post date: [March 28, 2024, 12:55pm UTC](https://openmc.discourse.group/t/error-failed-to-open-hdf5-file-with-mode-w-summary-h5/1360/8 "2024-03-28T12:55:41Z")

</div>

> [@Sivakorn.SSW](#):
>
> `export HDF5_USE_FILE_LOCKING=FALSE`

I tried to implement

```auto
with openmc.StatePoint('statepoint.10.h5') as sp:
    k_eff = sp.keff

```

this part at the end of my input file but it didn’t work.
