write_checkpoint Subroutine

public subroutine write_checkpoint(state, base, t, iter, is_ok, message, written_file, t_comp)

Write a checkpoint file for the current solver state.

The file is written as an unformatted stream binary. After a successful write, the plain text file latest_checkpoint is updated to the new file's path.

absent is written as 0, matching a fresh (non-restarted) run's value.

Arguments

Type IntentOptional 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
character(len=*), intent(out), optional :: written_file

Path of the file actually written (e.g. <base>_<iter>.bin), set only on success. Lets callers (e.g. the Cortex WRITE_CHECKPOINT reply) report the real on-disk path rather than reconstructing it from base.

real(kind=wp), intent(in), optional :: t_comp

Optional Kahan compensation term for t (v5, F2);