Skip to content

Reproducibility and Restarting the Coupled Model

Ufuk Turunçoğlu edited this page Nov 24, 2026 · 3 revisions

A restart run is reproducible when continuing from a restart file produces bit-identical results to a run that passed through the same point without stopping. This page describes how to set up such a restart, how to verify it, and what is currently known not to be covered.

Building

Restart reproducibility requires --reprod. Build both legs with it:

./build.sh --compiler=intel --component-list=mom6,cmeps --remove --reprod

--reprod adds -fp-model=precise (Intel) or -ffp-contract=off (GNU) to the MPAS build. It is off by default, because it costs performance, so you have to ask for it. MOM6 and CMEPS set strict floating-point in their own CMakeLists.txt regardless of this flag, so --reprod governs MPAS only.

Standalone MPAS has been observed not to reproduce on restart without it.

It is tempting to assume the flag is unnecessary because both legs run the same executable, so any reassociation or FMA contraction should apply identically and cancel. That argument does not hold in practice. A restarted run reaches the same physical state by a different route: it allocates and fills its arrays during a restart read rather than inheriting them from the previous timestep, so array alignment and loop trip counts need not match the continuous run's. Under the default -fp-model=fast the compiler is free to emit alignment-dependent vector code and to reassociate reductions, and those choices can then differ between the two legs. -fp-model=precise removes that freedom.

Verify the flag actually reached the MPAS build before trusting a comparison:

grep CMAKE_Fortran_FLAGS: build/mpas_atm_nuopc/CMakeCache.txt
# expect: CMAKE_Fortran_FLAGS:STRING=-fp-model=precise

To check every compiled target rather than the cache:

grep -rh "Fortran_FLAGS = " build/mpas_atm_nuopc/ --include=flags.make | sort -u

A build without --reprod is the right choice for production runs where you do not intend to restart-compare; it is faster, and nothing else here depends on it.

Setting up a restart run

Create the restart run directory as a copy of the base one, then change the settings below. The examples restart at 2021-07-03 00:00:00; substitute your own restart time throughout.

1. namelist.atmosphere

Option Base Restart
config_start_time '2021-07-01_00:00:00' '2021-07-03_00:00:00'
config_run_duration '4_00:00:00' '2_00:00:00'
config_do_restart false true
config_enable_import (your choice) must match base

config_start_time must exactly match a time at which the base run wrote a restart file.

Every other namelist option must be identical between the two legs. config_enable_import is the easy one to get wrong, because the restart directory is usually copied once and then kept while the base namelist is edited. A base run with config_enable_import = true compared against a restart leg still carrying false is a one-way run compared against a two-way one; it will show large differences that have nothing to do with restart reproducibility. Diff the two namelists before blaming the model:

diff $B/namelist.atmosphere $R/namelist.atmosphere

The only lines that should differ are the three in the table above.

2. esmxRun.yaml

The following are the required changes for the restart run.

ESMX:
  App:
    startTime: 2021-07-03T00:00:00     # was 2021-07-01T00:00:00
    stopTime:  2021-07-05T00:00:00     # unchanged

attributes: &common
  start_type:   continue               # was: startup
  read_restart: true                   # was: false
  restart_dir:  ./RESTART/
  case_name:    glb

stop_n / stop_option should describe the restart leg's own length (here stop_n: 2, stop_option: ndays).

3. streams.atmosphere

The restart run's output intervals must match the base run's, or there will be no common times to compare:

<immutable_stream name="restart" ... output_interval="1:00:00" />
<stream name="output"           ... output_interval="1:00:00" >
<stream name="diagnostics"      ... output_interval="1:00:00" >

Careful with MPAS interval strings. The format is [DD_]HH:MM:SS, so "0:12:00" means 12 minutes, not 12 hours, and "1:00:00" means 1 hour. At config_dt = 720.0, an interval of "0:12:00" writes output every timestep — useful for debugging, but it produces ~1.4 GB per 12 model-minutes across the three streams and will dominate your wall time.

4. Choose a restart time both models can write

The restart instant must fall on both cadences:

  • MPAS — the restart stream's output_interval in streams.atmosphere
  • CMEPS/MOM6 — restart_n / restart_option in esmxRun.yaml (e.g. restart_n: 3, restart_option: nhours)

With hourly MPAS restarts and 3-hourly coupled restarts, valid restart times are every 3 hours.

Staging restart files from the base run

This section assumes that we are restarting the model in a different directory. Five files (plus two pointer files) must be moved from the base run directory. Note that MOM6 reads its restarts from INPUT/, not RESTART/, despite the file names.

What From (base) To (restart run) Method
MPAS state restart.2021-07-03_00.00.00.nc run directory real copy
CMEPS pointer rpointer.cpl.2021-07-03-00000 run directory copy
MOM6 pointer rpointer.ocn.2021-07-03-00000 run directory copy
MOM6 state (×4) RESTART/glb.mom6.r.2021-07-03-00000{,_1,_2,_3}.nc INPUT/ symlink ok
CMEPS state RESTART/glb.cpl.r.2021-07-03-00000.nc RESTART/ symlink ok

The coupled file names encode seconds-of-day: -00000 is 00:00 UTC, -10800 is 03:00 UTC, and so on.

Copy the MPAS restart, do not symlink it. It lands in the same directory MPAS writes its own restarts into, so a symlink risks writing back into the base run. The MOM6 and CMEPS files are read-only and may safely be links.

