Skip to content

Commit

Permalink
rm optional file names
Browse files Browse the repository at this point in the history
  • Loading branch information
rscherrer committed Jun 7, 2021
1 parent 3b0cb8d commit 7914e7e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
7 changes: 4 additions & 3 deletions src/GenArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ void GenArch::write(const std::vector<Edge> &v, std::ofstream &file, const bool

void GenArch::save(Param &pars) const
{
std::ofstream archfile(pars.archfile); // should be arg
const std::string filename = "architecture.txt";
std::ofstream archfile(filename);

if (!archfile.is_open())
throw std::runtime_error("Unable to open file " + pars.archfile + '\n');
throw std::runtime_error("Unable to open file " + filename + '\n');

// Write parameters first
archfile << "Parameters used to generate the architecture:\n";
Expand Down Expand Up @@ -254,7 +255,7 @@ void GenArch::load(const Param &pars)
// with that found in the arhictecture file provided
// and update the parameters accordingly

const std::string filename = pars.archfile;
const std::string filename = "architecture.txt";

// Open the architecture file
std::ifstream file(filename.c_str());
Expand Down
17 changes: 3 additions & 14 deletions src/Param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Param::Param() :
archload(false),
parsave(true),
logsave(false),
archfile("architecture.txt"),
parfile("paramlog.txt"),
orderfile("whattosave.txt"),
logfile("log.txt"),
seed(makeDefaultSeed()),
ntrials(100u)
{
Expand Down Expand Up @@ -147,10 +143,6 @@ void Param::import(std::ifstream &file)
else if (input == "archload") file >> archload;
else if (input == "parsave") file >> parsave;
else if (input == "logsave") file >> logsave;
else if (input == "archfile") file >> archfile;
else if (input == "parfile") file >> parfile;
else if (input == "orderfile") file >> orderfile;
else if (input == "logfile") file >> logfile;
else if (input == "seed") file >> seed;
else if (input == "ntrials") file >> ntrials;
else
Expand Down Expand Up @@ -271,9 +263,10 @@ void Param::check() const

void Param::save() const
{
std::ofstream file(parfile);
const std::string filename = "paramlog.txt";
std::ofstream file(filename);
if (!file.is_open())
throw std::runtime_error("Unable to open file " + parfile);
throw std::runtime_error("Unable to open file " + filename);
write(file);
file.close();
}
Expand Down Expand Up @@ -340,10 +333,6 @@ void Param::write(std::ofstream &file) const
file << "archload " << archload << '\n';
file << "parsave " << parsave << '\n';
file << "logsave " << logsave << '\n';
file << "archfile " << archfile << '\n';
file << "parfile " << parfile << '\n';
file << "orderfile " << orderfile << '\n';
file << "logfile " << logfile << '\n';
file << "seed " << seed << '\n';
file << "ntrials " << ntrials << '\n';

Expand Down
4 changes: 0 additions & 4 deletions src/Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ struct Param {
bool archload;
bool parsave;
bool logsave;
std::string archfile;
std::string parfile;
std::string orderfile;
std::string logfile;
size_t seed;
size_t ntrials;

Expand Down
5 changes: 2 additions & 3 deletions src/Simul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int simulate(const std::vector<std::string> &args)
Collector collector = Collector(arch);

// Create a printer
const std::string order = pars.choosewhattosave ? pars.orderfile : "";
const std::string order = pars.choosewhattosave ? "whattosave.txt" : "";
Printer printer = Printer(order);
if (pars.datsave) printer.open();

Expand All @@ -44,8 +44,7 @@ int simulate(const std::vector<std::string> &args)
}

// Redirect output to log file if needed
if (pars.logsave)
pars.logsave = std::freopen(pars.logfile.c_str(), "w", stdout);
if (pars.logsave) pars.logsave = std::freopen("log.txt", "w", stdout);

// Open a log file
std::cout << "Simulation started.\n";
Expand Down

0 comments on commit 7914e7e

Please sign in to comment.