Commit f1c33991 authored by Burlen Loring's avatar Burlen Loring

Merge branch 'bug_fixes_from_warp_vtkm' into 'master'

bug fixes from warp vtkm

See merge request !149
parents c0c2ece8 b51c370b
......@@ -54,7 +54,6 @@ using AnalysisAdaptorVector = std::vector<AnalysisAdaptorPtr>;
namespace sensei
{
static
int requireAttribute(pugi::xml_node &node, const char *attributeName)
{
......@@ -69,9 +68,12 @@ int requireAttribute(pugi::xml_node &node, const char *attributeName)
// --------------------------------------------------------------------------
static int parse(MPI_Comm comm, int rank,
const std::string &filename, pugi::xml_document &doc)
static int parse(MPI_Comm comm, const std::string &filename,
pugi::xml_document &doc)
{
int rank = 0;
MPI_Comm_rank(comm, &rank);
unsigned long nbytes = 0;
char *buffer = nullptr;
if(rank == 0)
......@@ -921,18 +923,14 @@ int ConfigurableAnalysis::Initialize(const std::string& filename)
{
timer::MarkEvent event("ConfigurableAnalysis::Initialize");
int rank = 0;
MPI_Comm_rank(this->GetCommunicator(), &rank);
pugi::xml_document doc;
if (parse(this->GetCommunicator(), rank, filename, doc))
if (parse(this->GetCommunicator(), filename, doc))
{
if (rank == 0)
SENSEI_ERROR("failed to parse configuration")
SENSEI_ERROR("Failed to load, parse, and share XML configuration")
MPI_Abort(this->GetCommunicator(), -1);
return -1;
}
int rv = 0;
pugi::xml_node root = doc.child("sensei");
for (pugi::xml_node node = root.child("analysis");
......@@ -954,13 +952,12 @@ int ConfigurableAnalysis::Initialize(const std::string& filename)
|| ((type == "cdf") && !this->Internals->AddVTKmCDF(node))
|| ((type == "python") && !this->Internals->AddPythonAnalysis(node))))
{
if (rank == 0)
SENSEI_ERROR("Failed to add '" << type << "' analysis")
rv -= 1;
SENSEI_ERROR("Failed to add '" << type << "' analysis")
MPI_Abort(this->GetCommunicator(), -1);
}
}
return rv;
return 0;
}
//----------------------------------------------------------------------------
......@@ -968,10 +965,6 @@ bool ConfigurableAnalysis::Execute(DataAdaptor* data)
{
timer::MarkEvent event("ConfigurableAnalysis::Execute");
int rank = 0;
MPI_Comm_rank(this->GetCommunicator(), &rank);
int rv = 0;
int ai = 0;
AnalysisAdaptorVector::iterator iter = this->Internals->Analyses.begin();
AnalysisAdaptorVector::iterator end = this->Internals->Analyses.end();
......@@ -987,16 +980,15 @@ bool ConfigurableAnalysis::Execute(DataAdaptor* data)
if (!(*iter)->Execute(data))
{
if (rank == 0)
SENSEI_ERROR("Failed to execute " << (*iter)->GetClassName())
rv -= 1;
SENSEI_ERROR("Failed to execute " << (*iter)->GetClassName())
MPI_Abort(this->GetCommunicator(), -1);
}
if (logEnabled)
timer::MarkEndEvent(analysisName);
}
return rv < 0 ? false : true;
return true;
}
//----------------------------------------------------------------------------
......@@ -1004,10 +996,6 @@ int ConfigurableAnalysis::Finalize()
{
timer::MarkEvent event("ConfigurableAnalysis::Finalize");
int rank = 0;
MPI_Comm_rank(this->GetCommunicator(), &rank);
int rv = 0;
int ai = 0;
AnalysisAdaptorVector::iterator iter = this->Internals->Analyses.begin();
AnalysisAdaptorVector::iterator end = this->Internals->Analyses.end();
......@@ -1024,14 +1012,14 @@ int ConfigurableAnalysis::Finalize()
if ((*iter)->Finalize())
{
SENSEI_ERROR("Failed to finalize " << (*iter)->GetClassName())
rv -= 1;
MPI_Abort(this->GetCommunicator(), -1);
}
if (logEnabled)
timer::MarkEndEvent(analysisName);
}
return rv;
return 0;
}
//----------------------------------------------------------------------------
......
......@@ -250,13 +250,19 @@ MeshRequirementsIterator DataRequirements::GetMeshRequirementsIterator() const
ArrayRequirementsIterator DataRequirements::GetArrayRequirementsIterator(
const std::string &meshName) const
{
MeshArrayMapType::const_iterator it = this->MeshArrayMap.find(meshName);
if (it != this->MeshArrayMap.end())
if (this->MeshNames.find(meshName) == this->MeshNames.end())
{
SENSEI_ERROR("No mesh named \"" << meshName << "\"")
}
else
{
ArrayRequirementsIterator ait(it->second);
return ait;
MeshArrayMapType::const_iterator it = this->MeshArrayMap.find(meshName);
if (it != this->MeshArrayMap.end())
{
ArrayRequirementsIterator ait(it->second);
return ait;
}
}
SENSEI_ERROR("No mesh named \"" << meshName << "\"")
return ArrayRequirementsIterator();
}
......
......@@ -27,6 +27,10 @@
#include <fstream>
#include <cassert>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <vtkAlgorithm.h>
#include <vtkCompositeDataPipeline.h>
#include <vtkXMLDataSetWriter.h>
......@@ -102,6 +106,22 @@ VTKPosthocIO::~VTKPosthocIO()
//-----------------------------------------------------------------------------
int VTKPosthocIO::SetOutputDir(const std::string &outputDir)
{
int rank = 0;
MPI_Comm_rank(this->GetCommunicator(), &rank);
// rank 0 ensures that directory is present
if (rank == 0)
{
int ierr = mkdir(outputDir.c_str(), S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
if (ierr && (errno != EEXIST))
{
const char *estr = strerror(errno);
SENSEI_ERROR("Directory \"" << outputDir
<< "\" does not exist and we could not create it. " << estr)
return -1;
}
}
this->OutputDir = outputDir;
return 0;
}
......@@ -109,8 +129,7 @@ int VTKPosthocIO::SetOutputDir(const std::string &outputDir)
//-----------------------------------------------------------------------------
int VTKPosthocIO::SetMode(int mode)
{
if (!(mode == VTKPosthocIO::MODE_VISIT) ||
(mode == VTKPosthocIO::MODE_PARAVIEW))
if ((mode != VTKPosthocIO::MODE_VISIT) && (mode != VTKPosthocIO::MODE_PARAVIEW))
{
SENSEI_ERROR("Invalid mode " << mode)
return -1;
......@@ -281,16 +300,19 @@ bool VTKPosthocIO::Execute(DataAdaptor* dataAdaptor)
ArrayRequirementsIterator ait =
this->Requirements.GetArrayRequirementsIterator(meshName);
for (; ait; ++ait)
if (ait)
{
if (dataAdaptor->AddArray(dobj, mit.MeshName(),
ait.Association(), ait.Array()))
for (; ait; ++ait)
{
SENSEI_ERROR("Failed to add "
<< VTKUtils::GetAttributesName(ait.Association())
<< " data array \"" << ait.Array() << "\" to mesh \""
<< meshName << "\"")
return false;
if (dataAdaptor->AddArray(dobj, mit.MeshName(),
ait.Association(), ait.Array()))
{
SENSEI_ERROR("Failed to add "
<< VTKUtils::GetAttributesName(ait.Association())
<< " data array \"" << ait.Array() << "\" to mesh \""
<< meshName << "\"")
return false;
}
}
}
......
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