Commit 317d6f81 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

cosmetic changes to comments

parent 3249266f
...@@ -182,17 +182,17 @@ public: ...@@ -182,17 +182,17 @@ public:
} }
else if (xmlStrcmp(currNode->name, (xmlChar*)"Function") == 0) { else if (xmlStrcmp(currNode->name, (xmlChar*)"Function") == 0) {
// function handling goes here // Function handling goes here
xmlNodePtr childNode = currNode->children; xmlNodePtr childNode = currNode->children;
std::string arraySubType = ""; std::string arraySubType = "";
// get Array Subtype, if any // Gget Array Subtype, if any
xmlAttrPtr currAttribute = currNode->properties; xmlAttrPtr currAttribute = currNode->properties;
while (currAttribute != NULL) { while (currAttribute != NULL) {
if (xmlStrcmp(currAttribute->name, (xmlChar*)"Type") == 0 ) { if (xmlStrcmp(currAttribute->name, (xmlChar*)"Type") == 0 ) {
arraySubType = (char*)currAttribute->children->content; arraySubType = (char*)currAttribute->children->content;
break; break;
// uses the first type found // Uses the first type found
} }
} }
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
while (childNode != NULL) { while (childNode != NULL) {
if (xmlStrcmp(childNode->name, (xmlChar*)"Expression") == 0){ if (xmlStrcmp(childNode->name, (xmlChar*)"Expression") == 0){
// store expression // Store expression
xmlAttrPtr childAttribute = childNode->properties; xmlAttrPtr childAttribute = childNode->properties;
while (childAttribute != NULL) { while (childAttribute != NULL) {
if(xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) { if(xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) {
...@@ -224,13 +224,13 @@ public: ...@@ -224,13 +224,13 @@ public:
} }
} }
// two seperate loops to allow for different orders and multiple variable sets // Two seperate loops to allow for different orders and multiple variable sets
childNode = currNode->children; childNode = currNode->children;
std::map<std::string, shared_ptr<XdmfArray> > variableCollection; std::map<std::string, shared_ptr<XdmfArray> > variableCollection;
while (childNode != NULL) { while (childNode != NULL) {
if (xmlStrcmp(childNode->name, (xmlChar*)"Variable") == 0) { if (xmlStrcmp(childNode->name, (xmlChar*)"Variable") == 0) {
// store child variables // Store child variables
xmlNodePtr childVariable = childNode->children; xmlNodePtr childVariable = childNode->children;
while (childVariable != NULL) { while (childVariable != NULL) {
...@@ -246,31 +246,31 @@ public: ...@@ -246,31 +246,31 @@ public:
std::map<std::string, std::string> typeMap; std::map<std::string, std::string> typeMap;
while (childAttribute != NULL) { while (childAttribute != NULL) {
// the variable type of the array // The variable type of the array
if (xmlStrcmp(childAttribute->name, (xmlChar*)"DataType") == 0) { if (xmlStrcmp(childAttribute->name, (xmlChar*)"DataType") == 0) {
typeMap["DataType"] = (char*)childAttribute->children->content; typeMap["DataType"] = (char*)childAttribute->children->content;
} }
// the precision of the variable type (only used for long and double) // The precision of the variable type (only used for long and double)
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Precision") == 0) { else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Precision") == 0) {
typeMap["Precision"] = (char*)childAttribute->children->content; typeMap["Precision"] = (char*)childAttribute->children->content;
} }
// the key or mapped string for the variable // The key or mapped string for the variable
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Key") == 0) { else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Key") == 0) {
childKey = (char*)childAttribute->children->content; childKey = (char*)childAttribute->children->content;
} }
// text based xml data // Text based xml data
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) { else if (xmlStrcmp(childAttribute->name, (xmlChar*)"Value") == 0) {
dataString = (char*)childAttribute->children->content; dataString = (char*)childAttribute->children->content;
} }
// an x pointer to another XdmfArray // An x pointer to another XdmfArray
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"XPointer") == 0) { else if (xmlStrcmp(childAttribute->name, (xmlChar*)"XPointer") == 0) {
childXPointer = childAttribute->children->content; childXPointer = childAttribute->children->content;
} }
// used in conjunction with Xpointers to reference objects in a different file // Used in conjunction with Xpointers to reference objects in a different file
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"href") == 0) { else if (xmlStrcmp(childAttribute->name, (xmlChar*)"href") == 0) {
childhref = childAttribute->children->content; childhref = childAttribute->children->content;
} }
// path to hdf5 data sets and the dimensions of those sets // Path to hdf5 data sets and the dimensions of those sets
else if (xmlStrcmp(childAttribute->name, (xmlChar*)"hdf5") == 0) { else if (xmlStrcmp(childAttribute->name, (xmlChar*)"hdf5") == 0) {
childhdf5 = (char*)childAttribute->children->content; childhdf5 = (char*)childAttribute->children->content;
} }
...@@ -315,7 +315,7 @@ public: ...@@ -315,7 +315,7 @@ public:
dataType = XdmfArrayType::Uninitialized(); dataType = XdmfArrayType::Uninitialized();
} }
// if xpointer grab item at that location // If xpointer grab item at that location
if (childXPointer) { if (childXPointer) {
xmlXPathContextPtr context = mXPathContext; xmlXPathContextPtr context = mXPathContext;
...@@ -338,18 +338,18 @@ public: ...@@ -338,18 +338,18 @@ public:
xmlXPathObjectPtr result = xmlXPtrEval(childXPointer, context); xmlXPathObjectPtr result = xmlXPtrEval(childXPointer, context);
if(result && !xmlXPathNodeSetIsEmpty(result->nodesetval)) { if(result && !xmlXPathNodeSetIsEmpty(result->nodesetval)) {
for(int i=0; i<result->nodesetval->nodeNr; ++i) { for(int i=0; i<result->nodesetval->nodeNr; ++i) {
// there should only be one item being returned here // There should only be one item being returned here
// place into a new vector // Place into a new vector
std::vector<shared_ptr<XdmfItem> > pointedItems; std::vector<shared_ptr<XdmfItem> > pointedItems;
this->readSingleNode(result->nodesetval->nodeTab[i], pointedItems); this->readSingleNode(result->nodesetval->nodeTab[i], pointedItems);
try { try {
// try to cast it as an array // Try to cast it as an array
childArray = shared_dynamic_cast<XdmfArray>(pointedItems[0]); childArray = shared_dynamic_cast<XdmfArray>(pointedItems[0]);
} }
catch (...) { catch (...) {
// if that doesn't work throw an error // If that doesn't work throw an error
try { try {
// because we should only be working with arrays // Because we should only be working with arrays
XdmfError::message(XdmfError::FATAL, XdmfError::message(XdmfError::FATAL,
"Error: Variable not Equivalent to an Array"); "Error: Variable not Equivalent to an Array");
} }
...@@ -366,11 +366,11 @@ public: ...@@ -366,11 +366,11 @@ public:
xmlXPathFreeContext(context); xmlXPathFreeContext(context);
} }
} }
// if hdf5 create controllers and attach it // If hdf5 create controllers and attach it
else if (childhdf5.compare("") != 0) { else if (childhdf5.compare("") != 0) {
// parse the hdf5 controllers // Parse the hdf5 controllers
std::vector<std::string> controllerParts; std::vector<std::string> controllerParts;
// split the content based on "|" characters // Split the content based on "|" characters
size_t barSplit = 0; size_t barSplit = 0;
std::string splitString(childhdf5); std::string splitString(childhdf5);
std::string subcontent; std::string subcontent;
...@@ -389,7 +389,7 @@ public: ...@@ -389,7 +389,7 @@ public:
controllerParts.push_back(subcontent); controllerParts.push_back(subcontent);
} }
// insert those controllers into the childArray // Insert those controllers into the childArray
int hdf5step = 2; int hdf5step = 2;
for (unsigned int i = 0; i < controllerParts.size(); i = i + hdf5step) { for (unsigned int i = 0; i < controllerParts.size(); i = i + hdf5step) {
size_t colonLocation = controllerParts[i].find(":"); size_t colonLocation = controllerParts[i].find(":");
...@@ -410,18 +410,18 @@ public: ...@@ -410,18 +410,18 @@ public:
std::vector<unsigned int> contentDims; std::vector<unsigned int> contentDims;
if (i + 1 < controllerParts.size()){ if (i + 1 < controllerParts.size()){
// this is the string that contains the dimensions // This is the string that contains the dimensions
boost::tokenizer<> dimtokens(controllerParts[i + 1]); boost::tokenizer<> dimtokens(controllerParts[i + 1]);
for(boost::tokenizer<>::const_iterator iter = dimtokens.begin(); for(boost::tokenizer<>::const_iterator iter = dimtokens.begin();
iter != dimtokens.end(); iter != dimtokens.end();
++iter) { ++iter) {
contentDims.push_back(atoi((*iter).c_str())); contentDims.push_back(atoi((*iter).c_str()));
} }
hdf5step = 2;// if this works then the dimension content should be skipped over hdf5step = 2;// If this works then the dimension content should be skipped over
} }
else { else {
// if it fails then it means that the next content is not a dimension string // If it fails then it means that the next content is not a dimension string
// in this case an error should be thrown, formatting error // In this case an error should be thrown, formatting error
// because there is no base array to pull dimensions from // because there is no base array to pull dimensions from
try { try {
XdmfError::message(XdmfError::FATAL, XdmfError::message(XdmfError::FATAL,
...@@ -441,9 +441,9 @@ public: ...@@ -441,9 +441,9 @@ public:
contentDims)); contentDims));
} }
} }
// if xml parse strait to insert // If xml parse strait to insert
else if (dataString.compare("") != 0) { else if (dataString.compare("") != 0) {
// parse the data into tokens // Parse the data into tokens
childArray->initialize(dataType, 0); childArray->initialize(dataType, 0);
unsigned int index = 0; unsigned int index = 0;
boost::char_separator<char> sep(" \t\n"); boost::char_separator<char> sep(" \t\n");
...@@ -453,7 +453,7 @@ public: ...@@ -453,7 +453,7 @@ public:
iter = tokens.begin(); iter = tokens.begin();
iter != tokens.end(); iter != tokens.end();
++iter, ++index) { ++iter, ++index) {
// insert those tokens into the childArray // Insert those tokens into the childArray
childArray->insert(index, *iter); childArray->insert(index, *iter);
} }
} }
...@@ -462,13 +462,13 @@ public: ...@@ -462,13 +462,13 @@ public:
iter = tokens.begin(); iter = tokens.begin();
iter != tokens.end(); iter != tokens.end();
++iter, ++index) { ++iter, ++index) {
// insert those tokens into the childArray // Insert those tokens into the childArray
childArray->insert(index, atof((*iter).c_str())); childArray->insert(index, atof((*iter).c_str()));
} }
} }
} }
// parse the value into the array // Parse the value into the array
if (childKey.compare("") != 0){ if (childKey.compare("") != 0){
if (variableCollection.find(childKey) != variableCollection.end()) { if (variableCollection.find(childKey) != variableCollection.end()) {
try { try {
...@@ -504,25 +504,25 @@ public: ...@@ -504,25 +504,25 @@ public:
catch (XdmfError e) { catch (XdmfError e) {
throw e; throw e;
} }
// the properties and children aren't really needed to generate the object, but the factory still requires them. // The properties and children aren't really needed to generate the object, but the factory still requires them.
std::map<std::string, std::string> newArrayProperties; std::map<std::string, std::string> newArrayProperties;
std::vector<shared_ptr<XdmfItem> > newArrayChildren; std::vector<shared_ptr<XdmfItem> > newArrayChildren;
shared_ptr<XdmfArray> returnArray = XdmfArray::New(); shared_ptr<XdmfArray> returnArray = XdmfArray::New();
if (arraySubType.compare("") == 0) { if (arraySubType.compare("") == 0) {
// if no type is specified an array is generated // If no type is specified an array is generated
arraySubType = "DataItem"; arraySubType = "DataItem";
} }
// this should generate an item that corresponds to the tag provided, the casting ensures that it is a subtype of array // This should generate an item that corresponds to the tag provided, the casting ensures that it is a subtype of array
// using a factory to be able to build things outside of core // Using a factory to be able to build things outside of core
returnArray = shared_dynamic_cast<XdmfArray>(mItemFactory->createItem( returnArray = shared_dynamic_cast<XdmfArray>(mItemFactory->createItem(
arraySubType, arraySubType,
newArrayProperties, newArrayProperties,
newArrayChildren)); newArrayChildren));
if (!returnArray) { if (!returnArray) {
// if the specified tag fails to generate an item then reclass as an array // If the specified tag fails to generate an item then reclass as an array
arraySubType = "DataItem"; arraySubType = "DataItem";
returnArray = shared_dynamic_cast<XdmfArray>(mItemFactory->createItem( returnArray = shared_dynamic_cast<XdmfArray>(mItemFactory->createItem(
arraySubType, arraySubType,
...@@ -557,15 +557,15 @@ public: ...@@ -557,15 +557,15 @@ public:
readSingleNode(const xmlNodePtr currNode, readSingleNode(const xmlNodePtr currNode,
std::vector<shared_ptr<XdmfItem> > & myItems) std::vector<shared_ptr<XdmfItem> > & myItems)
{ {
// check to see if the node is already in the Xpath // Check to see if the node is already in the Xpath
std::map<xmlNodePtr, shared_ptr<XdmfItem> >::const_iterator iter = std::map<xmlNodePtr, shared_ptr<XdmfItem> >::const_iterator iter =
mXPathMap.find(currNode); mXPathMap.find(currNode);
// if it is grab it from the previously stored items // If it is grab it from the previously stored items
if(iter != mXPathMap.end()) { if(iter != mXPathMap.end()) {
myItems.push_back(iter->second); myItems.push_back(iter->second);
} }
else { else {
// otherwise, generate it from the node // Otherwise, generate it from the node
std::map<std::string, std::string> itemProperties; std::map<std::string, std::string> itemProperties;
xmlNodePtr childNode = currNode->children; xmlNodePtr childNode = currNode->children;
...@@ -575,13 +575,13 @@ public: ...@@ -575,13 +575,13 @@ public:
if(childNode->type == XML_TEXT_NODE && childNode->content) { if(childNode->type == XML_TEXT_NODE && childNode->content) {
const char * content = (char*)childNode->content; const char * content = (char*)childNode->content;
// determine if content is whitespace // Determine if content is whitespace
bool whitespace = true; bool whitespace = true;
const char * contentPtr = content; const char * contentPtr = content;
// step through to end of pointer // Step through to end of pointer
while(contentPtr != NULL) { while(contentPtr != NULL) {
// if not a whitespace character, break // If not a whitespace character, break
if(!isspace(*contentPtr++)) { if(!isspace(*contentPtr++)) {
whitespace = false; whitespace = false;
break; break;
...@@ -593,7 +593,7 @@ public: ...@@ -593,7 +593,7 @@ public:
itemProperties.insert(std::make_pair("XMLDir", mXMLDir)); itemProperties.insert(std::make_pair("XMLDir", mXMLDir));
} }
// split the content based on "|" characters // Split the content based on "|" characters
size_t barSplit = 0; size_t barSplit = 0;
std::string splitString(content); std::string splitString(content);
std::string subcontent; std::string subcontent;
......
This diff is collapsed.
...@@ -58,348 +58,287 @@ ...@@ -58,348 +58,287 @@
XdmfDSMCommMPI::XdmfDSMCommMPI() XdmfDSMCommMPI::XdmfDSMCommMPI()
{ {
IntraComm = MPI_COMM_NULL; IntraComm = MPI_COMM_NULL;
Id = -1; Id = -1;
IntraSize = -1; IntraSize = -1;
InterComm = MPI_COMM_NULL; InterComm = MPI_COMM_NULL;
InterSize = -1; InterSize = -1;
SetDsmMasterHostName(""); SetDsmMasterHostName("");
InterCommType = XDMF_DSM_COMM_MPI; InterCommType = XDMF_DSM_COMM_MPI;
} }
XdmfDSMCommMPI::~XdmfDSMCommMPI() XdmfDSMCommMPI::~XdmfDSMCommMPI()
{ {
if (InterComm != MPI_COMM_NULL) if (InterComm != MPI_COMM_NULL) {
{ int status = MPI_Comm_free(&InterComm);
int status = MPI_Comm_free(&InterComm); if (status != MPI_SUCCESS) {
if (status != MPI_SUCCESS) try {
{ XdmfError::message(XdmfError::FATAL, "Failed to free intercomm Comm");
try }
{ catch (XdmfError e) {
XdmfError::message(XdmfError::FATAL, "Failed to free intercomm Comm"); throw e;
} }
catch (XdmfError e) }
{ }
throw e; if (IntraComm != MPI_COMM_NULL) {
} int status = MPI_Comm_free(&IntraComm);
} if (status != MPI_SUCCESS) {
} try {
if (IntraComm != MPI_COMM_NULL) XdmfError::message(XdmfError::FATAL, "Failed to free intercomm Comm");
{ }
int status = MPI_Comm_free(&IntraComm); catch (XdmfError e) {
if (status != MPI_SUCCESS) throw e;
{ }
try }
{ }
XdmfError::message(XdmfError::FATAL, "Failed to free intercomm Comm");
}
catch (XdmfError e)
{
throw e;
}
}
}
} }
void void
XdmfDSMCommMPI::SetDsmMasterHostName(const char *hostName) XdmfDSMCommMPI::SetDsmMasterHostName(const char *hostName)
{ {
strcpy(DsmMasterHostName, hostName); strcpy(DsmMasterHostName, hostName);
} }
char * char *
XdmfDSMCommMPI::GetDsmMasterHostName() XdmfDSMCommMPI::GetDsmMasterHostName()
{ {
return DsmMasterHostName; return DsmMasterHostName;
} }
int int
XdmfDSMCommMPI::GetId() XdmfDSMCommMPI::GetId()
{ {
return this->Id; return this->Id;
} }
int int
XdmfDSMCommMPI::GetIntraSize() XdmfDSMCommMPI::GetIntraSize()
{ {
return this->IntraSize; return this->IntraSize;
} }
int int
XdmfDSMCommMPI::GetInterSize() XdmfDSMCommMPI::GetInterSize()
{ {
return this->InterSize; return this->InterSize;
} }
int int
XdmfDSMCommMPI::GetInterCommType() XdmfDSMCommMPI::GetInterCommType()
{ {
return this->InterCommType; return this->InterCommType;
} }
void void
XdmfDSMCommMPI::Init() XdmfDSMCommMPI::Init()
{ {
int size, rank; int size, rank;
if (MPI_Comm_size(this->IntraComm, &size) != MPI_SUCCESS) if (MPI_Comm_size(this->IntraComm, &size) != MPI_SUCCESS) {
{ try {
try XdmfError::message(XdmfError::FATAL, "Failed to initialize size");
{ }
XdmfError::message(XdmfError::FATAL, "Failed to initialize size"); catch (XdmfError e) {
} throw e;
catch (XdmfError e) }
{ }
throw e; if (MPI_Comm_rank(this->IntraComm, &rank) != MPI_SUCCESS) {
} try {
} XdmfError::message(XdmfError::FATAL, "Failed to initialize rank");
if (MPI_Comm_rank(this->IntraComm, &rank) != MPI_SUCCESS) }
{ catch (XdmfError e) {
try throw e;
{ }
XdmfError::message(XdmfError::FATAL, "Failed to initialize rank"); }
}
catch (XdmfError e)
{
throw e;
}
}
this->Id = rank; this->Id = rank;
this->IntraSize = size; this->IntraSize = size;
} }
//possibly use setenv/unsetenv/getenv to pass dsm port
//http://linux.die.net/man/3/setenv
void void
XdmfDSMCommMPI::OpenPort() XdmfDSMCommMPI::OpenPort()
{ {
if (Id == 0) if (Id == 0) {
{ int status = MPI_Open_port(MPI_INFO_NULL, DsmMasterHostName);
int status = MPI_Open_port(MPI_INFO_NULL, DsmMasterHostName);