A complete manifest is atomically published only after every restart-bearing file is closed.
| Type | Intent | Optional | 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 |
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