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

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
OutputFileBase::OutputFileBase(FieldSharedPtr f) : OutputModule(f)
{
m_requireEquiSpaced = false;
m_config["writemultiplefiles"] =
ConfigOption(true,"0","Write multiple files in parallel or when using nparts option");
}
OutputFileBase::~OutputFileBase()
......@@ -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
// to avoid checking files from other partitions
fs::path outFile;
if(vm.count("nprocs"))
if(vm.count("nparts"))
{
outFile = GetFullOutName(filename, vm);
}
......@@ -275,29 +277,28 @@ bool OutputFileBase::WriteFile(std::string &filename, po::variables_map &vm)
int writeFile = 1;
if (count && (vm.count("forceoutput") == 0))
{
writeFile = 0; // set to zero for reduce all to be correct.
if (comm->GetRank() == 0)
if(vm.count("nparts") == 0 ) // do not do check if --nparts is enabled.
{
string answer;
cout << "Did you wish to overwrite " << outFile << " (y/n)? ";
getline(cin, answer);
if (answer.compare("y") == 0)
{
writeFile = 1;
}
else
writeFile = 0; // set to zero for reduce all to be correct.
if (comm->TreatAsRankZero())
{
cout << "Not writing file " << filename
<< " because it already exists" << endl;
string answer;
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;
}
......
......@@ -59,8 +59,6 @@ OutputFld::OutputFld(FieldSharedPtr f) : OutputFileBase(f)
{
m_config["format"] = ConfigOption(
false, "Xml", "Output format of field file");
m_config["writemultiplefiles"] =
ConfigOption(true,"0","Write multiple files in parallel or using nparts option");
}
OutputFld::~OutputFld()
......
......@@ -75,14 +75,27 @@ OutputTecplot::OutputTecplot(FieldSharedPtr f) : OutputFileBase(f),
m_oneOutputFile(false)
{
m_requireEquiSpaced = true;
m_config["writemultiplefiles"] =
ConfigOption(true,"0","Write multiple files in parallel or when using nparts option");
}
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.
*/
......@@ -299,12 +312,12 @@ fs::path OutputTecplot::GetPath(std::string &filename,
po::variables_map &vm)
{
int nprocs = m_f->m_comm->GetSize();
int rank = m_f->m_comm->GetRank();
string returnstr(filename);
// Amend for parallel output if required
if (nprocs != 1 && !m_oneOutputFile)
{
int rank = m_f->m_comm->GetRank();
int dot = filename.find_last_of('.');
string ext = filename.substr(dot, filename.length() - dot);
string procId = "_P" + boost::lexical_cast<std::string>(rank);
......@@ -330,14 +343,6 @@ void OutputTecplot::WriteTecplotFile(po::variables_map &vm)
int nprocs = m_f->m_comm->GetSize();
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
string filename = m_config["outfile"].as<string>();
......
......@@ -71,6 +71,9 @@ public:
OutputTecplot(FieldSharedPtr f);
virtual ~OutputTecplot();
virtual void Process(po::variables_map &vm);
virtual std::string GetModuleName()
{
return "OutputTecplot";
......
......@@ -52,6 +52,7 @@ int main(int argc, char* argv[])
{
Timer timer;
timer.Start();
po::options_description desc("Available options");
desc.add_options()
("help,h",
......@@ -446,19 +447,21 @@ int main(int argc, char* argv[])
new FieldConvertComm(argc, argv, nParts,rank));
}
// Run field process.
for (int n = 0; n < SIZE_ModulePriority; ++n)
{
ModulePriority priority = static_cast<ModulePriority>(n);
if(((priority == eCreateGraph)||(priority == eOutput))&&(nParts > 1))
if(nParts > 1)
{
f->m_comm = partComm;
}
else
{
f->m_comm = defComm;
if(((priority == eCreateGraph)||(priority == eOutput)))
{
f->m_comm = partComm;
}
else
{
f->m_comm = defComm;
}
}
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