Skip to content

Commit

Permalink
Merge pull request #184 from pdziekan/help_fix
Browse files Browse the repository at this point in the history
add default values for options to reenable help message for microphysics
  • Loading branch information
pdziekan authored Jan 21, 2025
2 parents 29ac1f0 + 993ebe3 commit f40f096
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/opts/opts_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ po::options_description opts_main("General options");

void handle_opts(
po::options_description &opts_micro,
po::variables_map &vm
po::variables_map &vm,
const bool check_help
)
{
opts_main.add(opts_micro);
po::store(po::command_line_parser(ac, av).options(opts_main).allow_unregistered().run(), vm); // ignores unknown, could be exchanged with a config file parser

// hendling the "help" option
if (vm.count("help"))
if (check_help && vm.count("help"))
{
std::cout << opts_main;
exit(EXIT_SUCCESS);
Expand Down
3 changes: 2 additions & 1 deletion src/opts/opts_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern po::options_description opts_main;

void handle_opts(
po::options_description &opts_micro,
po::variables_map &vm
po::variables_map &vm,
const bool check_help=true
);

1 change: 1 addition & 0 deletions src/opts/opts_lgrngn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>

#include "../detail/outmom.hpp"
#include "../detail/subs_t.hpp"
#include <UWLCM/output_bins.hpp>

// simulation and output parameters for micro=lgrngn
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/slvr_piggy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class slvr_piggy<
opts.add_options()
("prs_tol", po::value<setup::real_t>()->default_value(1e-6) , "pressure solver tolerance"); // not really related to piggybacking, but convenient to put here as it is the first solver to inherit from libmpdata++
po::variables_map vm;
handle_opts(opts, vm);
handle_opts(opts, vm, false);
save_vel_flag = vm["save_vel"].as<bool>();
this->prs_tol = vm["prs_tol"].as<setup::real_t>();
}
Expand Down
20 changes: 9 additions & 11 deletions src/uwlcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "detail/ct_params.hpp"

#if !defined(UWLCM_DISABLE_2D_LGRNGN) || !defined(UWLCM_DISABLE_3D_LGRNGN)
// #include "opts/opts_lgrngn.hpp"
#include "solvers/slvr_lgrngn.hpp"
#include "solvers/lgrngn/diag_lgrngn.hpp"
#include "solvers/lgrngn/hook_ante_delayed_step_lgrngn.hpp"
Expand All @@ -29,14 +28,12 @@
#endif

#if !defined(UWLCM_DISABLE_2D_BLK_1M) || !defined(UWLCM_DISABLE_3D_BLK_1M)
// #include "opts/opts_blk_1m.hpp"
#include "solvers/slvr_blk_1m.hpp"
#include "solvers/blk_1m/calc_forces_blk_1m_common.hpp"
#include "solvers/blk_1m/update_rhs_blk_1m_common.hpp"
#endif

#if !defined(UWLCM_DISABLE_2D_BLK_2M) || !defined(UWLCM_DISABLE_3D_BLK_2M)
// #include "opts/opts_blk_2m.hpp"
#include "solvers/slvr_blk_2m.hpp"
#include "solvers/blk_2m/calc_forces_blk_2m_common.hpp"
#include "solvers/blk_2m/update_rhs_blk_2m_common.hpp"
Expand All @@ -59,22 +56,23 @@ int main(int argc, char** argv)
av = argv;

{
// note: all options should have default values here to make "--micro=? --help" work
// note: all options except micro should have default values here to make "--micro=? --help" work
opts_main.add_options()
//("micro", po::value<std::string>()->default_value("blk_1m"), "one of: blk_1m, blk_2m, lgrngn, none")
("micro", po::value<std::string>()->required(), "one of: blk_1m, blk_2m, lgrngn, none")
("case", po::value<std::string>()->required(), "one of: dry_thermal, moist_thermal, dycoms_rf01, dycoms_rf02, cumulus_congestus_icmw20, cumulus_congestus_icmw24, rico11, dry_pbl")
("case", po::value<std::string>()->default_value("moist_thermal"), "one of: dry_thermal, moist_thermal, dycoms_rf01, dycoms_rf02, cumulus_congestus_icmw20, cumulus_congestus_icmw24, rico11, dry_pbl")
("X", po::value<setup::real_t>()->default_value(-1) , "domain size in X [m] (set negative for case default)")
("Y", po::value<setup::real_t>()->default_value(-1) , "domain size in Y [m] (set negative for case default)")
("Z", po::value<setup::real_t>()->default_value(-1) , "domain size in Z [m] (set negative for case default)")
("nx", po::value<int>()->required() , "grid cell count in horizontal")
("nx", po::value<int>()->default_value(1) , "grid cell count in horizontal")
("ny", po::value<int>()->default_value(0) , "grid cell count in horizontal, 0 for 2D simulation")
("nz", po::value<int>()->required() , "grid cell count in vertical")
("nt", po::value<int>()->required() , "timestep count")
("nz", po::value<int>()->default_value(1) , "grid cell count in vertical")
("nt", po::value<int>()->default_value(0) , "timestep count")
("rng_seed", po::value<int>()->default_value(0) , "rng seed for randomness post initialization (currently only in Lagrangian microphysics), 0 for random")
("rng_seed_init", po::value<int>()->default_value(0) , "rng seed for initial conditions (perturbations of th and rv and initialization of Lagrangian microphysics), 0 for rng_seed_init=rng_seed")
("dt", po::value<setup::real_t>()->required() , "timestep length [s]")
("outdir", po::value<std::string>()->required(), "output directory name (netCDF-compatible HDF5)")
("outfreq", po::value<int>()->required(), "output rate (timestep interval)")
("dt", po::value<setup::real_t>()->default_value(1) , "timestep length [s]")
("outdir", po::value<std::string>()->default_value(""), "output directory name (netCDF-compatible HDF5)")
("outfreq", po::value<int>()->default_value(0), "output rate (timestep interval)")
("outstart", po::value<int>()->default_value(0), "output starts after this many timesteps")
("outwindow", po::value<int>()->default_value(1), "number of consecutive timesteps output is done, starts at outfreq (doesnt affect output of droplet spectra from lagrangian microphysics)")
("spinup", po::value<int>()->default_value(0) , "number of initial timesteps during which rain formation is to be turned off")
Expand Down

0 comments on commit f40f096

Please sign in to comment.