B=/path/to/base_run
R=/path/to/restart_run
STAMP=2021-07-03_00.00.00      # MPAS form
CSTAMP=2021-07-03-00000        # CMEPS/MOM6 form
BASE=$(basename $B)

# 1. MPAS state - real copy
cp $B/restart.${STAMP}.nc $R/

# 2. pointer files
cp $B/rpointer.cpl.${CSTAMP} $B/rpointer.ocn.${CSTAMP} $R/

# 3. MOM6 state -> INPUT/
for s in "" _1 _2 _3; do
  ln -sfn ../../${BASE}/RESTART/glb.mom6.r.${CSTAMP}${s}.nc \
          $R/INPUT/glb.mom6.r.${CSTAMP}${s}.nc
done

# 4. CMEPS state -> RESTART/
ln -sfn ../../${BASE}/RESTART/glb.cpl.r.${CSTAMP}.nc \
        $R/RESTART/glb.cpl.r.${CSTAMP}.nc

# 5. verify every link resolves
for l in $R/INPUT/glb.mom6.r.${CSTAMP}*.nc $R/RESTART/glb.cpl.r.${CSTAMP}.nc; do
  [ -s "$(readlink -f $l)" ] && echo "OK   $l" || echo "BROKEN $l"
done

Re-running an existing restart directory

Delete the previous run's output first. MPAS uses clobber_mode = "never_modify", so it will refuse to overwrite existing output files and those timesteps will silently go unwritten.

Never use a bare rm restart.*.nc. The input restart file sits in the same directory, with the same prefix, as the output restart files. Exclude it explicitly:

cd $R
for f in restart.*.nc; do
  [ "$f" = "restart.${STAMP}.nc" ] || rm -f -- "$f"
done
rm -f diag.*.nc history.*.nc debug_fine.*.nc glb.cpl.hi.*.nc \
      PET*.ESMF_LogFile log.atmosphere.*.out logfile.*.out mediator.log \
      err out ESMF_Profile.summary restart_timestamp
rm -f MOM6_OUTPUT/*

Verifying reproducibility

Compare every output file the two runs have in common. cprnc reports the two files seem to be IDENTICAL when all fields match:

CP=/path/to/cprnc
for h in $(seq -w 1 19); do
  f=history.2021-07-03_${h}.00.00.nc
  [ -s "$B/$f" ] && [ -s "$R/$f" ] || continue
  $CP -m "$B/$f" "$R/$f" > /tmp/cprnc_$h.log 2>&1
  printf "%s  %s\n" "$h:00" \
    "$(grep -q 'IDENTICAL' /tmp/cprnc_$h.log && echo IDENTICAL || echo DIFFER)"
done

Check the summary block of each log, which reports the number of fields compared and how many had non-zero differences. A few fields "could not be analyzed" is normal — those are character variables such as xtime, which cprnc cannot compare numerically.

Compare both the history and restart streams. The restart files carry considerably more state (305 fields vs 116 in the default history stream), so they are the stronger test.

Also compare the CMEPS mediator history (glb.cpl.hi.*.nc). These report DIFFERENT even on a perfect restart, because time and time_bnds are stored relative to each leg's own start date: the base writes days since 2021-07-01 and the restart leg days since 2021-07-03, so the same instant carries a different number. Check which variables differ. If the only two entries are time and time_bnds, every physical field matches.

A run killed by the scheduler leaves a truncated final output file. Its header is written but its data is not, so ncdump -h succeeds on it while ncdump -v xtime returns nothing, and the file is orders of magnitude smaller than its siblings. cprnc will report a difference that is an artifact, not a reproducibility failure. Use restart_timestamp to find the last completed time, and compare file sizes before trusting the final output of a killed run. MPAS writes the restart stream before history, so a kill between the two leaves the restart file intact and only the history file truncated.

Known limitations

Regional (limited-area) runs

The lbc var_struct holding lateral boundary tendency arrays is not in the restart stream, and atm_core_run_start performs a firstCall = .true. LBC initialization regardless of config_do_restart. A restarted regional run may therefore force its boundary zone with a zero tendency for up to one lbc_in interval. This affects limited-area runs only. The regional configuration is not tested for restart reproducibility yet.

Restart timing and surface updates

Not fixed. All twelve physics alarms created in physics_run_init (mpas_atmphys_manager.F) are anchored to the run's start time rather than to an absolute reference, so a restart that does not land on an alarm's interval boundary shifts that alarm's whole schedule.

The defect is generic, but it only causes damage where two things coincide: a long interval, and a handler that destroys state rather than merely setting a flag.

Alarm Default interval Handler
radtlw, radtsw 00:30:00 sets a flag only
camAlarm 06:00:00 sets a flag only
conv, pbl none sets a flag only
green 24:00:00 physics_update_surface, overwrites sfc_albbck
acrain, acradt none (config_bucket_update) resets accumulation buckets

config_greeness_update is the one that bites in practice. Its 24-hour interval is the longest, so nearly any restart misaligns it, and its handler overwrites the sea-ice albedo that physics_update_sst had set. The 30-minute radiation alarms stay aligned for any restart on an hour boundary, which is why they are not seen to misbehave.

Restart on a day boundary to avoid this. Mid-day restarts are known to produce small differences in sfc_albbck over sea-ice cells. If you enable config_bucket_update with a long interval, expect the same problem from the bucket alarms.