diff --git a/.buildkite/longruns_gpu/pipeline.yml b/.buildkite/longruns_gpu/pipeline.yml index f7f3fd1c5ae..e2a7aed5d1f 100644 --- a/.buildkite/longruns_gpu/pipeline.yml +++ b/.buildkite/longruns_gpu/pipeline.yml @@ -38,180 +38,180 @@ steps: - wait - - group: "helem 30 dycore" - steps: + # - group: "helem 30 dycore" + # steps: - - label: ":computer: hydrostatic balance (ρe_tot)" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_sphere_hydrostatic_balance_rhoe" + # - label: ":computer: hydrostatic balance (ρe_tot)" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_sphere_hydrostatic_balance_rhoe" - - label: ":computer: dry baroclinic wave" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_dry_baroclinic_wave" + # - label: ":computer: dry baroclinic wave" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_dry_baroclinic_wave" - - label: ":computer: dry baroclinic wave high res" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_dry_baroclinic_wave_he60" + # - label: ":computer: dry baroclinic wave high res" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_dry_baroclinic_wave_he60" - - label: ":computer: baroclinic wave equilmoist" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_moist_baroclinic_wave" + # - label: ":computer: baroclinic wave equilmoist" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_moist_baroclinic_wave" - - label: ":computer: baroclinic wave equilmoist high res" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_moist_baroclinic_wave_he60" + # - label: ":computer: baroclinic wave equilmoist high res" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_moist_baroclinic_wave_he60" - - label: ":computer: dry held-suarez" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_dry_held_suarez" + # - label: ":computer: dry held-suarez" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_dry_held_suarez" - - label: ":computer: held-suarez, equilmoist" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_moist_held_suarez" + # - label: ":computer: held-suarez, equilmoist" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_moist_held_suarez" - - label: ":computer: held-suarez equilmoist + deep-atmosphere eqns" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_moist_held_suarez_deepatmos" - agents: - slurm_gpus: 1 - slurm_time: 12:00:00 + # - label: ":computer: held-suarez equilmoist + deep-atmosphere eqns" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_moist_held_suarez_deepatmos" + # agents: + # slurm_gpus: 1 + # slurm_time: 12:00:00 - - group: "helem 16 aquaplanet" - steps: + # - group: "helem 16 aquaplanet" + # steps: - - label: ":computer: aquaplanet equilmoist allsky radiation + 0M microphysics" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_allsky_0M" + # - label: ":computer: aquaplanet equilmoist allsky radiation + 0M microphysics" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_allsky_0M" - - label: ":computer: aquaplanet equilmoist allsky radiation + diagnostic edmf + 0M microphysics" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_allsky_diagedmf_0M" + # - label: ":computer: aquaplanet equilmoist allsky radiation + diagnostic edmf + 0M microphysics" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_allsky_diagedmf_0M" - - label: ":computer: aquaplanet equilmoist allsky radiation + prognostic edmf diffusion only + 0M microphysics" - command: - - srun julia --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_allsky_progedmf_diffonly_0M" + # - label: ":computer: aquaplanet equilmoist allsky radiation + prognostic edmf diffusion only + 0M microphysics" + # command: + # - srun julia --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_allsky_progedmf_diffonly_0M" - - label: ":computer: aquaplanet equilmoist allsky radiation + 0M microphysics + earth topography" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_allsky_0M_earth" + # - label: ":computer: aquaplanet equilmoist allsky radiation + 0M microphysics + earth topography" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_allsky_0M_earth" - - label: ":umbrella: aquaplanet equilmoist allsky radiation + 1M microphysics" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_allsky_1M" + # - label: ":umbrella: aquaplanet equilmoist allsky radiation + 1M microphysics" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_allsky_1M" - - label: ":computer: aquaplanet equilmoist allsky radiation + time-varying insolation + 0M microphysics + slab ocean" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_allsky_tvinsol_0M_slabocean" + # - label: ":computer: aquaplanet equilmoist allsky radiation + time-varying insolation + 0M microphysics + slab ocean" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_allsky_tvinsol_0M_slabocean" - - group: "DYAMOND" + # - group: "DYAMOND" - steps: + # steps: - - label: ":computer: aquaplanet dyamond" - command: - - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME - artifact_paths: "$$JOB_NAME/output_active/*" - agents: - slurm_gpus: 1 - slurm_time: 24:00:00 - env: - CLIMACOMMS_DEVICE: "CUDA" - JOB_NAME: "longrun_aquaplanet_dyamond" + # - label: ":computer: aquaplanet dyamond" + # command: + # - srun julia --color=yes --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml --job_id $$JOB_NAME + # artifact_paths: "$$JOB_NAME/output_active/*" + # agents: + # slurm_gpus: 1 + # slurm_time: 24:00:00 + # env: + # CLIMACOMMS_DEVICE: "CUDA" + # JOB_NAME: "longrun_aquaplanet_dyamond" - group: "atmos-only coupler runs" diff --git a/Artifacts.toml b/Artifacts.toml index 6ea887b27ab..353542ca4aa 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -25,3 +25,13 @@ git-tree-sha1 = "6693f8451b447543952b3d557d733c7e5c670ed3" [[ozone_concentrations_lowres.download]] sha256 = "908384b32e90c733c2173654afbb974d238a9a516ad8965039077c6ddb29b5f0" url = "https://caltech.box.com/shared/static/6c16wt7i1htxq6tadpt1ng2uftjgdtpr.gz" + +[era5_cloud] +git-tree-sha1 = "10742e0a2e343d13bb04df379e300a83402d4106" + + [[era5_cloud.download]] + sha256 = "bb51e2f2d315b487e05a8d38944d4ad937ee4a40c43b68541220c5d54425e24a" + url = "https://caltech.box.com/shared/static/b6ur4ap4vo04j09vdulem96z9fxqlgyn.gz" + + + diff --git a/config/default_configs/default_config.yml b/config/default_configs/default_config.yml index 82c44fd0dc6..8c9e2a4d7bb 100644 --- a/config/default_configs/default_config.yml +++ b/config/default_configs/default_config.yml @@ -99,6 +99,9 @@ dt_rad: idealized_clouds: help: "Use idealized clouds in radiation model [`false` (default), `true`]" value: false +prescribed_clouds_in_radiation: + help: "Use prescribed clouds in radiation model [`false` (default), `true`]" + value: false insolation: help: "Insolation used in radiation model [`idealized` (default), `timevarying`, `rcemipii`]" value: "idealized" diff --git a/config/model_configs/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.yml b/config/model_configs/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.yml index 0c1938aa5b0..d2440021169 100644 --- a/config/model_configs/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.yml +++ b/config/model_configs/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.yml @@ -3,7 +3,7 @@ z_elem: 31 dz_bottom: 50.0 rayleigh_sponge: true dt: "400secs" -t_end: "1days" +t_end: "1hours" dt_save_state_to_disk: "24hours" vert_diff: "FriersonDiffusion" implicit_diffusion: true @@ -12,6 +12,7 @@ moist: "equil" precip_model: "1M" rad: "allskywithclear" aerosol_radiation: true +prescribed_clouds_in_radiation: true insolation: "timevarying" non_orographic_gravity_wave: true orographic_gravity_wave: "gfdl_restart" diff --git a/examples/Manifest.toml b/examples/Manifest.toml index d06017817eb..a9fadce4b54 100644 --- a/examples/Manifest.toml +++ b/examples/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.10.5" manifest_format = "2.0" -project_hash = "4a69d8d0d873926fbb39490c1e1d573fbc26434e" +project_hash = "0650226b22aae022a4fd4dd08a3323bee9fb506d" [[deps.ADTypes]] git-tree-sha1 = "eea5d80188827b35333801ef97a40c2ed653b081" @@ -411,9 +411,11 @@ version = "0.7.38" [[deps.ClimaUtilities]] deps = ["Artifacts", "Dates"] -git-tree-sha1 = "24bd6d5066404af09215c372d0ffea56ed849206" +git-tree-sha1 = "5ea56b287b36d24a3df2d0e704cea2028ad06b5d" +repo-rev = "main" +repo-url = "https://github.com/CliMA/ClimaUtilities.jl.git" uuid = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513" -version = "0.1.15" +version = "0.1.17" weakdeps = ["Adapt", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Interpolations", "NCDatasets"] [deps.ClimaUtilities.extensions] diff --git a/src/cache/cache.jl b/src/cache/cache.jl index 08a23b67a19..54c0513609f 100644 --- a/src/cache/cache.jl +++ b/src/cache/cache.jl @@ -182,7 +182,7 @@ function build_cache(Y, atmos, params, surface_setup, sim_info, aerosol_names) radiation_args = atmos.radiation_mode isa RRTMGPI.AbstractRRTMGPMode ? - (params, atmos.ozone, aerosol_names, atmos.insolation) : () + (start_date, params, atmos.ozone, aerosol_names, atmos.insolation) : () hyperdiff = hyperdiffusion_cache(Y, atmos) rayleigh_sponge = rayleigh_sponge_cache(Y, atmos) diff --git a/src/callbacks/callbacks.jl b/src/callbacks/callbacks.jl index cc30ceab06c..c563c4ed595 100644 --- a/src/callbacks/callbacks.jl +++ b/src/callbacks/callbacks.jl @@ -77,6 +77,12 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator) evaluate!(field, tv, t) end end + if :prescribed_clouds_field in propertynames(p.radiation) + for (key, tv) in pairs(p.radiation.prescribed_cloud_timevaryinginputs) + field = getproperty(p.radiation.prescribed_clouds_field, key) + evaluate!(field, tv, t) + end + end FT = Spaces.undertype(axes(Y.c)) thermo_params = CAP.thermodynamics_params(params) @@ -157,13 +163,31 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator) ) # RRTMGP needs lwp and iwp in g/m^2 kg_to_g_factor = 1000 - @. ᶜlwp = - kg_to_g_factor * Y.c.ρ * cloud_diagnostics_tuple.q_liq * ᶜΔz / - max(cloud_diagnostics_tuple.cf, eps(FT)) - @. ᶜiwp = - kg_to_g_factor * Y.c.ρ * cloud_diagnostics_tuple.q_ice * ᶜΔz / - max(cloud_diagnostics_tuple.cf, eps(FT)) - @. ᶜfrac = cloud_diagnostics_tuple.cf + if radiation_mode.prescribed_clouds + @. ᶜlwp = + kg_to_g_factor * + Y.c.ρ * + p.radiation.prescribed_clouds_field.clwc * + ᶜΔz / max(p.radiation.prescribed_clouds_field.cc, eps(FT)) + @. ᶜiwp = + kg_to_g_factor * + Y.c.ρ * + p.radiation.prescribed_clouds_field.ciwc * + ᶜΔz / max(p.radiation.prescribed_clouds_field.cc, eps(FT)) + @. ᶜfrac = p.radiation.prescribed_clouds_field.cc + else + @. ᶜlwp = + kg_to_g_factor * + Y.c.ρ * + cloud_diagnostics_tuple.q_liq * + ᶜΔz / max(cloud_diagnostics_tuple.cf, eps(FT)) + @. ᶜiwp = + kg_to_g_factor * + Y.c.ρ * + cloud_diagnostics_tuple.q_ice * + ᶜΔz / max(cloud_diagnostics_tuple.cf, eps(FT)) + @. ᶜfrac = cloud_diagnostics_tuple.cf + end end end diff --git a/src/parameterized_tendencies/radiation/RRTMGPInterface.jl b/src/parameterized_tendencies/radiation/RRTMGPInterface.jl index 18c9009cf3d..cb59635818e 100644 --- a/src/parameterized_tendencies/radiation/RRTMGPInterface.jl +++ b/src/parameterized_tendencies/radiation/RRTMGPInterface.jl @@ -24,6 +24,7 @@ end struct AllSkyRadiation <: AbstractRRTMGPMode idealized_h2o::Bool idealized_clouds::Bool + prescribed_clouds::Bool add_isothermal_boundary_layer::Bool aerosol_radiation::Bool "Reset the RNG seed before calling RRTGMP to a known value (the timestep number). When modeling cloud optics, RRTGMP uses a random number generator. Resetting the seed every time RRTGMP is called to a deterministic value ensures that the simulation is fully reproducible and can be restarted in a reproducible way. Disable this option when running production runs." @@ -32,6 +33,7 @@ end struct AllSkyRadiationWithClearSkyDiagnostics <: AbstractRRTMGPMode idealized_h2o::Bool idealized_clouds::Bool + prescribed_clouds::Bool add_isothermal_boundary_layer::Bool aerosol_radiation::Bool "Reset the RNG seed before calling RRTGMP to a known value (the timestep number). When modeling cloud optics, RRTGMP uses a random number generator. Resetting the seed every time RRTGMP is called to a deterministic value ensures that the simulation is fully reproducible and can be restarted in a reproducible way. Disable this option when running production runs." diff --git a/src/parameterized_tendencies/radiation/radiation.jl b/src/parameterized_tendencies/radiation/radiation.jl index daf911e3598..bef49683b9f 100644 --- a/src/parameterized_tendencies/radiation/radiation.jl +++ b/src/parameterized_tendencies/radiation/radiation.jl @@ -10,11 +10,14 @@ import .Parameters as CAP import RRTMGP import .RRTMGPInterface as RRTMGPI -import Dates: Year +import Dates: Year, Date import ClimaUtilities.TimeVaryingInputs: - TimeVaryingInput, LinearPeriodFillingInterpolation + TimeVaryingInput, + PeriodicCalendar, + LinearPeriodFillingInterpolation, + LinearInterpolation -import Interpolations +import Interpolations as Intp using Statistics: mean radiation_model_cache(Y, atmos::AtmosModel, args...) = @@ -86,6 +89,7 @@ end function radiation_model_cache( Y, radiation_mode::RRTMGPI.AbstractRRTMGPMode, + start_date, params, ozone, aerosol_names, @@ -257,10 +261,48 @@ function radiation_model_cache( kwargs..., ) end + if radiation_mode.prescribed_clouds + cloud_cache = get_cloud_cache(Y, start_date) + else + cloud_cache = (;) + end return merge( (; rrtmgp_model, ᶠradiation_flux = similar(Y.f, Geometry.WVector{FT})), insolation_cache(insolation_mode, Y), + cloud_cache, + ) +end + +function get_cloud_cache(Y, start_date) + target_space = axes(Y.c) + prescribed_cloud_names = ("cc", "clwc", "ciwc") + prescribed_cloud_names_as_symbols = Symbol.(prescribed_cloud_names) + extrapolation_bc = (Intp.Periodic(), Intp.Flat(), Intp.Flat()) + timevaryinginputs = [ + TimeVaryingInput( + joinpath( + @clima_artifact("era5_cloud", ClimaComms.context(Y.c)), + "era5_cloud.nc", + ), + name, + target_space; + reference_date = start_date, + regridder_type = :InterpolationsRegridder, + regridder_kwargs = (; extrapolation_bc), + method = LinearInterpolation(PeriodicCalendar(Year(1), Date(2010))), + ) for name in prescribed_cloud_names + ] + + prescribed_clouds_field = similar( + Y.c, + NamedTuple{ + prescribed_cloud_names_as_symbols, + NTuple{length(prescribed_cloud_names_as_symbols), eltype(Y.c.ρ)}, + }, ) + prescribed_cloud_timevaryinginputs = + (; zip(prescribed_cloud_names_as_symbols, timevaryinginputs)...) + return (; prescribed_clouds_field, prescribed_cloud_timevaryinginputs) end insolation_cache(_, _) = (;) diff --git a/src/solver/model_getters.jl b/src/solver/model_getters.jl index a20b3e8469e..1e1a0585e36 100644 --- a/src/solver/model_getters.jl +++ b/src/solver/model_getters.jl @@ -221,6 +221,9 @@ function get_radiation_mode(parsed_args, ::Type{FT}) where {FT} @assert idealized_h2o in (true, false) idealized_clouds = parsed_args["idealized_clouds"] @assert idealized_clouds in (true, false) + prescribed_clouds = parsed_args["prescribed_clouds_in_radiation"] + @assert prescribed_clouds in (true, false) + @assert !(idealized_clouds && prescribed_clouds) add_isothermal_boundary_layer = parsed_args["add_isothermal_boundary_layer"] @assert add_isothermal_boundary_layer in (true, false) aerosol_radiation = parsed_args["aerosol_radiation"] @@ -254,6 +257,7 @@ function get_radiation_mode(parsed_args, ::Type{FT}) where {FT} RRTMGPI.AllSkyRadiation( idealized_h2o, idealized_clouds, + prescribed_clouds, add_isothermal_boundary_layer, aerosol_radiation, reset_rng_seed, @@ -262,6 +266,7 @@ function get_radiation_mode(parsed_args, ::Type{FT}) where {FT} RRTMGPI.AllSkyRadiationWithClearSkyDiagnostics( idealized_h2o, idealized_clouds, + prescribed_clouds, add_isothermal_boundary_layer, aerosol_radiation, reset_rng_seed,