Skip to content

Commit

Permalink
Rework of the CLI argument parser and add the option to define inputs…
Browse files Browse the repository at this point in the history
… through a JSON file (#93)

* Add first parser attempt

* Use argparser

* Convert all execs to use new argparser

* Add json option and example files for all parameters

* Include json in dependencies

* Add json to readme

* Bump version

* Bump version

* Fix missing json check and add install to workflows

* Run ubuntu on 22.04

* Add unit tests and documentation for parser

* Fix unit test

* Use template function to convert value in types

* Fix windows uint problem and get catch2 through conan

* Unify spelling

* Unify spelling of arguments

* Update cpp-linter.yml

* Update cpp-linter.yml

* apply cmake-format

* Automated commit of cmake-format changes.

* logger docu

* Apply suggestions from code review

Co-authored-by: Lisa Biermann <[email protected]>

* Remove duplicate cmakedefs

* Fix missing install on mac

* Only print help output once

* Update CMakeLists.txt

Co-authored-by: Lisa Biermann <[email protected]>

* Fix openmp missing on

* opt openmp

* link to openmp target

Co-authored-by: phbasler <[email protected]>
Co-authored-by: Lisa Biermann <[email protected]>
  • Loading branch information
3 people authored Nov 5, 2022
1 parent 2822628 commit f24ba97
Show file tree
Hide file tree
Showing 39 changed files with 1,978 additions and 1,184 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
persist-credentials: false
- name: installPackages
run: brew install eigen && brew install gsl && brew install nlopt && brew install boost && brew install libomp
run: brew install eigen && brew install gsl && brew install nlopt && brew install boost && brew install libomp && brew install nlohmann-json
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: "!contains(github.event.head_commit.message, 'skip-ci')"

steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name : installPackages
run : sudo apt-get install --no-install-recommends --yes libgsl-dev libeigen3-dev libnlopt-dev libnlopt-cxx-dev libboost-all-dev
run : sudo apt-get install --no-install-recommends --yes libgsl-dev libeigen3-dev libnlopt-dev libnlopt-cxx-dev libboost-all-dev nlohmann-json3-dev
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: file
style: "file"
tidy-checks: '-*'
version: '14'

- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
persist-credentials: false
- name : installPackages
run : brew install eigen gsl nlopt boost libomp
run : brew install eigen gsl nlopt boost libomp nlohmann-json
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand All @@ -42,7 +42,7 @@ jobs:
with:
persist-credentials: false
- name : installPackages
run : brew install eigen gsl boost libomp
run : brew install eigen gsl boost libomp nlohmann-json
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.13)
project(
BSMPT
VERSION 2.4.0
VERSION 2.5.0
LANGUAGES C CXX
DESCRIPTION
"BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models"
Expand Down Expand Up @@ -37,6 +37,10 @@ if(EnableCoverage)
set(BSMPT_USE_VECTORIZATION OFF)
endif()

if(BSMPT_IS_TOPLEVEL)
include(CTest)
endif()

# -------------------------------- setup cmake --------------------------------
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) # use <packagename>_ROOT as search path
Expand All @@ -62,6 +66,7 @@ find_package(PkgConfig)
find_package(Eigen3 3.3.0 REQUIRED)
find_package(Boost 1.66)
find_package(GSL 2.1 REQUIRED)
find_package(nlohmann_json 3.7.3)

find_package(Threads REQUIRED)

Expand All @@ -83,6 +88,11 @@ if(Boost_FOUND)
endif()
endif()

if(nlohmann_json_FOUND)
set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs}
"${nlohmann_json}/*")
endif()

set(EXPORT_CMAES FALSE)
include(FetchContent)
if(UseLibCMAES AND NOT WIN32)
Expand Down Expand Up @@ -211,9 +221,6 @@ endif(BSMPT_IS_TOPLEVEL)

# -------------------- Testing
# ---------------------------------------------------
if(BSMPT_IS_TOPLEVEL)
include(CTest)
endif()

if(BSMPT_IS_TOPLEVEL AND BUILD_TESTING)
add_subdirectory(tests)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas M
SPDX-License-Identifier: GPL-3.0-or-later
-->

Program: BSMPT version 2.4.0
Program: BSMPT version 2.5.0

