diff --git a/yt/frontends/boxlib/data_structures.py b/yt/frontends/boxlib/data_structures.py index d7c8e087a71..2725275896f 100644 --- a/yt/frontends/boxlib/data_structures.py +++ b/yt/frontends/boxlib/data_structures.py @@ -739,6 +739,9 @@ def _parse_cparams(self): param, vals = (s.strip() for s in line.split("=")) except ValueError: continue + # Castro and Maestro mark overridden defaults with a "[*]" before + # the parameter name + param = param.removeprefix("[*]").strip() if param == "amr.ref_ratio": vals = self.refine_by = int(vals[0]) elif param == "Prob.lo_bc": @@ -1128,16 +1131,6 @@ def _parse_parameter_file(self): self.parameters[fields[0]] = fields[1].strip() line = next(f) - # runtime parameters that we overrode follow "Inputs File - # Parameters" - # skip the "====..." line - line = next(f) - for line in f: - if line.strip() == "" or "fortin parameters" in line: - continue - p, v = line.strip().split("=") - self.parameters[p] = v.strip() - # hydro method is set by the base class -- override it here self.parameters["HydroMethod"] = "Castro" @@ -1199,21 +1192,8 @@ def _parse_parameter_file(self): fields = line.split(":") self.parameters[fields[0]] = fields[1].strip() - with open(jobinfo_filename) as f: - # get the runtime parameters - for line in f: - try: - p, v = (_.strip() for _ in line[4:].split("=", 1)) - if len(v) == 0: - self.parameters[p] = "" - else: - self.parameters[p] = _guess_pcast(v) - except ValueError: - # not a parameter line - pass - - # hydro method is set by the base class -- override it here - self.parameters["HydroMethod"] = "Maestro" + # hydro method is set by the base class -- override it here + self.parameters["HydroMethod"] = "Maestro" # set the periodicity based on the integer BC runtime parameters periodicity = [False, False, False] diff --git a/yt/frontends/boxlib/tests/test_outputs.py b/yt/frontends/boxlib/tests/test_outputs.py index d3e9e5d91e5..f0d3bb2647d 100644 --- a/yt/frontends/boxlib/tests/test_outputs.py +++ b/yt/frontends/boxlib/tests/test_outputs.py @@ -443,3 +443,28 @@ def test_maestro_parameters(): # Check an int parameter assert ds.parameters["s0_interp_type"] == 3 assert type(ds.parameters["s0_interp_type"]) is int # noqa: E721 + + +castro_1d_cyl = "castro_sedov_1d_cyl_plt00150" + + +@requires_file(castro_1d_cyl) +def test_castro_parameters(): + ds = data_dir_load(castro_1d_cyl) + assert isinstance(ds, CastroDataset) + + # Modified from default (leading [*]) + assert ds.parameters["castro.do_hydro"] == 1 + assert ds.parameters["castro.cfl"] == 0.5 + assert ds.parameters["problem.p_ambient"] == float("1e-06") + # Leading [*] should be removed from the parameter name + assert "[*] castro.do_hydro" not in ds.parameters + + # Not modified from default + assert ds.parameters["castro.pslope_cutoff_density"] == float("-1e+20") + assert ds.parameters["castro.do_sponge"] == 0 + assert ds.parameters["problem.dens_ambient"] == 1 + assert ds.parameters["eos.eos_assume_neutral"] == 1 + + # Empty string value + assert ds.parameters["castro.stopping_criterion_field"] is None