Conversation
Lets a simulation write its dynamic fire state to a NetCDF restart file at a fixed interval and resume from one of those files, for standalone runs (serial and MPI) and for runs coupled to WRF. Namelist (time block): restart - resume from fire_restart_<start datetime>.nc restart_interval - restart write interval in seconds, -1 disables state_mod: Read_restart and Write_restart type-bound methods, plus Build_restart_file_name and the MPI helpers they need. A restart read validates the grid metadata stored in the file against the current configuration before touching any state, so a mismatched restart file fails early instead of producing a silently wrong run. netcdf_mod: Attribute writers (Add_netcdf_att) and MPI-aware readers and writers for distributed 2D and 3D fields. initialize_mod: Init_fire_state_from_restart takes the real-case restart path, so the existing geogrid initialization is left as is. The WRF-coupled path reads the restart after the fire components are initialized. fire_behavior: Reads the restart state at startup instead of Save_state, and writes a restart every restart_interval seconds. restart_interval must map to a whole number of time steps or the run stops with a message. fmc_wrffire_mod: Drops the unused state_mod and namelist_mod imports. state_mod now uses fmc_wrffire_mod for the moisture restart fields, so these imports would otherwise form a circular module dependency. The code was created with assistance from Codex GPT-5.5 and Claude Opus 4.7. Co-authored-by: mefrediani <frediani@ucar.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
The CFBM has had no way to stop a simulation and resume it.
This feature adds a restart capability. A run can write its dynamic fire state to a
NetCDF file at a fixed interval, and a later run can be initialized from one of
those files instead of a cold start. It covers standalone runs, serial and MPI,
and runs coupled to WRF.
Two options are added to the
&timenamelist block:restart.false.fire_restart_<start datetime>.ncrestart_interval-1-1disables writesBoth default to the previous behavior, so existing namelists are unaffected.
Changes by file:
state/state_mod.F90carries theRead_restartandWrite_restarttype-bound methods,
Build_restart_file_name, and the MPI helpers they need.A restart read validates the grid metadata stored in the file against the
current configuration before touching any state, so a mismatched restart file
fails early with a message instead of producing a silently wrong run.
io/netcdf_mod.F90adds attribute writers (Add_netcdf_att) andMPI-aware readers and writers for distributed 2D and 3D fields.
driver/initialize_mod.F90routes the real-case restart path through anew
Init_fire_state_from_restart, leaving the existing geogridinitialization untouched. The WRF-coupled path reads the restart after the
fire components are initialized.
driver/fire_behavior.F90reads the restart state at startup in place ofSave_state, and writes a restart everyrestart_intervalseconds.restart_intervalmust map to a whole number of time steps or the run stopswith a message.
io/namelist_mod.F90adds the two options, their broadcast, and a rangecheck.
physics/fmc_wrffire_mod.F90drops its unusedstate_modandnamelist_modimports. This one is load-bearing rather than cosmetic:state_modnow usesfmc_wrffire_modfor the moisture restart fields, soleaving those imports in place would create a circular module dependency.
Type of change
Tests conducted:
All testing on Derecho (NCAR) using the repository environment
env/derecho/gnu-12.2.0: GCC 12.2.0, cray-mpich 8.1.25, NetCDF-Fortran 4.9.2,HDF5 1.12.2, ESMF 8.5.0, CMake 3.26.3.
Builds. Three configurations, all clean with no errors or new warnings:
serial (
--mpi-off), MPI (default), and--esmx(which includes NUOPC).Registered ctest suite, run on the
--esmxbuild so every registered caseis reachable:
7 of 7. The NUOPC cases matter here because the cap uses both
initialize_modand
state_mod, and this PR touches both.Restart regressions. These run a case straight through, then run it again
stopping and restarting partway, and compare the two. Restart test scripts are
not included in this PR (see below), but the results are:
Serial build, 20 of 20 checks:
MPI build on a compute node, 30 of 30 checks:
The multi-rank runs are the ones that exercise the distributed restart read and
write and the halo exchange following a restart read. Restarting at 2 and 4
ranks reproduces the continuous run, so the domain decomposition is handled
correctly on the restart path.
57 passing checks in total across the three build configurations.
Not covered. Two gaps, stated explicitly:
Init_fire_state_within_wrfcallingRead_restart) is exercised by a separate WRF harness, and not tested here.On the test scripts. The restart test scripts (
test7_restart.s,test8_restart.s,test9.s,test9_restart.s, thetest9case directory, andthe
tests/CMakeLists.txtregistration) are deliberately held out of this PRpending the separate discussion about how tests should be organized. They are
ready and can be added here or in a follow-up PR, whichever is preferred.
Documentation:
Documentation was left out to keep the diff focused on
the code. Happy to add it to this PR if preferred, otherwise it will follow
separately.
Contributors:
@masih-e (Masih Eghdami:masih@ucar.edu)
@mefrediani (Maria Frediani:frediani@ucar.edu)
LLM/coding assistant technology used: the restart implementation was developed
with assistance from Codex GPT-5.5 and Claude Opus 4.7. Claude Opus 5 assisted
with the pre-review cleanup of this branch.
Further information:
state/state_mod.F90grows from 1063 to 1965 lines in this PR, which is morethan that file should carry. A restart-specific module is worth doing as a follow-up. This
change is not possible with the current code because the restart calls depend on the fire
state type.