Learn R Programming

lpjmlkit (version 1.0.11)

read_config: Read an LPJmL configuration file

Description

Reads a configuration (config) file (compilable csjon/js file or json file) and turns it into a nested list object.

Usage

read_config(filename, from_restart = FALSE, macro = "")

Value

A nested list object representing the LPJmL configuration read from filename.

Arguments

filename

Character string representing path (if different from current working directory) and filename.

from_restart

Logical defining whether config files should be read as from_restart (transient run) or without (spinup run). Defaults to FALSE (spinup run). Used only if file is not pre-compiled (no json).

macro

Optional character string to pass one or several macros to the pre-compiler, e.g. ("-DFROM_RESTART"). Used only if file is not pre-compiled (no json).

Examples

Run this code
if (FALSE) {
 config <- read_config(filename = "config_spinup.json")

 config[["version"]]
 # [1] "5.3"

 config[["pftpar"]][[1]][["name"]]
 # [1] "tropical broadleaved evergreen tree"

 config[["input"]][["coord"]][["name"]]
 # [1] "input_VERSION2/grid.bin"

 # visualize configuration as tree view
 View(config)
}

Run the code above in your browser using DataLab