Skip to content

Commit

Permalink
Update all tests and examples to remove legacy log behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Jul 27, 2023
1 parent d4c428e commit bd7ca51
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 85 deletions.
7 changes: 4 additions & 3 deletions examples/compressible/dcmip_3_1_meanflow_quads.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@

# I/O
dirname = 'dcmip_3_1_meanflow'
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
)
diagnostic_fields = [Perturbation('theta'), Perturbation('rho'), CompressibleKineticEnergy()]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
13 changes: 7 additions & 6 deletions examples/compressible/dry_bryan_fritsch.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@
no_normal_flow_bc_ids=[1, 2])

# I/O
output = OutputParameters(dirname=dirname,
dumpfreq=int(tmax / (5*dt)),
dumplist=['rho'],
dump_vtus=False,
dump_nc=True,
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=int(tmax / (5*dt)),
dumplist=['rho'],
dump_vtus=False,
dump_nc=True,
)
diagnostic_fields = [Perturbation('theta')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
9 changes: 5 additions & 4 deletions examples/compressible/moist_bryan_fritsch.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@

# I/O
dirname = 'moist_bryan_fritsch'
output = OutputParameters(dirname=dirname,
dumpfreq=int(tmax / (5*dt)),
dumplist=['u'],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=int(tmax / (5*dt)),
dumplist=['u'],
)
diagnostic_fields = [Theta_e(eqns)]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
9 changes: 5 additions & 4 deletions examples/compressible/mountain_hydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@

# I/O
dirname = 'hydrostatic_mountain'
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
)
diagnostic_fields = [CourantNumber(), VelocityZ(), HydrostaticImbalance(eqns),
Perturbation('theta'), Perturbation('rho')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)
Expand Down
11 changes: 6 additions & 5 deletions examples/compressible/mountain_nonhydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@