Released by: Philipp Basler and Lisa Biermann and Margarete Mühlleitner and Jonas Müller

Expand Down Expand Up @@ -137,6 +137,9 @@ Also contact us if you have a custom model for BSMPT v1.x and you have trouble c

## Executables
BSMPT provides multiple executables. Here we give a quick overview of them. For every executable you can call them with the `--help` option to get an overview of possible input parameters.

Additionally, every executable has the option to set the `--json=/path/to/your/file.json` which contains a json string with the parameters you can set through the CLI. This can be useful if you want to store the parameters you used for a given call. Please beware that all relative paths in the json file are considered relative to the current working directory and not to the location of the json file. Examples can be found in `example/JSON`. If you want to be sure to have the correct output file we recommend using absolute paths.

For the following examples the C2HDM with the example/C2HDM_Input.dat file is used.

### BSMPT
Expand Down
17 changes: 17 additions & 0 deletions example/JSON/BSMPT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
13 changes: 13 additions & 0 deletions example/JSON/CalcCT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
19 changes: 19 additions & 0 deletions example/JSON/CalculateEWBG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"config": "../example/EWBG_config.txt",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
17 changes: 17 additions & 0 deletions example/JSON/NLOVEV.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
19 changes: 19 additions & 0 deletions example/JSON/PlotEWBG_nL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"config": "../example/EWBG_config.txt",
"vw": "0.1",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
21 changes: 21 additions & 0 deletions example/JSON/PlotEWBG_vw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"config": "../example/EWBG_config.txt",
"vw_min": "0.1",
"vw_max": "0.2",
"vw_stepsize": "0.05",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
14 changes: 14 additions & 0 deletions example/JSON/Test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"model": "c2hdm",
"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
13 changes: 13 additions & 0 deletions example/JSON/TripleHiggsCouplingsNLO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
20 changes: 20 additions & 0 deletions example/JSON/VEVEVO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"temperatureStart": "0",
"temperatureEnd": "100",
"temperatureStep": "5",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
1 change: 1 addition & 0 deletions include/BSMPT/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
#cmakedefine libcmaes_FOUND
#cmakedefine NLopt_FOUND
#cmakedefine Boost_FOUND
#cmakedefine nlohmann_json_FOUND
25 changes: 19 additions & 6 deletions include/BSMPT/utility/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ namespace BSMPT
{

class Logger;
class parser;

void ShowLoggerHelp();
void SetLogger(const parser &argparser);
void SetLogger(const std::vector<std::string> &args);

enum class LoggingLevel
Expand All @@ -32,18 +34,29 @@ enum class LoggingLevel
Debug
};

/**
* @brief The BSMPTLogger class
*/
class BSMPTLogger
{
public:
friend Logger;
BSMPTLogger(std::ostream &os) : mOstream{os.rdbuf()} {}
BSMPTLogger(const BSMPTLogger &) = delete;
BSMPTLogger(BSMPTLogger &&) = delete;
BSMPTLogger(const BSMPTLogger &) = delete;
BSMPTLogger(BSMPTLogger &&) = delete;
BSMPTLogger &operator=(const BSMPTLogger &) = delete;
BSMPTLogger &operator=(BSMPTLogger &&) = delete;
BSMPTLogger &operator=(BSMPTLogger &&) = delete;

private:
/**
* @brief SetOStream sets the output of the logger to a certain ostream
* @param Ostream
*/
void SetOStream(std::ostream &Ostream);
/**
* @brief SetOStream writes the output of the logger to a file
* @param file
*/
void SetOStream(const std::string &file);
template <typename T>
void
Expand Down Expand Up @@ -81,10 +94,10 @@ class BSMPTLogger
class Logger
{
public:
Logger(const Logger &) = delete;
Logger(Logger &&) = delete;
Logger(const Logger &) = delete;
Logger(Logger &&) = delete;
Logger &operator=(const Logger &) = delete;
Logger &operator=(Logger &&) = delete;
Logger &operator=(Logger &&) = delete;

static void SetLevel(const std::map<LoggingLevel, bool> &Setup)
{
Expand Down
Loading

0 comments on commit f24ba97

Please sign in to comment.