Commit b3ca86b8 authored by Andrew Bauer's avatar Andrew Bauer Committed by Kitware Robot

Merge topic 'exoduswriter_parallel_naming'

177f37d8 Padding filenames for ExodusII writer based on number of processes
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Cory Quammen's avatarCory Quammen <cory.quammen@kitware.com>
Merge-request: !2119
parents 9b98ff33 177f37d8
Pipeline #33303 running with stage
in 0 seconds
......@@ -49,12 +49,23 @@
#include <cctype>
#include <map>
#include <ctime>
#include <sstream>
vtkObjectFactoryNewMacro (vtkExodusIIWriter);
vtkCxxSetObjectMacro (vtkExodusIIWriter, ModelMetadata, vtkModelMetadata);
namespace
{
unsigned int GetNumberOfDigits(unsigned int i)
{
if (i<10)
{
return 1;
}
return GetNumberOfDigits(i/10)+1;
}
}
//----------------------------------------------------------------------------
vtkExodusIIWriter::vtkExodusIIWriter ()
......@@ -595,24 +606,25 @@ int vtkExodusIIWriter::CreateNewExodusFile()
}
else
{
char *myFileName = new char [VTK_MAXPATH];
if (this->CurrentTimeIndex == 0)
{
sprintf(myFileName, "%s.%d.%d", this->FileName, this->NumberOfProcesses, this->MyRank);
}
else
std::ostringstream myFileName;
myFileName << this->FileName << ".";
if (this->CurrentTimeIndex != 0)
{
sprintf(myFileName, "%s_%06d.%d.%d",
this->FileName, this->CurrentTimeIndex, this->NumberOfProcesses, this->MyRank);
myFileName << "_" << std::setfill('0') << std::setw(6) <<
this->CurrentTimeIndex << std::setw(0) << ".";
}
this->fid = ex_create(myFileName, EX_CLOBBER, &compWordSize, &IOWordSize);
unsigned int numDigits = GetNumberOfDigits(
static_cast<unsigned int>(this->NumberOfProcesses-1));
myFileName << this->NumberOfProcesses << "." << std::setfill('0')
<< std::setw(numDigits) << this->MyRank;
this->fid = ex_create(myFileName.str().c_str(), EX_CLOBBER,
&compWordSize, &IOWordSize);
if (fid <= 0)
{
vtkErrorMacro (
<< "vtkExodusIIWriter: CreateNewExodusFile can't create "
<< myFileName);
<< myFileName.str());
}
delete [] myFileName;
}
// FileTimeOffset makes the time in the file relative
......
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