Skip to content

Commit

Permalink
Rename float_type_cs -> float_type
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriabarra committed Jan 17, 2023
1 parent 61d2f4c commit a467da5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
32 changes: 16 additions & 16 deletions experiments/AMIP/moist_mpi_earth/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ include("mpi/mpi_init.jl") # setup MPI context for distributed runs #hide
#=
## Overview
AMIP is a standard experimental protocol of the Program for Climate Model Diagnosis & Intercomparison (PCMDI).
AMIP is a standard experimental protocol of the Program for Climate Model Diagnosis & Intercomparison (PCMDI).
It is used as a model benchmark for the atmospheric and land model components, while sea-surface temperatures (SST) and sea-ice concentration (SIC)
are prescribed using time-interpolations between monthly observed data. We use standard data files with original sources:
- SST and SIC: https://gdex.ucar.edu/dataset/158_asphilli.html
- SST and SIC: https://gdex.ucar.edu/dataset/158_asphilli.html
- land-sea mask: https://www.ncl.ucar.edu/Applications/Data/#cdf
For more information, see the PCMDI's specifications for [AMIP I](https://pcmdi.github.io/mips/amip/) and [AMIP II](https://pcmdi.github.io/mips/amip2/).
For more information, see the PCMDI's specifications for [AMIP I](https://pcmdi.github.io/mips/amip/) and [AMIP II](https://pcmdi.github.io/mips/amip2/).
This driver contains two modes. The full `AMIP` mode and a `SlabPlanet` (all surfaces are thermal slabs) mode. Since `AMIP` is not a closed system, the
`SlabPlanet` mode is useful for checking conservation properties of the coupling.
This driver contains two modes. The full `AMIP` mode and a `SlabPlanet` (all surfaces are thermal slabs) mode. Since `AMIP` is not a closed system, the
`SlabPlanet` mode is useful for checking conservation properties of the coupling.
=#

