Checkpoints are Fortran unformatted (stream) binary files that capture everything needed to resume a run exactly:
File naming: <base>_NNNNNN.bin where NNNNNN is the zero-padded
iteration number. A companion text file latest_checkpoint (written
alongside) records the path of the most recent checkpoint so that
restart drivers need not track the iteration themselves.
Typical usage in the driver: @code use checkpoint, only: write_checkpoint, read_checkpoint ! --- writing --- call write_checkpoint(state, cfg%checkpoint_file, t, iter) ! --- reading --- call read_checkpoint(state, cfg%restart_file, t, iter) @endcode
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private, | parameter | :: | CKPT_MAGIC | = | 42 | |
| integer, | private, | parameter | :: | CKPT_VERSION | = | 1 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | fname | |||
| logical, | intent(out), | optional | :: | is_ok | ||
| character(len=*), | intent(out), | optional | :: | message |
Write a checkpoint file for the current solver state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_state_t), | intent(in) | :: | state |
Current solver state (must have ub allocated). |
||
| character(len=*), | intent(in) | :: | base |
Base name (e.g. 'checkpoint'); file = base_NNNNNN.bin. |
||
| real(kind=wp), | intent(in) | :: | t |
Current simulation time [s]. |
||
| integer, | intent(in) | :: | iter |
Current iteration number. |
||
| logical, | intent(out), | optional | :: | is_ok | ||
| character(len=*), | intent(out), | optional | :: | message |
Read a checkpoint file and restore solver state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_state_t), | intent(inout) | :: | state |
Solver state with ub already allocated (from setup_solver). |
||
| character(len=*), | intent(in) | :: | fname |
Path to the checkpoint file (or 'latest_checkpoint'). |
||
| real(kind=wp), | intent(out) | :: | t |
Restored simulation time [s]. |
||
| integer, | intent(out) | :: | iter |
Restored iteration count. |
||
| logical, | intent(out), | optional | :: | is_ok | ||
| character(len=*), | intent(out), | optional | :: | message |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | fname | |||
| logical, | intent(out), | optional | :: | is_ok | ||
| character(len=*), | intent(out), | optional | :: | message |