2010-10-25 18:20:58 +02:00
|
|
|
/*
|
2019-12-16 19:42:59 +01:00
|
|
|
* Copyright © 2010-2019 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
|
|
|
|
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CONFIG_FILE_HH
|
|
|
|
#define _CONFIG_FILE_HH
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2018-06-04 14:31:26 +02:00
|
|
|
using member_nodes_t = map<string, double>;
|
2011-03-10 19:35:00 +01:00
|
|
|
|
2012-06-06 16:07:59 +02:00
|
|
|
class Hook
|
|
|
|
{
|
|
|
|
public:
|
2018-07-04 15:56:23 +02:00
|
|
|
explicit Hook(string global_init_file_arg);
|
2012-06-06 16:07:59 +02:00
|
|
|
private:
|
|
|
|
map<string, string> hooks;
|
|
|
|
public:
|
2017-05-16 16:30:27 +02:00
|
|
|
inline map<string, string>
|
2018-07-04 15:56:23 +02:00
|
|
|
get_hooks() const
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
|
|
|
return hooks;
|
|
|
|
};
|
2012-06-06 16:07:59 +02:00
|
|
|
};
|
2011-03-10 19:35:00 +01:00
|
|
|
|
2015-08-28 17:58:43 +02:00
|
|
|
class Path
|
|
|
|
{
|
|
|
|
public:
|
2018-07-04 15:56:23 +02:00
|
|
|
explicit Path(vector<string> includepath_arg);
|
2015-08-28 17:58:43 +02:00
|
|
|
private:
|
2018-06-04 14:17:36 +02:00
|
|
|
map<string, vector<string>> paths;
|
2015-08-28 17:58:43 +02:00
|
|
|
public:
|
2018-06-04 14:17:36 +02:00
|
|
|
inline map<string, vector<string>>
|
2018-07-04 15:56:23 +02:00
|
|
|
get_paths() const
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
|
|
|
return paths;
|
|
|
|
};
|
2015-08-28 17:58:43 +02:00
|
|
|
};
|
|
|
|
|
2010-10-25 18:20:58 +02:00
|
|
|
class SlaveNode
|
|
|
|
{
|
|
|
|
friend class ConfigFile;
|
|
|
|
public:
|
2018-07-04 15:56:23 +02:00
|
|
|
SlaveNode(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 dynarePath_arg, string matlabOctavePath_arg, bool singleCompThread_arg, int numberOfThreadsPerJob_arg,
|
|
|
|
string operatingSystem_arg);
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
|
|
protected:
|
2019-12-16 19:42:59 +01:00
|
|
|
const string computerName, port;
|
|
|
|
int minCpuNbr, maxCpuNbr;
|
|
|
|
const string userName, password;
|
|
|
|
const string remoteDrive, remoteDirectory;
|
|
|
|
const string dynarePath, matlabOctavePath;
|
2010-10-25 18:20:58 +02:00
|
|
|
const bool singleCompThread;
|
2016-12-13 11:35:24 +01:00
|
|
|
const int numberOfThreadsPerJob;
|
2011-03-10 16:27:07 +01:00
|
|
|
const string operatingSystem;
|
2010-10-25 18:20:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Cluster
|
|
|
|
{
|
|
|
|
friend class ConfigFile;
|
|
|
|
public:
|
2018-10-04 15:17:13 +02:00
|
|
|
explicit Cluster(member_nodes_t member_nodes_arg);
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
|
|
protected:
|
2011-06-09 14:44:58 +02:00
|
|
|
member_nodes_t member_nodes;
|
2010-10-25 18:20:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//! The abstract representation of a "config" file
|
|
|
|
class ConfigFile
|
|
|
|
{
|
|
|
|
public:
|
2018-06-04 12:31:07 +02:00
|
|
|
ConfigFile(bool parallel_arg, bool parallel_test_arg, bool parallel_slave_open_mode_arg, string cluster_name);
|
2010-10-25 18:20:58 +02:00
|
|
|
|
|
|
|
private:
|
2019-12-16 19:42:59 +01:00
|
|
|
const bool parallel, parallel_test, parallel_slave_open_mode;
|
2010-10-25 18:20:58 +02:00
|
|
|
const string cluster_name;
|
|
|
|
string firstClusterName;
|
2012-06-06 16:07:59 +02:00
|
|
|
//! Hooks
|
2018-07-04 15:56:23 +02:00
|
|
|
vector<Hook> hooks;
|
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
|
2018-07-04 15:56:23 +02:00
|
|
|
map<string, SlaveNode> slave_nodes;
|
2012-06-06 16:07:59 +02:00
|
|
|
//! Add Hooks
|
2018-07-04 15:56:23 +02:00
|
|
|
void addHooksConfFileElement(string global_init_file);
|
2015-08-28 17:58:43 +02:00
|
|
|
//! Add Paths
|
2018-07-04 15:56:23 +02:00
|
|
|
void addPathsConfFileElement(vector<string> includepath);
|
2010-10-25 18:20:58 +02:00
|
|
|
//! Add a SlaveNode or a Cluster object
|
2018-07-04 15:56:23 +02: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 &dynarePath, const string &matlabOctavePath, bool singleCompThread, int numberOfThreadsPerJob,
|
|
|
|
const string &operatingSystem);
|
2010-10-25 18:20:58 +02:00
|
|
|
public:
|
|
|
|
//! Parse config file
|
|
|
|
void getConfigFileInfo(const string ¶llel_config_file);
|
|
|
|
//! Check Pass
|
2012-01-23 16:52:27 +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
|
2019-10-04 10:54:03 +02:00
|
|
|
vector<filesystem::path> getIncludePaths() const;
|
2012-06-06 16:07:59 +02:00
|
|
|
//! Write any hooks
|
|
|
|
void writeHooks(ostream &output) const;
|
2010-10-25 18:20:58 +02:00
|
|
|
//! Create options_.parallel structure, write options
|
|
|
|
void writeCluster(ostream &output) const;
|
|
|
|
//! Close slave nodes if needed
|
|
|
|
void writeEndParallel(ostream &output) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! CONFIG_FILE_HH
|