def run_test(test_name, L, output_file): """Run an ISMIP-HOM test on a [0,L]*[0,L] domain and save results to an output_file.""" grid, geometry, enthalpy, yield_stress = init(test_name, L) Mz = int(config.get_number("stress_balance.blatter.Mz")) coarsening_factor = int( config.get_number("stress_balance.blatter.coarsening_factor")) model = PISM.BlatterISMIPHOM(grid, Mz, coarsening_factor, tests[test_name]) stress_balance = PISM.StressBalance(grid, model, PISM.BlatterMod(model)) stress_balance.init() inputs = PISM.StressBalanceInputs() inputs.geometry = geometry inputs.basal_yield_stress = yield_stress inputs.enthalpy = enthalpy stress_balance.update(inputs, True) try: output = PISM.util.prepare_output(output_file) output.set_compression_level(1) ds = stress_balance.diagnostics() ds["velsurf"].compute().write(output) geometry.ice_thickness.write(output) geometry.bed_elevation.write(output) geometry.ice_surface_elevation.write(output) yield_stress.write(output) finally: output.close()