Inputs Schema
Exec/Tools/build_erf_schema.py writes a per-build schema of ERF’s inputs. It lists every literal ParmParse
query in ERF and in the AMReX it builds against, typed from the variable each query fills. For each key it records:
whether a build feature is needed (a key read only under
#ifdef ERF_USE_X);the variable’s default, as a parsed literal;
whether ERF now refuses the key at start-up.
Each fact names the source line it comes from. Exec/Tools/check_erf_inputs.py --schema checks a deck against
it.
The schema is reference material for checking and tooling, not a fixed workflow contract. It reads only literal
queries, and a key whose variable type it cannot find is unknown. Prefixes ERF builds at run time (boundary
faces, stations, refinement indicators, particle containers) are read as families, listed in scan.FAMILIES;
reads the generator still cannot place are listed under unresolved. A key name passed to a local lambda and
read inside it (get_layer_prop in ERF_SLM.cpp) takes the literal of each call of that lambda; a call whose
argument is not a literal is listed under unresolved. A key name built in another way, such as a concatenation
at the read, is not in the schema and is not listed.
Generating a Schema
The tool reads source with git archive, so nothing is checked out and no build is run. AMReX is taken at the
commit ERF’s Submodules/AMReX points to:
python3 Exec/Tools/build_erf_schema.py --repo . --erf HEAD \
--cmake="-DERF_ENABLE_CUDA=ON -DERF_ENABLE_NETCDF=ON -DERF_ENABLE_RRTMGP=ON" --out erf_inputs_schema.json
Build options come from --cmake=..., from --cmake-cache CMakeCache.txt, or from both. A CMakeCache.txt
holds every ERF option. A -D list holds only the options passed, and the rest take the CMakeLists.txt
defaults. The schema records which kind it was given.
Facts that belong to the machine rather than to the build come from --site-facts, a JSON list. Whether the MPI
is GPU-aware is one; it affects amrex.use_gpu_aware_mpi = true.
The same commits, options and site facts give the same bytes.
What a Key Records
Type:
int,real,bool,stringorenum, each also as a list;unknown; orremoved. When one variable name has several types in a file, the read call decides (a list forqueryarr/getarr, a scalar otherwise), then the nearest declaration before the read. Every read method ofAMReX_ParmParse.His read; aquerylineread takes the whole line, aquerytableread is recorded as a table, aquery_enum_sloppyread records the characters it ignores, and aWithParserorAsDoubleread is markedparser, since it takes an expression by design.Layer: whether AMReX or ERF reads the key. A key both read keeps both source lines. When two reads disagree, an array read makes the key a list, an enum read wins over a
std::stringprobe, and the pair is kept intype_conflict. A refusal in problem-specific code (Source/Prob/) is listed underrefused_byand does not override a read elsewhere.Default: the initializer of the variable the query fills, in canonical form, or none. A
pp.addof a literal in ERF’sadd_par(Source/main.cpp) is the default instead: it runs before the inputs are read, so the inputs override it (amr.n_properis 2, not AMReX’s 1).Build requirements: the
ERF_USE_Xmacro a key is read under, with the#ifdefline. Also any enum value that is refused, or whose model is only built, without a feature.Removed: the key’s read sits in an
ifwhose body always callsAbortorErrorand does not go on to read the key. This coverscontains(k),query(k, x) > 0andcountval(k) > 0, the last also through a variable.
Each value type has one canonical form: 1, 1.0 and 1e0 are one real; t and 1 are true; an
enum name takes its declared case. The schema lists these rules under canonical_rules.
Checking a Deck
python3 Exec/Tools/check_erf_inputs.py --schema erf_inputs_schema.json inputs
With a schema, the checker reports:
a key no query reads, as WARNING; when the schema’s
unresolvedlist has a read of that name through a prefix the generator could not resolve, as INFO naming the line;a removed key, as ERROR;
a string or enum value ERF does not know, or fewer per-level values than levels, as ERROR;
a bool, int or real value that is not a plain literal (
2*0.5,300.;,1e9for an int), as WARNING, since ParmParse hands it to its parser at run time, except for a key read with the parser (queryWithParser,queryAsDouble);1D0is an ERROR, since neither ParmParse nor its parser reads adorDexponent;more words than the key reads (
erf.check_int = 10 steps; ParmParse reads the first), as WARNING;a key or value that needs a feature the build lacks, as ERROR;
a
@NAME@placeholder (aconfigure_filetemplate), as INFO.
It also compares the schema’s removed keys with the curated list of retired keys in checks/keys.py, and prints
any difference as INFO.
Tests
python3 -m unittest discover -s Exec/Tools/erf_inputs_schema/tests
python3 Exec/Tools/check_erf_inputs.py --self-test