Skip to content

Commit

Permalink
Merge pull request #879 from CliMA/as/test-longruns
Browse files Browse the repository at this point in the history
Clean up long-run pipeline, info statements.
  • Loading branch information
akshaysridhar authored Jul 16, 2024
2 parents 7291a96 + 4b8b2e4 commit 3a2e35c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion config/longrun_configs/amip_target_topo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ hourly_checkpoint: true
land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
hyperdiffusion: "ClimaHyperdiffusion"
netcdf_interpolate_z_over_msl: true
rad: "allskywithclear"
start_date: "20100101"
Expand All @@ -22,4 +23,4 @@ t_end: "100days"
topo_smoothing: true
topography: "Earth"
turb_flux_partition: "CombinedStateFluxesMOST"
vert_diff: "true"
vert_diff: "FriersonDiffusion"
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ start_date: "19790301"
surface_setup: "PrescribedSurface"
t_end: "20days"
turb_flux_partition: "CombinedStateFluxesMOST"
vert_diff: "true"
vert_diff: "FriersonDiffusion"
18 changes: 14 additions & 4 deletions experiments/ClimaEarth/components/atmosphere/climaatmos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,28 @@ function get_atmos_config_dict(coupler_dict::Dict, job_id::String)
atmos_config_file = coupler_dict["atmos_config_file"]
atmos_config_repo = coupler_dict["atmos_config_repo"]
# override default or specified configs with coupler arguments, and set the correct atmos config_file
comms_ctx = ClimaComms.context()
@info atmos_config_repo
if atmos_config_repo == "ClimaCoupler"
@assert !isnothing(atmos_config_file) "Must specify `atmos_config_file` within ClimaCoupler."
@info "Using Atmos configuration from ClimaCoupler in $atmos_config_file"
if ClimaComms.iamroot(comms_ctx)
@info "Using Atmos configuration from ClimaCoupler in $atmos_config_file"
end
atmos_config = merge(
CA.override_default_config(joinpath(pkgdir(ClimaCoupler), atmos_config_file)),
coupler_dict,
Dict("config_file" => atmos_config_file),
)
elseif atmos_config_repo == "ClimaAtmos"
if isnothing(atmos_config_file)
@info "Using Atmos default configuration"
if ClimaComms.iamroot(comms_ctx)
@info "Using Atmos default configuration"
end
atmos_config = merge(CA.default_config_dict(), coupler_dict, Dict("config_file" => atmos_config_file))
else
@info "Using Atmos configuration from $atmos_config_file"
if ClimaComms.iamroot(comms_ctx)
@info "Using Atmos configuration from $atmos_config_file"
end
atmos_config = merge(
CA.override_default_config(joinpath(pkgdir(CA), atmos_config_file)),
coupler_dict,
Expand All @@ -339,7 +347,9 @@ function get_atmos_config_dict(coupler_dict::Dict, job_id::String)
toml_file = isnothing(toml_file) ? joinpath(pkgdir(ClimaCoupler), default_toml_file) : toml_file

if !isnothing(toml_file)
@info "Overwriting Atmos parameters from $toml_file"
if ClimaComms.iamroot(comms_ctx)
@info "Overwriting Atmos parameters from $toml_file"
end
atmos_config = merge(atmos_config, Dict("toml" => [toml_file]))
end

Expand Down
5 changes: 3 additions & 2 deletions experiments/ClimaEarth/run_amip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ job_id = parsed_args["job_id"]
config_dict = YAML.load_file(parsed_args["config_file"])
config_dict = merge(parsed_args, config_dict)

comms_ctx = Utilities.get_comms_context(parsed_args)
ClimaComms.init(comms_ctx)

## get component model dictionaries (if applicable)
atmos_config_dict, config_dict = get_atmos_config_dict(config_dict, job_id)
atmos_config_object = CA.AtmosConfig(atmos_config_dict)
Expand Down Expand Up @@ -138,8 +141,6 @@ We set up communication context for CPU single thread/CPU with MPI/GPU. If no de
then `ClimaComms` automatically selects the device from which this code is called.
=#

comms_ctx = Utilities.get_comms_context(parsed_args)
ClimaComms.init(comms_ctx)

## make sure we don't use animations for GPU runs
if comms_ctx.device isa ClimaComms.CUDADevice
Expand Down
8 changes: 4 additions & 4 deletions src/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ function get_comms_context(parsed_args)
comms_ctx = ClimaComms.context(device)
ClimaComms.init(comms_ctx)

@info "Running on $(nameof(typeof(device)))."

if comms_ctx isa ClimaComms.SingletonCommsContext
@info "Setting up single-process ClimaCoupler run"
@info "Setting up single-process ClimaCoupler run on device: $(nameof(typeof(device)))."
else
@info "Setting up distributed ClimaCoupler run" nprocs = ClimaComms.nprocs(comms_ctx)
if ClimaComms.iamroot(comms_ctx)
@info "Setting up distributed ClimaCoupler run on " nprocs = ClimaComms.nprocs(comms_ctx) device = "$(nameof(typeof(device)))"
end
end

return comms_ctx
Expand Down

0 comments on commit 3a2e35c

Please sign in to comment.