Expand All @@ -41,7 +41,7 @@ you can run directly from the Julia REPL. The latter is recommended for debuggin
with threading enabled:
```julia
julia --project --threads 8
```
```
=#

#=
Expand Down Expand Up @@ -94,7 +94,7 @@ import ClimaCoupler
import ClimaCoupler.Regridder: land_sea_mask, update_masks!, combine_surfaces!, dummmy_remap!, binary_mask
import ClimaCoupler.ConservationChecker:
EnergyConservationCheck, WaterConservationCheck, check_conservation!, plot_global_conservation
import ClimaCoupler.Utilities: CoupledSimulation, float_type_cs, swap_space!
import ClimaCoupler.Utilities: CoupledSimulation, float_type, swap_space!
import ClimaCoupler.BCReader:
bcfile_info_init, float_type_bcf, update_midmonth_data!, next_date_in_file, interpolate_midmonth_to_daily
import ClimaCoupler.TimeManager: current_date, datetime_to_strdate, trigger_callback, Monthly, EveryTimestep
Expand Down Expand Up @@ -136,9 +136,9 @@ include("atmos/atmos_init.jl")
atmos_sim = atmos_init(FT, Y, integrator, params = params);

#=
We use a common `Space` for all global surfaces. This enables the MPI processes to operate on the same columns in both
the atmospheric and surface components, so exchanges are parallelized. Note this is only possible when the
atmosphere and surface are of the same horizontal resolution.
We use a common `Space` for all global surfaces. This enables the MPI processes to operate on the same columns in both
the atmospheric and surface components, so exchanges are parallelized. Note this is only possible when the
atmosphere and surface are of the same horizontal resolution.
=#
## init a 2D bounary space at the surface
boundary_space = atmos_sim.domain.face_space.horizontal_space
Expand All @@ -163,9 +163,9 @@ land_sim =
#=
### Ocean and Sea Ice
In the `AMIP` mode, all ocean properties are prescribed from a file, while sea-ice temperatures are calculated using observed
SIC and assuming a 2m thickness of the ice.
SIC and assuming a 2m thickness of the ice.
In the `SlabPlanet` mode, all ocean and sea ice are dynamical models, namely thermal slabs, with different parameters.
In the `SlabPlanet` mode, all ocean and sea ice are dynamical models, namely thermal slabs, with different parameters.
=#

@info mode_name
Expand Down Expand Up @@ -241,7 +241,7 @@ end
#=
## Coupler Initialization
The coupler needs to contain exchange information, manage the calendar and be able to access all component models. It can also optionally
save online diagnostics. These are all initialized here and saved in a global `CouplerSimulation` struct, `cs`.
save online diagnostics. These are all initialized here and saved in a global `CouplerSimulation` struct, `cs`.
=#

## coupler exchange fields
Expand Down Expand Up @@ -313,7 +313,7 @@ cs = CoupledSimulation{FT}(


#=
## Initial States Exchange
## Initial States Exchange
=#
## share states between models
include("./push_pull.jl")
Expand Down Expand Up @@ -412,8 +412,8 @@ end
solve_coupler!(cs);

#=
## Postprocessing
Currently all postprocessing is performed using the root process only.
## Postprocessing
Currently all postprocessing is performed using the root process only.
=#

if ClimaComms.iamroot(comms_ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct CouplerSimulation{FT, C, S, D, B, P}
end

CouplerSimulation{FT}(args...) where {FT} = CouplerSimulation{FT, typeof.(args[1:5])...}(args...)
float_type_cs(::CouplerSimulation{FT}) where {FT} = FT
float_type(::CouplerSimulation{FT}) where {FT} = FT

function swap_space!(field, new_space)
field_out = zeros(new_space)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"""
get_var(cs::CouplerSimulation, ::Symbol)
Defines variable extraction from the coupler simulation.
Defines variable extraction from the coupler simulation.
"""
get_var(cs, ::Val{:T}) = air_temperature(cs)

get_var(cs, ::Val{:u}) = ClimaCore.Geometry.UVVector.(cs.model_sims.atmos_sim.integrator.u.c.uₕ).components.data.:1

get_var(cs, ::Val{:q_tot}) =
cs.model_sims.atmos_sim.integrator.u.c.ρq_tot ./ cs.model_sims.atmos_sim.integrator.u.c.ρ .* float_type_cs(cs)(1000)
cs.model_sims.atmos_sim.integrator.u.c.ρq_tot ./ cs.model_sims.atmos_sim.integrator.u.c.ρ .* float_type(cs)(1000)

get_var(cs, ::Val{:toa}) = swap_space!(toa_fluxes(cs), cs.boundary_space)

Expand Down
12 changes: 6 additions & 6 deletions experiments/AMIP/moist_mpi_earth/push_pull.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
atmos_push!(cs)
updates F_A, F_R, P_liq, and F_E in place based on values used in the atmos_sim for the current step.
"""
function atmos_push!(cs)
Expand All @@ -21,7 +21,7 @@ and hydrostatic balance assumptions. The land model does not compute the surface
a reasonable stand-in.
"""
function land_pull!(cs)
FT = float_type_cs(cs)
FT = float_type(cs)
land_sim = cs.model_sims.land_sim
csf = cs.fields
land_mask = cs.surface_masks.land
Expand Down Expand Up @@ -59,7 +59,7 @@ In the current version, the sea ice has a prescribed thickness, and we assume th
sublimating. That contribution has been zeroed out in the atmos fluxes.
"""
function ice_pull!(cs)
FT = float_type_cs(cs)
FT = float_type(cs)
ice_sim = cs.model_sims.ice_sim
csf = cs.fields
ice_mask = cs.surface_masks.ice
Expand All @@ -71,7 +71,7 @@ end

"""
atmos_pull!(cs)
Creates the surface fields for temperature, roughness length, albedo, and specific humidity; computes
turbulent surface fluxes; updates the atmosphere boundary flux cache variables in place; updates the
RRTMGP cache variables in place.
Expand Down Expand Up @@ -105,7 +105,7 @@ function atmos_pull!(cs)

update_masks!(cs)

# combine models' surfaces onlo one coupler field
# combine models' surfaces onlo one coupler field
combined_field = zeros(boundary_space)

# surface temperature
Expand All @@ -120,7 +120,7 @@ function atmos_pull!(cs)
combine_surfaces!(combined_field, cs.surface_masks, (; land = z0b_land, ocean = z0b_ocean, ice = z0b_ice))
dummmy_remap!(z0b_cpl, combined_field)

# calculate atmospheric surface density
# calculate atmospheric surface density
set_ρ_sfc!(ρ_sfc_cpl, T_sfc_cpl, atmos_sim.integrator)

# surface specific humidity
Expand Down
14 changes: 7 additions & 7 deletions experiments/AMIP/moist_mpi_earth/user_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Atmos diagnostics

"""
get_var(cs::CoupledSimulation, ::Val{:T})
get_var(cs::CoupledSimulation, ::Val{:T})
Air temperature (K).
"""
Expand All @@ -15,23 +15,23 @@ function get_var(cs::CoupledSimulation, ::Val{:T})
end

"""
get_var(cs::CoupledSimulation, ::Val{:u})
get_var(cs::CoupledSimulation, ::Val{:u})
Zonal wind (m s⁻¹).
"""
get_var(cs::CoupledSimulation, ::Val{:u}) =
ClimaCore.Geometry.UVVector.(cs.model_sims.atmos_sim.integrator.u.c.uₕ).components.data.:1

"""
get_var(cs::CoupledSimulation, ::Val{:q_tot})
get_var(cs::CoupledSimulation, ::Val{:q_tot})
Total specific humidity (kg kg⁻¹).
"""
get_var(cs::CoupledSimulation, ::Val{:q_tot}) =
cs.model_sims.atmos_sim.integrator.u.c.ρq_tot ./ cs.model_sims.atmos_sim.integrator.u.c.ρ .* float_type_cs(cs)(1000)
cs.model_sims.atmos_sim.integrator.u.c.ρq_tot ./ cs.model_sims.atmos_sim.integrator.u.c.ρ .* float_type(cs)(1000)

"""
get_var(cs::CoupledSimulation, ::Val{:toa})
get_var(cs::CoupledSimulation, ::Val{:toa})
Top of the atmosphere radiation fluxes (W m⁻²).
"""
Expand Down Expand Up @@ -64,7 +64,7 @@ function get_var(cs::CoupledSimulation, ::Val{:toa})
end

"""
get_var(cs::CoupledSimulation, ::Val{:precipitation})
get_var(cs::CoupledSimulation, ::Val{:precipitation})
Precipitation (m m⁻²).
"""
Expand All @@ -77,7 +77,7 @@ get_var(cs::CoupledSimulation, ::Val{:precipitation}) =

# coupler diagnotics
"""
get_var(cs::CoupledSimulation, ::Val{:T_sfc})
get_var(cs::CoupledSimulation, ::Val{:T_sfc})
Combined surface temperature (K).
"""
Expand Down
6 changes: 3 additions & 3 deletions src/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ struct CoupledSimulation{
FV,
P,
E,
TSI,
TI <: Int,
DTI <: Int,
TSI <: Tuple{Real, Real},
TI <: Real,
DTI <: Real,
NTSM <: NamedTuple,
NTMS <: NamedTuple,
NTM <: NamedTuple,
Expand Down

0 comments on commit a467da5

Please sign in to comment.