Commit 974d81c0 authored by Spencer Sherwin's avatar Spencer Sherwin
Browse files

Updated so that the correct files is checked in case of overwriting...

Updated so that the correct files is checked in case of overwriting possibilty. Not this now will force an overwrite always when --nparts is used. Also updated soem syntax suggestions from Douglas
parent 09cb4ef7
...@@ -50,6 +50,8 @@ namespace FieldUtils ...@@ -50,6 +50,8 @@ namespace FieldUtils
OutputFileBase::OutputFileBase(FieldSharedPtr f) : OutputModule(f) OutputFileBase::OutputFileBase(FieldSharedPtr f) : OutputModule(f)
{ {
m_requireEquiSpaced = false; m_requireEquiSpaced = false;
m_config["writemultiplefiles"] =
ConfigOption(true,"0","Write multiple files in parallel or when using nparts option");
} }
OutputFileBase::~OutputFileBase() OutputFileBase::~OutputFileBase()
...@@ -249,7 +251,7 @@ bool OutputFileBase::WriteFile(std::string &filename, po::variables_map &vm) ...@@ -249,7 +251,7 @@ bool OutputFileBase::WriteFile(std::string &filename, po::variables_map &vm)
// Get path to file. If procid was defined, get the full name // Get path to file. If procid was defined, get the full name
// to avoid checking files from other partitions // to avoid checking files from other partitions
fs::path outFile; fs::path outFile;
if(vm.count("nprocs")) if(vm.count("nparts"))
{ {
outFile = GetFullOutName(filename, vm); outFile = GetFullOutName(filename, vm);
} }
...@@ -275,29 +277,28 @@ bool OutputFileBase::WriteFile(std::string &filename, po::variables_map &vm) ...@@ -275,29 +277,28 @@ bool OutputFileBase::WriteFile(std::string &filename, po::variables_map &vm)
int writeFile = 1; int writeFile = 1;
if (count && (vm.count("forceoutput") == 0)) if (count && (vm.count("forceoutput") == 0))
{ {
writeFile = 0; // set to zero for reduce all to be correct. if(vm.count("nparts") == 0 ) // do not do check if --nparts is enabled.
if (comm->GetRank() == 0)
{ {
string answer;
cout << "Did you wish to overwrite " << outFile << " (y/n)? "; writeFile = 0; // set to zero for reduce all to be correct.
getline(cin, answer);
if (answer.compare("y") == 0) if (comm->TreatAsRankZero())
{
writeFile = 1;
}
else
{ {
cout << "Not writing file " << filename string answer;
<< " because it already exists" << endl; cout << "Did you wish to overwrite " << outFile << " (y/n)? ";
getline(cin, answer);
if (answer.compare("y") == 0)
{
writeFile = 1;
}
else
{
cout << "Not writing file " << filename
<< " because it already exists" << endl;
}
} }
comm->AllReduce(writeFile, LibUtilities::ReduceSum);
} }
else if (comm->TreatAsRankZero())
{
writeFile = 1;
}
comm->AllReduce(writeFile, LibUtilities::ReduceSum);
} }
return (writeFile == 0) ? false : true; return (writeFile == 0) ? false : true;
} }
......
...@@ -59,8 +59,6 @@ OutputFld::OutputFld(FieldSharedPtr f) : OutputFileBase(f) ...@@ -59,8 +59,6 @@ OutputFld::OutputFld(FieldSharedPtr f) : OutputFileBase(f)
{ {
m_config["format"] = ConfigOption( m_config["format"] = ConfigOption(
false, "Xml", "Output format of field file"); false, "Xml", "Output format of field file");
m_config["writemultiplefiles"] =
ConfigOption(true,"0","Write multiple files in parallel or using nparts option");
} }
OutputFld::~OutputFld() OutputFld::~OutputFld()
......
...@@ -75,14 +75,27 @@ OutputTecplot::OutputTecplot(FieldSharedPtr f) : OutputFileBase(f), ...@@ -75,14 +75,27 @@ OutputTecplot::OutputTecplot(FieldSharedPtr f) : OutputFileBase(f),
m_oneOutputFile(false) m_oneOutputFile(false)
{ {
m_requireEquiSpaced = true; m_requireEquiSpaced = true;
m_config["writemultiplefiles"] =
ConfigOption(true,"0","Write multiple files in parallel or when using nparts option");
} }
OutputTecplot::~OutputTecplot() OutputTecplot::~OutputTecplot()
{ {
} }
void OutputTecplot::Process(po::variables_map &vm)
{
if(m_config["writemultiplefiles"].as<bool>())
{
m_oneOutputFile = false;
}
else
{
m_oneOutputFile = (m_f->m_comm->GetSize()> 1);
}
OutputFileBase::Process(vm);
}
/** /**
* @brief Helper function to write binary data to stream. * @brief Helper function to write binary data to stream.
*/ */
...@@ -299,12 +312,12 @@ fs::path OutputTecplot::GetPath(std::string &filename, ...@@ -299,12 +312,12 @@ fs::path OutputTecplot::GetPath(std::string &filename,
po::variables_map &vm) po::variables_map &vm)
{ {
int nprocs = m_f->m_comm->GetSize(); int nprocs = m_f->m_comm->GetSize();
int rank = m_f->m_comm->GetRank();
string returnstr(filename); string returnstr(filename);
// Amend for parallel output if required // Amend for parallel output if required
if (nprocs != 1 && !m_oneOutputFile) if (nprocs != 1 && !m_oneOutputFile)
{ {
int rank = m_f->m_comm->GetRank();
int dot = filename.find_last_of('.'); int dot = filename.find_last_of('.');
string ext = filename.substr(dot, filename.length() - dot); string ext = filename.substr(dot, filename.length() - dot);
string procId = "_P" + boost::lexical_cast<std::string>(rank); string procId = "_P" + boost::lexical_cast<std::string>(rank);
...@@ -330,14 +343,6 @@ void OutputTecplot::WriteTecplotFile(po::variables_map &vm) ...@@ -330,14 +343,6 @@ void OutputTecplot::WriteTecplotFile(po::variables_map &vm)
int nprocs = m_f->m_comm->GetSize(); int nprocs = m_f->m_comm->GetSize();
int rank = m_f->m_comm->GetRank(); int rank = m_f->m_comm->GetRank();
if(m_config["writemultiplefiles"].as<bool>())
{
m_oneOutputFile = false;
}
else
{
m_oneOutputFile = (nprocs > 1) && (vm.count("procid") == 0 );
}
// Extract the output filename and extension // Extract the output filename and extension
string filename = m_config["outfile"].as<string>(); string filename = m_config["outfile"].as<string>();
......
...@@ -71,6 +71,9 @@ public: ...@@ -71,6 +71,9 @@ public:
OutputTecplot(FieldSharedPtr f); OutputTecplot(FieldSharedPtr f);
virtual ~OutputTecplot(); virtual ~OutputTecplot();
virtual void Process(po::variables_map &vm);
virtual std::string GetModuleName() virtual std::string GetModuleName()
{ {
return "OutputTecplot"; return "OutputTecplot";
......
...@@ -52,6 +52,7 @@ int main(int argc, char* argv[]) ...@@ -52,6 +52,7 @@ int main(int argc, char* argv[])
{ {
Timer timer; Timer timer;
timer.Start(); timer.Start();
po::options_description desc("Available options"); po::options_description desc("Available options");
desc.add_options() desc.add_options()
("help,h", ("help,h",
...@@ -446,19 +447,21 @@ int main(int argc, char* argv[]) ...@@ -446,19 +447,21 @@ int main(int argc, char* argv[])
new FieldConvertComm(argc, argv, nParts,rank)); new FieldConvertComm(argc, argv, nParts,rank));
} }
// Run field process. // Run field process.
for (int n = 0; n < SIZE_ModulePriority; ++n) for (int n = 0; n < SIZE_ModulePriority; ++n)
{ {
ModulePriority priority = static_cast<ModulePriority>(n); ModulePriority priority = static_cast<ModulePriority>(n);
if(((priority == eCreateGraph)||(priority == eOutput))&&(nParts > 1)) if(nParts > 1)
{ {
f->m_comm = partComm; if(((priority == eCreateGraph)||(priority == eOutput)))
} {
else f->m_comm = partComm;
{ }
f->m_comm = defComm; else
{
f->m_comm = defComm;
}
} }
for (int i = 0; i < modules.size(); ++i) for (int i = 0; i < modules.size(); ++i)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment