diff --git a/src/cache/cache.jl b/src/cache/cache.jl index a8925fb7beb..a9db9e6ed45 100644 --- a/src/cache/cache.jl +++ b/src/cache/cache.jl @@ -25,7 +25,6 @@ struct AtmosCache{ NETFLUXTOA, NETFLUXSFC, CONSCHECK, - OD, } """Timestep of the simulation (in seconds). This is also used by callbacks and tendencies""" dt::FT @@ -88,9 +87,6 @@ struct AtmosCache{ """Conservation check for prognostic surface temperature""" conservation_check::CONSCHECK - - """Directory output.""" - output_dir::OD end # Functions on which the model depends: @@ -106,7 +102,7 @@ end # The model also depends on f_plane_coriolis_frequency(params) # This is a constant Coriolis frequency that is only used if space is flat function build_cache(Y, atmos, params, surface_setup, sim_info, aerosol_names) - (; dt, t_end, start_date, output_dir) = sim_info + (; dt, t_end, start_date) = sim_info FT = eltype(params) ᶜcoord = Fields.local_geometry_field(Y.c).coordinates @@ -213,7 +209,6 @@ function build_cache(Y, atmos, params, surface_setup, sim_info, aerosol_names) net_energy_flux_toa, net_energy_flux_sfc, conservation_check, - output_dir, ) return AtmosCache{map(typeof, args)...}(args...) diff --git a/src/callbacks/callbacks.jl b/src/callbacks/callbacks.jl index ff9c17a438d..3b4be000afb 100644 --- a/src/callbacks/callbacks.jl +++ b/src/callbacks/callbacks.jl @@ -489,8 +489,7 @@ simulation will gracefully exit with the integrator. !!! note This may not be reliable for MPI jobs. """ -function maybe_graceful_exit(integrator) - output_dir = integrator.p.output_dir +function maybe_graceful_exit(output_dir, integrator) file = joinpath(output_dir, "graceful_exit.dat") if isfile(file) open(file, "r") do io diff --git a/src/callbacks/get_callbacks.jl b/src/callbacks/get_callbacks.jl index fb8f6f36a7d..a0baf5e4f0c 100644 --- a/src/callbacks/get_callbacks.jl +++ b/src/callbacks/get_callbacks.jl @@ -1,4 +1,12 @@ -function get_diagnostics(parsed_args, atmos_model, Y, p, dt, t_start) +function get_diagnostics( + parsed_args, + atmos_model, + Y, + p, + dt, + t_start, + output_dir, +) FT = Spaces.undertype(axes(Y.c)) @@ -23,7 +31,7 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, dt, t_start) "average" => ((+), CAD.average_pre_output_hook!), ) - hdf5_writer = CAD.HDF5Writer(p.output_dir) + hdf5_writer = CAD.HDF5Writer(output_dir) if !isnothing(parsed_args["netcdf_interpolation_num_points"]) num_netcdf_points = @@ -40,7 +48,7 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, dt, t_start) netcdf_writer = CAD.NetCDFWriter( axes(Y.c), - p.output_dir, + output_dir, num_points = num_netcdf_points; z_sampling_method, sync_schedule = CAD.EveryStepSchedule(), @@ -243,8 +251,10 @@ function get_callbacks(config, sim_info, atmos, params, Y, p, t_start) call_every_n_steps( terminate!; skip_first = true, - condition = (u, t, integrator) -> - maybe_graceful_exit(integrator), + condition = let output_dir = output_dir + (u, t, integrator) -> + maybe_graceful_exit(output_dir, integrator) + end, ), ) diff --git a/src/solver/type_getters.jl b/src/solver/type_getters.jl index 8513af27345..3b07878606f 100644 --- a/src/solver/type_getters.jl +++ b/src/solver/type_getters.jl @@ -713,6 +713,7 @@ function get_simulation(config::AtmosConfig) p, sim_info.dt, t_start, + output_dir, ) end @info "initializing diagnostics: $s" diff --git a/test/coupler_compatibility.jl b/test/coupler_compatibility.jl index e7b063d4b95..c48db9c2b55 100644 --- a/test/coupler_compatibility.jl +++ b/test/coupler_compatibility.jl @@ -91,7 +91,6 @@ const T2 = 290 p.net_energy_flux_toa, p.net_energy_flux_sfc, p.conservation_check, - p.output_dir, ) # Test that set_precomputed_quantities! can be used to update the surface