From 524cef1fdc3f03e9f597e2c5306a423e293a1402 Mon Sep 17 00:00:00 2001 From: Mikhail Mints Date: Wed, 21 Jun 2023 14:25:00 -0700 Subject: [PATCH] Changed the arg_type of command-line arguments for KiD_driver from Real to Float64, added option to specify float type. --- .buildkite/pipeline.yml | 4 +- .github/workflows/ci.yml | 2 +- test/experiments/KiD_driver/KiD_driver.jl | 14 ++--- .../KiD_driver/parse_commandline.jl | 52 ++++++++++--------- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0f6f1fd7..4efa6dd7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -76,8 +76,8 @@ steps: command: "julia --color=yes --project=test test/experiments/KiD_driver/KiD_driver.jl --moisture_choice=NonEquilibriumMoisture --prognostic_vars=RhodTQ --precipitation_choice=Precipitation1M" artifact_paths: "test/experiments/KiD_driver/Output_NonEquilibriumMoisture_RhodTQ_Precipitation1M_CliMA_1M/figures/*" - - label: ":crystal_ball: Experiments: equil (fixed rhod and T) + KK2000 " - command: "julia --color=yes --project=test test/experiments/KiD_driver/KiD_driver.jl --moisture_choice=EquilibriumMoisture --prognostic_vars=RhodTQ --precipitation_choice=Precipitation1M --rain_formation_scheme_choice KK2000 --prescribed_Nd 1e8" + - label: ":crystal_ball: Experiments: equil (fixed rhod and T) + KK2000 + Float32 " + command: "julia --color=yes --project=test test/experiments/KiD_driver/KiD_driver.jl --FLOAT_TYPE=Float32 --moisture_choice=EquilibriumMoisture --prognostic_vars=RhodTQ --precipitation_choice=Precipitation1M --rain_formation_scheme_choice KK2000 --prescribed_Nd 1e8" artifact_paths: "test/experiments/KiD_driver/Output_EquilibriumMoisture_RhodTQ_Precipitation1M_KK2000/figures/*" - label: ":crystal_ball: Experiments: equil (fixed rhod and T) + B1994 " diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1cce55a..8b1784d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: version: - - '1.8.1' + - '1.8.5' os: - ubuntu-latest - macOS-latest diff --git a/test/experiments/KiD_driver/KiD_driver.jl b/test/experiments/KiD_driver/KiD_driver.jl index 06ed4ff4..29cc66c9 100644 --- a/test/experiments/KiD_driver/KiD_driver.jl +++ b/test/experiments/KiD_driver/KiD_driver.jl @@ -28,12 +28,12 @@ const KID = Kinematic1D const AP = ArgParse const CMT = CloudMicrophysics.CommonTypes -const FT = Float64 - # Get the parameter values for the simulation include("parse_commandline.jl") opts = parse_commandline() +const FT = opts["FLOAT_TYPE"] == "Float64" ? Float64 : Float32 + # Equations to solve for mositure and precipitation variables moisture_choice = opts["moisture_choice"] prognostics_choice = opts["prognostic_vars"] @@ -83,7 +83,7 @@ end TS = KID.TimeStepping(FT(opts["dt"]), FT(opts["dt_output"]), FT(opts["t_end"])) # Create the coordinates -space, face_space = KID.make_function_space(FT, opts["z_min"], opts["z_max"], opts["n_elem"]) +space, face_space = KID.make_function_space(FT, FT(opts["z_min"]), FT(opts["z_max"]), opts["n_elem"]) coord = CC.Fields.coordinate_field(space) face_coord = CC.Fields.coordinate_field(face_space) @@ -106,9 +106,9 @@ params = create_parameter_set( path, toml_dict, FT, - opts["w1"], - opts["t1"], - opts["p0"], + FT(opts["w1"]), + FT(opts["t1"]), + FT(opts["p0"]), Int(opts["precip_sources"]), Int(opts["precip_sinks"]), Int(opts["qtot_flux_correction"]), @@ -141,7 +141,7 @@ callbacks = ODE.CallbackSet(callback_io) ode_rhs! = KID.make_rhs_function(moisture, precip) # Solve the ODE operator -problem = ODE.ODEProblem(ode_rhs!, Y, (opts["t_ini"], opts["t_end"]), aux) +problem = ODE.ODEProblem(ode_rhs!, Y, (FT(opts["t_ini"]), FT(opts["t_end"])), aux) solver = ODE.solve( problem, ODE.SSPRK33(), diff --git a/test/experiments/KiD_driver/parse_commandline.jl b/test/experiments/KiD_driver/parse_commandline.jl index 5acdcfcc..03a1d2b3 100644 --- a/test/experiments/KiD_driver/parse_commandline.jl +++ b/test/experiments/KiD_driver/parse_commandline.jl @@ -6,6 +6,10 @@ function parse_commandline() s = AP.ArgParseSettings() AP.@add_arg_table! s begin + "--FLOAT_TYPE" + help = "Float type. Can be set to Float64 or Float32" + arg_type = String + default = "Float64" "--moisture_choice" help = "Mositure model choice: EquilibriumMoisture, NonEquilibriumMoisture" arg_type = String @@ -45,56 +49,56 @@ function parse_commandline() default = false "--z_min" help = "Bottom of the computational domain [m]" - arg_type = Real - default = 0.0 + arg_type = Float64 + default = Float64(0) "--z_max" help = "Top of the computational domain [m]" - arg_type = Real - default = 2000.0 + arg_type = Float64 + default = Float64(2000) "--n_elem" help = "Number of computational elements" arg_type = Int default = 256 "--dt" help = "Simulation time step [s]" - arg_type = Real - default = 1.0 + arg_type = Float64 + default = Float64(1) "--dt_output" help = "Output time step [s]" - arg_type = Real - default = 30.0 + arg_type = Float64 + default = Float64(30) "--t_ini" help = "Time at the beginning of the simulation [s]" - arg_type = Real - default = 0.0 + arg_type = Float64 + default = Float64(0) "--t_end" help = "Time at the end of the simulation [s]" - arg_type = Real - default = 3600.0 + arg_type = Float64 + default = Float64(3600) "--w1" help = "Maximum prescribed updraft momentum flux [m/s * kg/m3]" - arg_type = Real - default = 2.0 + arg_type = Float64 + default = Float64(2) "--t1" help = "Oscillation time of the prescribed momentum flux [s]" - arg_type = Real - default = 600.0 + arg_type = Float64 + default = Float64(600) "--p0" help = "Pressure at the surface [pa]" - arg_type = Real - default = 100000.0 + arg_type = Float64 + default = Float64(100000) "--r_dry" help = "aerosol distribution mean radius for aerosol activation calculations in 2M schemes [m]" - arg_type = Real - default = 0.04 * 1e-6 + arg_type = Float64 + default = Float64(0.04 * 1e-6) "--std_dry" help = "aerosol distribution standard deviation for aerosol activation calucaulations in 2M schemes" - arg_type = Real - default = 1.4 + arg_type = Float64 + default = Float64(1.4) "--kappa" help = "hygroscopicity of aerosols for aerosol activation calucaulations in 2M schemes" - arg_type = Real - default = 0.9 + arg_type = Float64 + default = Float64(0.9) end return AP.parse_args(s)