Inspect one directory without mutating it and require every file declared by its checkpoint generation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | checkpoint_dir | |||
| logical, | intent(out) | :: | complete | |||
| integer(kind=i32), | intent(out), | optional | :: | schema_version | ||
| integer(kind=i32), | intent(out), | optional | :: | batches | ||
| integer(kind=i32), | intent(out), | optional | :: | mpi_world_size | ||
| logical, | intent(out), | optional | :: | has_macro_residuals | ||
| logical, | intent(out), | optional | :: | has_charge_ledger |
subroutine inspect_checkpoint_directory( & checkpoint_dir, complete, schema_version, batches, mpi_world_size, & has_macro_residuals, has_charge_ledger & ) character(len=*), intent(in) :: checkpoint_dir logical, intent(out) :: complete integer(i32), intent(out), optional :: schema_version, batches, mpi_world_size logical, intent(out), optional :: has_macro_residuals, has_charge_ledger character(len=1024) :: path integer(i32) :: saved_schema, saved_batches, saved_world_size, rank integer(i32) :: manifest_batches, manifest_world_size logical :: summary_ok, summary_has_ledger, manifest_found, manifest_complete logical :: manifest_has_residuals, manifest_has_ledger, exists complete = .false. saved_schema = -1_i32 saved_batches = -1_i32 saved_world_size = -1_i32 manifest_has_residuals = .false. manifest_has_ledger = .false. summary_has_ledger = .false. path = trim(checkpoint_dir)//'/summary.txt' inquire (file=trim(path), exist=exists) if (.not. exists) then call assign_inspection_outputs() return end if call read_summary_checkpoint_metadata( & trim(path), saved_schema, saved_batches, saved_world_size, summary_has_ledger, summary_ok & ) if (.not. summary_ok) then call assign_inspection_outputs() return end if ! `load_restart_checkpoint` の直接利用でも、future schemaや明示schema v1を ! legacy checkpointとして誤読込しない。後続のworld-size分ファイル走査も回避する。 if (.not. checkpoint_schema_is_loadable(saved_schema)) then call assign_inspection_outputs() return end if if (saved_schema >= checkpoint_manifest_required_schema) then call read_checkpoint_manifest( & trim(checkpoint_dir), manifest_found, manifest_complete, manifest_batches, manifest_world_size, & manifest_has_residuals, manifest_has_ledger & ) if (.not. manifest_found .or. .not. manifest_complete) then call assign_inspection_outputs() return end if if (manifest_batches /= saved_batches .or. manifest_world_size /= saved_world_size) then call assign_inspection_outputs() return end if if (manifest_has_ledger .neqv. summary_has_ledger) then call assign_inspection_outputs() return end if else inquire (file=trim(checkpoint_dir)//'/macro_residuals.csv', exist=manifest_has_residuals) manifest_has_ledger = summary_has_ledger end if inquire (file=trim(checkpoint_dir)//'/charges.csv', exist=exists) if (.not. exists) then call assign_inspection_outputs() return end if do rank = 0_i32, saved_world_size - 1_i32 path = checkpoint_rng_path(trim(checkpoint_dir), rank, saved_world_size) inquire (file=trim(path), exist=exists) if (.not. exists) then call assign_inspection_outputs() return end if end do if (manifest_has_residuals) then inquire (file=trim(checkpoint_dir)//'/macro_residuals.csv', exist=exists) if (.not. exists) then call assign_inspection_outputs() return end if end if if (summary_has_ledger) then inquire (file=trim(checkpoint_dir)//'/charge_ledger.csv', exist=exists) if (.not. exists) then call assign_inspection_outputs() return end if end if complete = .true. call assign_inspection_outputs() contains subroutine assign_inspection_outputs() if (present(schema_version)) schema_version = saved_schema if (present(batches)) batches = saved_batches if (present(mpi_world_size)) mpi_world_size = saved_world_size if (present(has_macro_residuals)) has_macro_residuals = manifest_has_residuals if (present(has_charge_ledger)) has_charge_ledger = summary_has_ledger end subroutine assign_inspection_outputs end subroutine inspect_checkpoint_directory