Quinoa all test code coverage report
Current view: top level - Control/Inciter/CmdLine - CmdLine.hpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 28 29 96.6 %
Date: 2021-11-11 18:25:50 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 18 50.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Control/Inciter/CmdLine/CmdLine.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Inciter's command line definition
       9                 :            :   \details   This file defines the heterogeneous stack that is used for storing
      10                 :            :      the data from user input during the command-line parsing of the
      11                 :            :      computational shock hydrodynamics tool, Inciter.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef InciterCmdLine_h
      15                 :            : #define InciterCmdLine_h
      16                 :            : 
      17                 :            : #include <string>
      18                 :            : 
      19                 :            : #include <brigand/algorithms/for_each.hpp>
      20                 :            : 
      21                 :            : #include "QuinoaConfig.hpp"
      22                 :            : #include "HelpFactory.hpp"
      23                 :            : #include "Keywords.hpp"
      24                 :            : #include "Inciter/Types.hpp"
      25                 :            : 
      26                 :            : namespace inciter {
      27                 :            : //! Inciter control facilitating user input to internal data transfer
      28                 :            : namespace ctr {
      29                 :            : 
      30                 :            : //! Member data for tagged tuple
      31                 :            : using CmdLineMembers = brigand::list<
      32                 :            :     tag::io,             ios
      33                 :            :   , tag::virtualization, kw::virtualization::info::expect::type
      34                 :            :   , tag::verbose,        bool
      35                 :            :   , tag::chare,          bool
      36                 :            :   , tag::nonblocking,    bool
      37                 :            :   , tag::benchmark,      bool
      38                 :            :   , tag::feedback,       bool
      39                 :            :   , tag::help,           bool
      40                 :            :   , tag::helpctr,        bool
      41                 :            :   , tag::quiescence,     bool
      42                 :            :   , tag::trace,          bool
      43                 :            :   , tag::version,        bool
      44                 :            :   , tag::license,        bool
      45                 :            :   , tag::cmdinfo,        tk::ctr::HelpFactory
      46                 :            :   , tag::ctrinfo,        tk::ctr::HelpFactory
      47                 :            :   , tag::helpkw,         tk::ctr::HelpKw
      48                 :            :   , tag::error,          std::vector< std::string >
      49                 :            :   , tag::lbfreq,         kw::lbfreq::info::expect::type
      50                 :            :   , tag::rsfreq,         kw::rsfreq::info::expect::type
      51                 :            : >;
      52                 :            : 
      53                 :            : //! \brief CmdLine : Control< specialized to Inciter >
      54                 :            : //! \details The stack is a tagged tuple
      55                 :            : //! \see Base/TaggedTuple.h
      56                 :            : //! \see Control/Inciter/Types.h
      57                 :            : class CmdLine : public tk::TaggedTuple< CmdLineMembers > {
      58                 :            : 
      59                 :            :   public:
      60                 :            :     //! \brief Inciter command-line keywords
      61                 :            :     //! \see tk::grm::use and its documentation
      62                 :            :     using keywords = tk::cmd_keywords< kw::verbose
      63                 :            :                                      , kw::charestate
      64                 :            :                                      , kw::nonblocking
      65                 :            :                                      , kw::benchmark
      66                 :            :                                      , kw::feedback
      67                 :            :                                      , kw::virtualization
      68                 :            :                                      , kw::help
      69                 :            :                                      , kw::helpctr
      70                 :            :                                      , kw::helpkw
      71                 :            :                                      , kw::control
      72                 :            :                                      , kw::input
      73                 :            :                                      , kw::output
      74                 :            :                                      , kw::screen
      75                 :            :                                      , kw::restart
      76                 :            :                                      , kw::diagnostics_cmd
      77                 :            :                                      , kw::quiescence
      78                 :            :                                      , kw::lbfreq
      79                 :            :                                      , kw::rsfreq
      80                 :            :                                      , kw::trace
      81                 :            :                                      , kw::version
      82                 :            :                                      , kw::license
      83                 :            :                                      >;
      84                 :            : 
      85                 :            :     //! Set of tags to ignore when printing this CmdLine
      86                 :            :     using ignore =
      87                 :            :       brigand::set< tag::cmdinfo
      88                 :            :                   , tag::ctrinfo
      89                 :            :                   , tag::helpkw >;
      90                 :            : 
      91                 :            :     //! \brief Constructor: set all defaults.
      92                 :            :     //! \param[in] ctrinfo std::map of control file keywords and their info
      93                 :            :     //!  \details Anything not set here is initialized by the compiler using the
      94                 :            :     //!   default constructor for the corresponding type. The ctrinfo map
      95                 :            :     //!   argument is optional. If not given, it is an empty std::map
      96                 :            :     //!   constructed in-place and affects nothing. If given, it contains the
      97                 :            :     //!   control file keywords, all of which are moved into the relevant slot
      98                 :            :     //!   (tag::ctrinfo). This allows constructing, e.g., a CmdLine object both
      99                 :            :     //!   with and without this information in place, which are both used at
     100                 :            :     //!   different stages of the execution. For example, because the
     101                 :            :     //!   command-line is parsed very early on during runtime while the input
     102                 :            :     //!   deck is only parsed much later, the control-file keywords and their
     103                 :            :     //!   information (owned by and generated by the input deck and its
     104                 :            :     //!   constructor) is not yet available when the CmdLine object is
     105                 :            :     //!   constructed. However, during command-line parsing it is still possible
     106                 :            :     //!   to request information on a control file keyword, so it must be
     107                 :            :     //!   available. The input deck is where all parsed information goes during
     108                 :            :     //!   control file parsing and is stored at global scope, see, e.g.,
     109                 :            :     //!   walker::g_inputdeck. This global-scope (still namespace-scope), input
     110                 :            :     //!   deck object is thus created before command-line parsing. The input
     111                 :            :     //!   deck object's constructor (working only on type information, available
     112                 :            :     //!   at compile-time, of all the control file keywords) creates a run-time
     113                 :            :     //!   map. This is a run-time map, but available before main() starts,
     114                 :            :     //!   because it is const and it is initialized as a global-scope map. This
     115                 :            :     //!   map is then passed in here as ctrinfo, and its contents inserted into
     116                 :            :     //!   the CmdLine object, making the control-file keywords and their info
     117                 :            :     //!   available during command-line parsing. Since the input deck stack
     118                 :            :     //!   contains a copy of the command-line stack, the command-line stack must
     119                 :            :     //!   be possible to be instantiated without passing the ctrinfo map,
     120                 :            :     //!   otherwise it would be a mutual dependency.
     121                 :            :     // cppcheck-suppress noExplicitConstructor
     122                 :       3363 :     CmdLine( tk::ctr::HelpFactory ctrinfo = tk::ctr::HelpFactory() ) {
     123                 :       3363 :       get< tag::io, tag::nrestart >() = 0;
     124         [ +  - ]:       3363 :       get< tag::io, tag::output >() = "out";
     125                 :       3363 :       get< tag::io, tag::refined >() = false;
     126                 :       3363 :       get< tag::io, tag::screen >() =
     127 [ +  - ][ +  - ]:       6726 :         tk::baselogname( tk::inciter_executable() );
     128         [ +  - ]:       3363 :       get< tag::io, tag::diag >() = "diag";
     129         [ +  - ]:       3363 :       get< tag::io, tag::particles >() = "track.h5part";
     130         [ +  - ]:       3363 :       get< tag::io, tag::restart >() = "restart";
     131                 :       3363 :       get< tag::virtualization >() = 0.0;
     132                 :       3363 :       get< tag::verbose >() = false; // Quiet output by default
     133                 :       3363 :       get< tag::chare >() = false; // No chare state output by default
     134                 :       3363 :       get< tag::nonblocking>() = false; // Blocking migration by default
     135                 :       3363 :       get< tag::benchmark >() = false; // No benchmark mode by default
     136                 :       3363 :       get< tag::feedback >() = false; // No detailed feedback by default
     137                 :       3363 :       get< tag::lbfreq >() = 1; // Load balancing every time-step by default
     138                 :       3363 :       get< tag::rsfreq >() = 1000;// Chkpt/restart after this many time steps
     139                 :       3363 :       get< tag::trace >() = true; // Output call and stack trace by default
     140                 :       3363 :       get< tag::version >() = false; // Do not display version info by default
     141                 :       3363 :       get< tag::license >() = false; // Do not display license info by default
     142                 :            :       // Initialize help: fill from own keywords + add map passed in
     143         [ +  - ]:       3363 :       brigand::for_each< keywords::set >( tk::ctr::Info(get<tag::cmdinfo>()) );
     144                 :       3363 :       get< tag::ctrinfo >() = std::move( ctrinfo );
     145                 :       3363 :     }
     146                 :            : 
     147                 :            :     /** @name Pack/Unpack: Serialize CmdLine object for Charm++ */
     148                 :            :     ///@{
     149                 :            :     //! \brief Pack/Unpack serialize member function
     150                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     151                 :       1798 :     void pup( PUP::er& p ) { tk::TaggedTuple< CmdLineMembers >::pup(p); }
     152                 :            :     //! \brief Pack/Unpack serialize operator|
     153                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     154                 :            :     //! \param[in,out] c CmdLine object reference
     155                 :       1798 :     friend void operator|( PUP::er& p, CmdLine& c ) { c.pup(p); }
     156                 :            :     //@}
     157                 :            : 
     158                 :            :     //! Compute and return log file name
     159                 :            :     //! \param[in] def Default log file name (so we don't mess with user's)
     160                 :            :     //! \param[in] nrestart Number of times restarted
     161                 :            :     //! \return Log file name
     162                 :       6788 :     std::string logname( const std::string& def, int nrestart ) const {
     163         [ -  + ]:       6788 :       if (get< tag::io, tag::screen >() != def)
     164                 :          0 :         return get< tag::io, tag::screen >();
     165                 :            :       else
     166         [ +  - ]:      13576 :         return tk::logname( tk::inciter_executable(), nrestart );
     167                 :            :     }
     168                 :            : };
     169                 :            : 
     170                 :            : } // ctr::
     171                 :            : } // inciter::
     172                 :            : 
     173                 :            : #endif // InciterCmdLine_h

Generated by: LCOV version 1.14