2010-10-25 18:20:58 +02:00
|
|
|
|
/*
|
2023-01-05 16:40:04 +01:00
|
|
|
|
* Copyright © 2010-2023 Dynare Team
|
2010-10-25 18:20:58 +02:00
|
|
|
|
*
|
|
|
|
|
* This file is part of Dynare.
|
|
|
|
|
*
|
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-06-09 16:52:20 +02:00
|
|
|
|
* along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2010-10-25 18:20:58 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2023-12-11 17:16:49 +01:00
|
|
|
|
#ifndef CONFIGURATION_HH
|
|
|
|
|
#define CONFIGURATION_HH
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
2023-11-30 15:28:57 +01:00
|
|
|
|
#include <filesystem>
|
2010-10-25 18:20:58 +02:00
|
|
|
|
#include <map>
|
|
|
|
|
#include <vector>
|
2011-03-10 19:35:00 +01:00
|
|
|
|
|
2012-01-23 16:52:27 +01:00
|
|
|
|
#include "WarningConsolidation.hh"
|
|
|
|
|
|
2010-10-25 18:20:58 +02:00
|
|
|
|
using namespace std;
|
|
|
|
|
|
2023-12-11 17:27:17 +01:00
|
|
|
|
/* The abstract representation of the configuration.
|
|
|
|
|
Merges information from the command-line and from the configuration file. */
|
|
|
|
|
class Configuration
|
2012-06-06 16:07:59 +02:00
|
|
|
|
{
|
|
|
|
|
public:
|
2023-12-11 17:27:17 +01:00
|
|
|
|
Configuration(bool parallel_arg, bool parallel_test_arg, bool parallel_follower_open_mode_arg,
|
|
|
|
|
bool parallel_use_psexec_arg, string cluster_name);
|
2023-11-30 15:28:57 +01:00
|
|
|
|
|
2012-06-06 16:07:59 +02:00
|
|
|
|
private:
|
2023-12-11 17:27:17 +01:00
|
|
|
|
using member_nodes_t = map<string, double>;
|
2023-11-30 15:28:57 +01:00
|
|
|
|
|
2023-12-11 17:27:17 +01:00
|
|
|
|
class Path
|
2017-05-16 16:30:27 +02:00
|
|
|
|
{
|
2023-12-11 17:27:17 +01:00
|
|
|
|
public:
|
|
|
|
|
explicit Path(vector<string> includepath_arg);
|
|
|
|
|
[[nodiscard]] map<string, vector<string>>
|
|
|
|
|
get_paths() const
|
|
|
|
|
{
|
|
|
|
|
return paths;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
map<string, vector<string>> paths;
|
2017-05-16 16:30:27 +02:00
|
|
|
|
};
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
2023-12-11 17:27:17 +01:00
|
|
|
|
struct FollowerNode
|
|
|
|
|
{
|
|
|
|
|
FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg,
|
|
|
|
|
string userName_arg, string password_arg, string remoteDrive_arg,
|
|
|
|
|
string remoteDirectory_arg, string programPath_arg, string programConfig_arg,
|
|
|
|
|
string matlabOctavePath_arg, bool singleCompThread_arg,
|
|
|
|
|
int numberOfThreadsPerJob_arg, string operatingSystem_arg);
|
|
|
|
|
const string computerName, port;
|
|
|
|
|
int minCpuNbr, maxCpuNbr;
|
|
|
|
|
const string userName, password;
|
|
|
|
|
const string remoteDrive, remoteDirectory;
|
|
|
|
|
const string programPath, programConfig, matlabOctavePath;
|
|
|
|
|
const bool singleCompThread;
|
|
|
|
|
const int numberOfThreadsPerJob;
|
|
|
|
|
const string operatingSystem;
|
|
|
|
|
};
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
2023-12-11 17:27:17 +01:00
|
|
|
|
struct Cluster
|
|
|
|
|
{
|
|
|
|
|
explicit Cluster(member_nodes_t member_nodes_arg);
|
|
|
|
|
member_nodes_t member_nodes;
|
|
|
|
|
};
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
2022-06-15 15:37:19 +02:00
|
|
|
|
const bool parallel, parallel_test, parallel_follower_open_mode, parallel_use_psexec;
|
2010-10-25 18:20:58 +02:00
|
|
|
|
const string cluster_name;
|
|
|
|
|
string firstClusterName;
|
2012-06-06 16:07:59 +02:00
|
|
|
|
//! Hooks
|
2023-12-12 15:54:44 +01:00
|
|
|
|
string global_init_file;
|
2015-08-28 17:58:43 +02:00
|
|
|
|
//! Paths
|
2018-07-04 15:56:23 +02:00
|
|
|
|
vector<Path> paths;
|
2010-10-25 18:20:58 +02:00
|
|
|
|
//! Cluster Table
|
2018-07-04 15:56:23 +02:00
|
|
|
|
map<string, Cluster> clusters;
|
2010-10-25 18:20:58 +02:00
|
|
|
|
//! Node Map
|
2022-06-15 15:37:19 +02:00
|
|
|
|
map<string, FollowerNode> follower_nodes;
|
2015-08-28 17:58:43 +02:00
|
|
|
|
//! Add Paths
|
2018-07-04 15:56:23 +02:00
|
|
|
|
void addPathsConfFileElement(vector<string> includepath);
|
2022-06-15 15:37:19 +02:00
|
|
|
|
//! Add a FollowerNode or a Cluster object
|
2023-11-30 15:28:57 +01:00
|
|
|
|
void addParallelConfFileElement(bool inNode, bool inCluster, const member_nodes_t& member_nodes,
|
|
|
|
|
const string& name, const string& computerName,
|
|
|
|
|
const string& port, int minCpuNbr, int maxCpuNbr,
|
|
|
|
|
const string& userName, const string& password,
|
|
|
|
|
const string& remoteDrive, const string& remoteDirectory,
|
|
|
|
|
const string& programPath, const string& programConfig,
|
|
|
|
|
const string& matlabOctavePath, bool singleCompThread,
|
|
|
|
|
int numberOfThreadsPerJob, const string& operatingSystem);
|
2023-12-11 19:01:00 +01:00
|
|
|
|
/* Given a filename (e.g. dynare.ini), looks for it in the configuration directory:
|
|
|
|
|
– if under Linux or macOS, look into the “dynare” subdirectory of the XDG
|
|
|
|
|
configuration directories (following the default values and the precedence order specified in
|
|
|
|
|
the XDG specification)
|
|
|
|
|
– if under Windows, look into %APPDATA%\dynare\
|
|
|
|
|
The returned path will be empty if the file is not found. */
|
|
|
|
|
[[nodiscard]] static filesystem::path findConfigFile(const string& filename);
|
2023-11-30 15:28:57 +01:00
|
|
|
|
|
2010-10-25 18:20:58 +02:00
|
|
|
|
public:
|
|
|
|
|
//! Parse config file
|
2023-12-11 19:01:00 +01:00
|
|
|
|
void getConfigFileInfo(const filesystem::path& conffile_option, WarningConsolidation& warnings);
|
2010-10-25 18:20:58 +02:00
|
|
|
|
//! Check Pass
|
2023-11-30 15:28:57 +01:00
|
|
|
|
void checkPass(WarningConsolidation& warnings) const;
|
2010-10-25 18:20:58 +02:00
|
|
|
|
//! Check Pass
|
|
|
|
|
void transformPass();
|
2015-08-28 17:58:43 +02:00
|
|
|
|
//! Get Path Info
|
2023-12-01 14:02:38 +01:00
|
|
|
|
[[nodiscard]] vector<filesystem::path> getIncludePaths() const;
|
2012-06-06 16:07:59 +02:00
|
|
|
|
//! Write any hooks
|
2023-11-30 15:28:57 +01:00
|
|
|
|
void writeHooks(ostream& output) const;
|
2010-10-25 18:20:58 +02:00
|
|
|
|
//! Create options_.parallel structure, write options
|
2023-11-30 15:28:57 +01:00
|
|
|
|
void writeCluster(ostream& output) const;
|
2022-06-15 15:37:19 +02:00
|
|
|
|
//! Close follower nodes if needed
|
2023-11-30 15:28:57 +01:00
|
|
|
|
void writeEndParallel(ostream& output) const;
|
2010-10-25 18:20:58 +02:00
|
|
|
|
};
|
|
|
|
|
|
2023-12-01 15:39:01 +01:00
|
|
|
|
#endif
|