publish_checkpoint_manifest Subroutine

public subroutine publish_checkpoint_manifest(out_dir, batches, mpi_world_size, has_macro_residuals, has_charge_ledger)

A complete manifest is atomically published only after every restart-bearing file is closed.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: out_dir
integer(kind=i32), intent(in) :: batches
integer(kind=i32), intent(in) :: mpi_world_size
logical, intent(in) :: has_macro_residuals
logical, intent(in) :: has_charge_ledger

Calls

proc~~publish_checkpoint_manifest~~CallsGraph proc~publish_checkpoint_manifest publish_checkpoint_manifest proc~atomic_rename atomic_rename proc~publish_checkpoint_manifest->proc~atomic_rename

Called by

proc~~publish_checkpoint_manifest~~CalledByGraph proc~publish_checkpoint_manifest publish_checkpoint_manifest proc~maybe_write_periodic_checkpoint maybe_write_periodic_checkpoint proc~maybe_write_periodic_checkpoint->proc~publish_checkpoint_manifest program~main main program~main->proc~publish_checkpoint_manifest

Source Code

  subroutine publish_checkpoint_manifest( &
    out_dir, batches, mpi_world_size, has_macro_residuals, has_charge_ledger &
    )
    character(len=*), intent(in) :: out_dir
    integer(i32), intent(in) :: batches, mpi_world_size
    logical, intent(in) :: has_macro_residuals, has_charge_ledger

    character(len=1024) :: path, temporary_path
    integer :: u, ios, rename_status

    if (batches < 0_i32) error stop 'Checkpoint manifest batches must be >= 0.'
    if (mpi_world_size <= 0_i32) error stop 'Checkpoint manifest mpi_world_size must be > 0.'

    path = trim(out_dir)//'/'//checkpoint_manifest_name
    temporary_path = trim(path)//'.tmp'
    open (newunit=u, file=trim(temporary_path), status='replace', action='write', iostat=ios)
    if (ios /= 0) error stop 'Failed to create temporary checkpoint manifest.'
    write (u, '(a,i0)') 'schema_version=', checkpoint_manifest_schema_current
    write (u, '(a)') 'state=complete'
    write (u, '(a,i0)') 'batches=', batches
    write (u, '(a,i0)') 'mpi_world_size=', mpi_world_size
    write (u, '(a,l1)') 'macro_residuals_present=', has_macro_residuals
    write (u, '(a,l1)') 'charge_ledger_present=', has_charge_ledger
    close (u, iostat=ios)
    if (ios /= 0) error stop 'Failed to close temporary checkpoint manifest.'
    call atomic_rename(trim(temporary_path), trim(path), rename_status)
    if (rename_status /= filesystem_success) error stop 'Failed to publish checkpoint manifest.'
  end subroutine publish_checkpoint_manifest