Write LPJ-GUESS binary state allowing cohort count changes
Source:R/write_state.R
write_binary_LPJGUESS_flexible.RdA robust writer for LPJ-GUESS `0.state` that supports changes in the number of cohorts/individuals (i.e., variable-length Individuals blocks). When no cohort count changes are detected, it can fall back to a fast in-place writer (e.g., your existing `write_binary_LPJGUESS()` that uses stored offsets).
Usage
write_binary_LPJGUESS_flexible(
State_updated,
outdir,
use_fast_inplace_if_possible = TRUE,
verbose = FALSE
)Arguments
- State_updated
A list containing: - `state`: updated Gridcell object (parsed state tree) - `pos_list`: named list/vector of byte offsets for each key - `siz_list`: named list/vector of byte sizes per element for each key
- outdir
Character scalar. Directory containing `0.state` and `meta.bin`.
- use_fast_inplace_if_possible
Logical. If `TRUE`, uses the existing in-place writer when no `number_of_individuals` changes are detected.
- verbose
Logical. If `TRUE`, prints minimal progress messages.
Value
Invisibly returns `TRUE` on success. Side effect: - Creates `bak.state` as a backup of the original `0.state` - Writes a new `0.state` (possibly via `0.state.tmp` and rename)