1 /*
2  * Distributed under the OSI-approved Apache License, Version 2.0.  See
3  * accompanying file Copyright.txt for details.
4  *
5  * settings.h
6  *
7  *  Created on: Oct 2018
8  *      Author: Norbert Podhorszki
9  */
10 
11 #ifndef SETTINGS_H_
12 #define SETTINGS_H_
13 
14 #include "adios2/common/ADIOSConfig.h"
15 
16 #include <fstream>
17 #include <string>
18 #include <vector>
19 
20 #include <mpi.h>
21 
22 enum class IOLib
23 {
24     ADIOS
25 #ifdef ADIOS2_HAVE_HDF5_PARALLEL
26     ,
27     HDF5
28 #endif
29 };
30 
31 class Settings
32 {
33 
34 public:
35     /* user arguments */
36     std::string configFileName;
37     std::string adiosConfigFileName;
38     unsigned int verbose = 0;
39     size_t appId = 0;
40     bool isStrongScaling = true; // strong or weak scaling
41     bool ioTimer = false;        // used to measure io time
42     bool fixedPattern = false;   // should Lock definitions?
43     bool isRatioDecomp = false;
44     IOLib iolib = IOLib::ADIOS;
45     //   process decomposition
46     std::vector<size_t> processDecomp = {1, 1, 1, 1, 1, 1, 1, 1,
47                                          1, 1, 1, 1, 1, 1, 1, 1};
48 
49     /* public variables */
50     MPI_Comm appComm = MPI_COMM_WORLD; // will change to split communicator
51     size_t myRank = 0;
52     size_t nProc = 1;
53     std::ifstream configFile;
54     size_t nDecomp = 0;
55 
56     Settings() = default;
57     ~Settings() = default;
58     int processArguments(int argc, char *argv[], MPI_Comm worldComm);
59     int extraArgumentChecks();
60     size_t stringToNumber(const std::string &varName, const char *arg) const;
61     int parseCSDecomp(const char *arg);
62     int rescaleDecomp();
63     size_t ndigits(size_t n) const;
64 
65 private:
66     void displayHelp();
67     int processArgs(int argc, char *argv[]);
68 };
69 
70 #endif /* SETTINGS_H_ */
71