From 2be9a5cf746e3aba1e0da4d48a55867cf8747180 Mon Sep 17 00:00:00 2001 From: Xavier Andrade Date: Thu, 14 Nov 2024 10:07:40 -0800 Subject: [PATCH 1/2] Add the "force" alias for "forces". --- src/main/inq.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/inq.cpp b/src/main/inq.cpp index 5f6435ac..018121ce 100644 --- a/src/main/inq.cpp +++ b/src/main/inq.cpp @@ -23,6 +23,7 @@ int main(int argc, char* argv[]) { { "extraelectrons"s, "extra-electrons"s }, { "extrastates"s, "extra-states"s }, { "filename"s, "file"s }, + { "force"s, "forces"s }, { "fraction"s, "fractional"s }, { "freq"s, "frequency"s }, { "functionals"s, "functional"s }, From b91b87f80cc3d6db1d16b076578d375b6f7fc0b2 Mon Sep 17 00:00:00 2001 From: Xavier Andrade Date: Thu, 14 Nov 2024 10:14:31 -0800 Subject: [PATCH 2/2] Moved the aliases to their own file. --- src/interface/aliases.hpp | 89 +++++++++++++++++++++++++++++++++++++++ src/main/inq.cpp | 58 ++----------------------- 2 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 src/interface/aliases.hpp diff --git a/src/interface/aliases.hpp b/src/interface/aliases.hpp new file mode 100644 index 00000000..552553cc --- /dev/null +++ b/src/interface/aliases.hpp @@ -0,0 +1,89 @@ +/* -*- indent-tabs-mode: t -*- */ + +#ifndef INQ__INTERFACE__ALIASES +#define INQ__INTERFACE__ALIASES + +// Copyright (C) 2019-2024 Lawrence Livermore National Security, LLC., Xavier Andrade, Alfredo A. Correa +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#include + +namespace inq { +namespace interface { +auto aliases() { + using namespace std::string_literals; + + return std::unordered_map{ + { "atomicnumber"s, "atomic-number"s }, + { "calculator"s, "calc"s }, + { "clean"s, "clear"s }, + { "exactexchange"s, "exact-exchange"s }, + { "extraelectrons"s, "extra-electrons"s }, + { "extrastates"s, "extra-states"s }, + { "filename"s, "file"s }, + { "force"s, "forces"s }, + { "fraction"s, "fractional"s }, + { "freq"s, "frequency"s }, + { "functionals"s, "functional"s }, + { "groundstate"s, "ground-state"s }, + { "gs"s, "ground-state"s }, + { "hartreefock"s, "hartree-fock"s }, + { "kpoint"s, "kpoints"s }, + { "kpoints"s, "kpoints"s }, + { "k-point"s, "kpoints"s }, + { "k-points"s, "kpoints"s }, + { "listsets"s, "list-sets"s }, + { "maxsteps"s, "max-steps"s }, + { "mix"s, "mixing"s }, + { "noncollinear"s, "non-collinear"s }, + { "noninteracting"s, "non-interacting"s }, + { "nonlocal"s, "non-local"s }, + { "observable"s, "observables"s }, + { "perturbation"s, "perturbations"s }, + { "pseudo-potential"s, "pseudo"s }, + { "pseudopotential"s, "pseudo"s }, + { "pseudoset"s, "pseudo-set"s }, + { "realtime"s, "real-time"s }, + { "rt"s, "real-time"s }, + { "result"s, "results"s }, + { "results-ground-state"s, "results ground-state"s }, + { "resultsgroundstate"s, "results ground-state"s }, + { "resultsground-state"s, "results ground-state"s }, + { "results-groundstate"s, "results ground-state"s }, + { "resultsgs"s, "results ground-state"s }, + { "results-gs"s, "results ground-state"s }, + { "results-real-time"s, "results real-time"s }, + { "resultsrealtime"s, "results real-time"s }, + { "resultsreal-time"s, "results real-time"s }, + { "results-realtime"s, "results real-time"s }, + { "resultsrt"s, "results real-time"s }, + { "results-rt"s, "results real-time"s }, + { "grid-shifted"s, "shifted-grid"s }, + { "shiftedgrid"s, "shifted-grid"s }, + { "timestep"s, "time-step"s }, + { "totaltime"s, "total-time"s }, + { "totalsteps"s, "total-steps"s }, + { "tol"s, "tolerance"s }, + { "utils"s, "util"s } + }; +} +} +} + +#endif + +#ifdef INQ_INTERFACE_ALIASES_UNIT_TEST +#undef INQ_INTERFACE_ALIASES_UNIT_TEST + +#include + +TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG) { + + using namespace inq; + using namespace Catch::literals; + +} +#endif diff --git a/src/main/inq.cpp b/src/main/inq.cpp index 018121ce..0c1d38ad 100644 --- a/src/main/inq.cpp +++ b/src/main/inq.cpp @@ -8,67 +8,13 @@ #include #include +#include using namespace inq; int main(int argc, char* argv[]) { - using namespace std::string_literals; using interface::operator+; - std::unordered_map aliases = { - { "atomicnumber"s, "atomic-number"s }, - { "calculator"s, "calc"s }, - { "clean"s, "clear"s }, - { "exactexchange"s, "exact-exchange"s }, - { "extraelectrons"s, "extra-electrons"s }, - { "extrastates"s, "extra-states"s }, - { "filename"s, "file"s }, - { "force"s, "forces"s }, - { "fraction"s, "fractional"s }, - { "freq"s, "frequency"s }, - { "functionals"s, "functional"s }, - { "groundstate"s, "ground-state"s }, - { "gs"s, "ground-state"s }, - { "hartreefock"s, "hartree-fock"s }, - { "kpoint"s, "kpoints"s }, - { "kpoints"s, "kpoints"s }, - { "k-point"s, "kpoints"s }, - { "k-points"s, "kpoints"s }, - { "listsets"s, "list-sets"s }, - { "maxsteps"s, "max-steps"s }, - { "mix"s, "mixing"s }, - { "noncollinear"s, "non-collinear"s }, - { "noninteracting"s, "non-interacting"s }, - { "nonlocal"s, "non-local"s }, - { "observable"s, "observables"s }, - { "perturbation"s, "perturbations"s }, - { "pseudo-potential"s, "pseudo"s }, - { "pseudopotential"s, "pseudo"s }, - { "pseudoset"s, "pseudo-set"s }, - { "realtime"s, "real-time"s }, - { "rt"s, "real-time"s }, - { "result"s, "results"s }, - { "results-ground-state"s, "results ground-state"s }, - { "resultsgroundstate"s, "results ground-state"s }, - { "resultsground-state"s, "results ground-state"s }, - { "results-groundstate"s, "results ground-state"s }, - { "resultsgs"s, "results ground-state"s }, - { "results-gs"s, "results ground-state"s }, - { "results-real-time"s, "results real-time"s }, - { "resultsrealtime"s, "results real-time"s }, - { "resultsreal-time"s, "results real-time"s }, - { "results-realtime"s, "results real-time"s }, - { "resultsrt"s, "results real-time"s }, - { "results-rt"s, "results real-time"s }, - { "grid-shifted"s, "shifted-grid"s }, - { "shiftedgrid"s, "shifted-grid"s }, - { "timestep"s, "time-step"s }, - { "totaltime"s, "total-time"s }, - { "totalsteps"s, "total-steps"s }, - { "tol"s, "tolerance"s }, - { "utils"s, "util"s } - }; - auto comm = input::environment::global().comm(); //Initialize MPI auto all_commands = @@ -142,6 +88,8 @@ int main(int argc, char* argv[]) { arg = uniformize(arg); + auto aliases = interface::aliases(); + //process aliases auto search = aliases.find(arg); if(search != aliases.end()) arg = search->second;