@@ -10,39 +10,15 @@ import YAML
10
10
import ClimaComms
11
11
ClimaComms. @import_required_backends
12
12
using ClimaUtilities. ClimaArtifacts
13
- import ClimaCalibrate:
14
- set_up_forward_model,
15
- run_forward_model,
16
- path_to_ensemble_member,
17
- ExperimentConfig
18
-
19
- """
20
- set_up_forward_model(member, iteration, experiment_dir::AbstractString)
21
- set_up_forward_model(member, iteration, ::ExperimentConfig; experiment_dir)
22
- set_up_forward_model(member, iteration, config_dict::AbstractDict)
23
-
24
- Return an AtmosConfig object for the given member and iteration.
25
-
26
- Turns off default diagnostics and sets the TOML parameter file to the member's path.
27
- This assumes that the config dictionary has an `output_dir` key.
28
- """
29
- function set_up_forward_model (
30
- member,
31
- iteration,
32
- :: ExperimentConfig ;
33
- experiment_dir = dirname (Base. active_project ()),
34
- )
35
- # Assume experiment_dir is project dir
36
- config_dict = YAML. load_file (joinpath (experiment_dir, " model_config.yml" ))
37
- set_up_forward_model (member, iteration, config_dict:: AbstractDict )
38
- end
39
-
40
- function set_up_forward_model (member, iteration, experiment_dir:: AbstractString )
41
- config_dict = YAML. load_file (joinpath (experiment_dir, " model_config.yml" ))
42
- set_up_forward_model (member, iteration, config_dict:: AbstractDict )
43
- end
44
-
45
- function set_up_forward_model (member, iteration, config_dict:: AbstractDict )
13
+ import ClimaCalibrate: forward_model, path_to_ensemble_member
14
+ import ClimaCalibrate as CAL
15
+
16
+ function CAL. forward_model (iteration, member, config_dict = nothing )
17
+ experiment_dir = dirname (Base. active_project ())
18
+ if isnothing (config_dict)
19
+ config_dict =
20
+ YAML. load_file (joinpath (experiment_dir, " model_config.yml" ))
21
+ end
46
22
output_dir = config_dict[" output_dir" ]
47
23
member_path = path_to_ensemble_member (output_dir, iteration, member)
48
24
config_dict[" output_dir" ] = member_path
@@ -55,21 +31,16 @@ function set_up_forward_model(member, iteration, config_dict::AbstractDict)
55
31
56
32
# Turn off default diagnostics
57
33
config_dict[" output_default_diagnostics" ] = false
58
- return CA. AtmosConfig (config_dict)
59
- end
60
-
61
- """
62
- run_forward_model(atmos_config::CA.AtmosConfig)
63
-
64
- Run the atmosphere model with the given an AtmosConfig object.
65
- Currently only has basic error handling.
66
- """
67
- function run_forward_model (atmos_config:: CA.AtmosConfig )
34
+ atmos_config = CA. AtmosConfig (
35
+ config_dict;
36
+ comms_ctx = ClimaComms. SingletonCommsContext (),
37
+ )
68
38
simulation = CA. get_simulation (atmos_config)
69
39
sol_res = CA. solve_atmos! (simulation)
70
40
if sol_res. ret_code == :simulation_crashed
71
41
error (
72
42
" The ClimaAtmos simulation has crashed. See the stack trace for details." ,
73
43
)
74
44
end
45
+ return simulation
75
46
end
0 commit comments