Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/solver/type_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,16 @@ function get_simulation(config::AtmosConfig)
output_dir = sim_info.output_dir
@info "Simulation info" job_id output_dir

output_toml_file = joinpath(output_dir, "$(job_id)_parameters.toml")
CP.log_parameter_information(
config.toml_dict,
joinpath(output_dir, "$(job_id)_parameters.toml"),
output_toml_file,
strict = config.parsed_args["strict_params"],
)
YAML.write_file(joinpath(output_dir, "$job_id.yml"), config.parsed_args)

output_args = copy(config.parsed_args)
output_args["toml"] = [abspath(output_toml_file)]
YAML.write_file(joinpath(output_dir, "$job_id.yml"), output_args)

if sim_info.restart
s = @timed_str begin
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ if TEST_GROUP in ("infrastructure", "all")
@safetestset "Variable manipulations" begin @time include("variable_manipulations_tests.jl") end
@safetestset "Parameter tests" begin @time include("parameter_tests.jl") end

@safetestset "Check TOML path" begin @time include("test_output_yaml_path.jl") end

# Interface tests
@safetestset "Radiation interface tests" begin @time include("rrtmgp_interface.jl") end
@safetestset "Coupler compatibility" begin @time include("coupler_compatibility.jl") end
Expand Down
39 changes: 39 additions & 0 deletions test/test_output_yaml_path.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import ClimaAtmos as CA
import YAML
using Test

@testset "Output YAML Path Test" begin
mktempdir() do output_dir
job_id = "test_yaml_path_fix"

input_toml_path = joinpath(@__DIR__, "..", "toml", "bomex_box_rhoe.toml")

config_dict = Dict(
"job_id" => job_id,
"output_dir" => output_dir,
"config" => "box",
"toml" => [input_toml_path],
"x_elem" => 2,
"y_elem" => 2,
"z_elem" => 4,
"dt" => "1s",
"t_end" => "2s",
"dt_save_state_to_disk" => "2s",
)

config = CA.AtmosConfig(config_dict; job_id)

simulation = CA.get_simulation(config)
real_output_dir = simulation.output_dir

output_yaml_path = joinpath(real_output_dir, "$(job_id).yml")
output_toml_path = joinpath(real_output_dir, "$(job_id)_parameters.toml")

@test isfile(output_yaml_path)
@test isfile(output_toml_path)

yaml_data = YAML.load_file(output_yaml_path)
@test yaml_data["toml"] == [abspath(output_toml_path)]
@test yaml_data["toml"] != [input_toml_path]
end
end
Loading