# I/O
dirname = 'nonhydrostatic_mountain'
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
log_level='INFO',
checkpoint_method='dumbcheckpoint')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
checkpoint_method='dumbcheckpoint',
)
diagnostic_fields = [CourantNumber(), VelocityZ(), Perturbation('theta'), Perturbation('rho')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
9 changes: 5 additions & 4 deletions examples/compressible/robert_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@

# I/O
dirname = 'robert_bubble'
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
)
diagnostic_fields = [CourantNumber(), Perturbation('theta'), Perturbation('rho')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
9 changes: 5 additions & 4 deletions examples/compressible/skamarock_klemp_hydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@

# I/O
dirname = 'skamarock_klemp_hydrostatic'
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
)
diagnostic_fields = [CourantNumber(), Perturbation('theta'), Perturbation('rho')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
13 changes: 7 additions & 6 deletions examples/compressible/skamarock_klemp_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@
points_z = [H/2.]
points = np.array([p for p in itertools.product(points_x, points_z)])
dirname = 'skamarock_klemp_nonlinear'
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
pddumpfreq=dumpfreq,
dumplist=['u'],
point_data=[('theta_perturbation', points)],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
pddumpfreq=dumpfreq,
dumplist=['u'],
point_data=[('theta_perturbation', points)],
)
diagnostic_fields = [CourantNumber(), Gradient("u"), Perturbation('theta'),
Gradient("theta_perturbation"), Perturbation('rho'),
RichardsonNumber("theta", parameters.g/Tsurf), Gradient("theta")]
Expand Down
9 changes: 5 additions & 4 deletions examples/compressible/straka_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@
# I/O
dirname = "straka_dx%s_dt%s" % (delta, dt)
dumpfreq = int(tmax / (ndumps*dt))
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist=['u'],
)
diagnostic_fields = [CourantNumber(), Perturbation('theta'), Perturbation('rho')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
10 changes: 7 additions & 3 deletions examples/compressible/unsaturated_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@

# I/O
dirname = 'unsaturated_bubble'
output = OutputParameters(dirname=dirname, dumpfreq=tdump, dump_nc=True,
dumplist=['cloud_water', 'rain'], log_level='INFO',
checkpoint=False)
output = OutputParameters(
dirname=dirname,
dumpfreq=tdump,
dump_nc=True,
dumplist=['cloud_water', 'rain'],
checkpoint=False
)
diagnostic_fields = [RelativeHumidity(eqns), Perturbation('theta'),
Perturbation('water_vapour'), Perturbation('rho')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)
Expand Down
9 changes: 5 additions & 4 deletions examples/incompressible/skamarock_klemp_incompressible.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
eqns = IncompressibleBoussinesqEquations(domain, parameters)

# I/O
output = OutputParameters(dirname='skamarock_klemp_incompressible',
dumpfreq=dumpfreq,
dumplist=['u'],
log_level='INFO')
output = OutputParameters(
dirname='skamarock_klemp_incompressible',
dumpfreq=dumpfreq,
dumplist=['u'],
)
# list of diagnostic fields, each defined in a class in diagnostics.py
diagnostic_fields = [CourantNumber(), Divergence(), Perturbation('b')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)
Expand Down
7 changes: 4 additions & 3 deletions examples/shallow_water/linear_williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
eqns = LinearShallowWaterEquations(domain, parameters, fexpr=fexpr)

# I/O
output = OutputParameters(dirname='linear_williamson_2',
dumpfreq=dumpfreq,
log_level='INFO')
output = OutputParameters(
dirname='linear_williamson_2',
dumpfreq=dumpfreq,
)
diagnostic_fields = [SteadyStateError('u'), SteadyStateError('D')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
9 changes: 5 additions & 4 deletions examples/shallow_water/thermal_williamson2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
# IO
dirname = "thermal_williamson2"
dumpfreq = int(tmax / (ndumps*dt))
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist_latlon=['D', 'D_error'],
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist_latlon=['D', 'D_error'],
)

diagnostic_fields = [RelativeVorticity(), PotentialVorticity(),
ShallowWaterKineticEnergy(),
Expand Down
11 changes: 6 additions & 5 deletions examples/shallow_water/williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
# I/O
dirname = "williamson_2_ref%s_dt%s" % (ref_level, dt)
dumpfreq = int(tmax / (ndumps*dt))
output = OutputParameters(dirname=dirname,
dumpfreq=dumpfreq,
dumplist_latlon=['D', 'D_error'],
log_level='INFO',
dump_nc=True)
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dumplist_latlon=['D', 'D_error'],
dump_nc=True,
)

diagnostic_fields = [RelativeVorticity(), PotentialVorticity(),
ShallowWaterKineticEnergy(),
Expand Down
9 changes: 5 additions & 4 deletions examples/shallow_water/williamson_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@
# I/O
dirname = "williamson_5_ref%s_dt%s" % (ref_level, dt)
dumpfreq = int(tmax / (ndumps*dt))
output = OutputParameters(dirname=dirname,
dumplist_latlon=['D'],
dumpfreq=dumpfreq,
log_level='INFO')
output = OutputParameters(
dirname=dirname,
dumplist_latlon=['D'],
dumpfreq=dumpfreq,
)
diagnostic_fields = [Sum('D', 'topography')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
7 changes: 4 additions & 3 deletions integration-tests/equations/test_linear_sw_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def run_linear_sw_wave(tmpdir):
eqns = LinearShallowWaterEquations(domain, parameters, fexpr=fexpr)

# I/O
output = OutputParameters(dirname=str(tmpdir)+"/linear_sw_wave",
dumpfreq=1,
log_level='INFO')
output = OutputParameters(
dirname=str(tmpdir)+"/linear_sw_wave",
dumpfreq=1,
)
io = IO(domain, output)
transport_methods = [DefaultTransport(eqns, "D")]

Expand Down
7 changes: 4 additions & 3 deletions integration-tests/equations/test_sw_fplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ def run_sw_fplane(tmpdir):
eqns = ShallowWaterEquations(domain, parameters, fexpr=fexpr)

# I/O
output = OutputParameters(dirname=str(tmpdir)+"/sw_fplane",
dumpfreq=1,
log_level='INFO')
output = OutputParameters(
dirname=str(tmpdir)+"/sw_fplane",
dumpfreq=1,
)

io = IO(domain, output, diagnostic_fields=[CourantNumber()])

Expand Down
40 changes: 26 additions & 14 deletions integration-tests/model/test_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ def test_checkpointing(tmpdir, stepper_type, checkpoint_method):
dirname_2 = str(tmpdir)+'/checkpointing_2'
dirname_3 = str(tmpdir)+'/checkpointing_3'

output_1 = OutputParameters(dirname=dirname_1, dumpfreq=1,
checkpoint_method=checkpoint_method,
chkptfreq=4, log_level='INFO')
output_2 = OutputParameters(dirname=dirname_2, dumpfreq=1,
checkpoint_method=checkpoint_method,
chkptfreq=2, log_level='INFO')
output_1 = OutputParameters(
dirname=dirname_1,
dumpfreq=1,
checkpoint_method=checkpoint_method,
chkptfreq=4,
)
output_2 = OutputParameters(
dirname=dirname_2,
dumpfreq=1,
checkpoint_method=checkpoint_method,
chkptfreq=2,
)

stepper_1, eqns_1 = set_up_model_objects(mesh, dt, output_1, stepper_type)
stepper_2, eqns_2 = set_up_model_objects(mesh, dt, output_2, stepper_type)
Expand All @@ -144,10 +150,13 @@ def test_checkpointing(tmpdir, stepper_type, checkpoint_method):

chkpt_filename = 'chkpt' if checkpoint_method == 'dumbcheckpoint' else 'chkpt.h5'
chkpt_2_path = path.join(stepper_2.io.dumpdir, chkpt_filename)
output_3 = OutputParameters(dirname=dirname_3, dumpfreq=1,
chkptfreq=2, log_level='INFO',
checkpoint_method=checkpoint_method,
checkpoint_pickup_filename=chkpt_2_path)
output_3 = OutputParameters(
dirname=dirname_3,
dumpfreq=1,
chkptfreq=2,
checkpoint_method=checkpoint_method,
checkpoint_pickup_filename=chkpt_2_path,
)

if checkpoint_method == 'checkpointfile':
mesh = pick_up_mesh(output_3, mesh_name)
Expand Down Expand Up @@ -180,10 +189,13 @@ def test_checkpointing(tmpdir, stepper_type, checkpoint_method):
# Run *new* timestepper for 2 time steps
# ------------------------------------------------------------------------ #

output_3 = OutputParameters(dirname=dirname_3, dumpfreq=1,
chkptfreq=2, log_level='INFO',
checkpoint_method=checkpoint_method,
checkpoint_pickup_filename=chkpt_2_path)
output_3 = OutputParameters(
dirname=dirname_3,
dumpfreq=1,
chkptfreq=2,
checkpoint_method=checkpoint_method,
checkpoint_pickup_filename=chkpt_2_path
)
if checkpoint_method == 'checkpointfile':
mesh = pick_up_mesh(output_3, mesh_name)
stepper_3, _ = set_up_model_objects(mesh, dt, output_3, stepper_type)
Expand Down
9 changes: 7 additions & 2 deletions integration-tests/model/test_nc_outputting.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ def test_nc_outputting(tmpdir, geometry, domain_and_mesh_details):
eqn = AdvectionEquation(domain, V, 'f')
transport_scheme = ForwardEuler(domain)
transport_method = DGUpwind(eqn, 'f')
output = OutputParameters(dirname=dirname, dumpfreq=1, dump_nc=True,
dumplist=['f'], log_level='INFO', checkpoint=False)
output = OutputParameters(
dirname=dirname,
dumpfreq=1,
dump_nc=True,
dumplist=['f'],
checkpoint=False
)

# Make velocity components for this geometry
if geometry == "interval":
Expand Down

0 comments on commit bd7ca51

Please sign in to comment.