Skip to content

Commit b1dc864

Browse files
committed
Add section on copying intermediate files. [ci skip]
1 parent 5ede7ea commit b1dc864

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,38 @@ geometry. To override this for all groups:
242242
somd2 perturbable_system.bss --terminal-flip-frequency "1 ps" --terminal-flip-angle "180 degrees"
243243
```
244244

245+
## Copying output files during a simulation
246+
247+
When `SOMD2` writes checkpoint files it acquires an exclusive
248+
[file lock](https://filelock.readthedocs.io) on `somd2.lock` inside the output
249+
directory. This guarantees that checkpoint files are always in a consistent
250+
state on disk.
251+
252+
If you want to copy the output directory while a simulation is running (for
253+
example, to create a backup or to inspect intermediate results), acquire the
254+
same lock first so that you do not copy files mid-write. On Linux/macOS this
255+
can be done with the `flock` command:
256+
257+
```bash
258+
flock /path/to/output/somd2.lock cp -r /path/to/output /destination
259+
```
260+
261+
Or from Python using the [filelock](https://pypi.org/project/filelock/) package
262+
(which `somd2` already depends on):
263+
264+
```python
265+
from filelock import FileLock
266+
267+
with FileLock("/path/to/output/somd2.lock"):
268+
# copy files here
269+
...
270+
```
271+
272+
> [!NOTE]
273+
> The `--timeout` option (default: `300 s`) controls how long `SOMD2` will
274+
> wait to re-acquire the lock after your copy completes. If you hold the lock
275+
> for longer than this, the simulation will raise a `Timeout` error.
276+
245277
## Analysis
246278

247279
Simulation output will be written to the directory specified using the

0 commit comments

Comments
 (0)