diff --git a/ChangeLog b/ChangeLog index 2b4ec9ab..30e59a60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ NEW the chi^2 calculation in single-histogram and asymmetry fits is parallelized if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2) Using --disable-omp this feature can be disabled on the configure level. NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML) +FIXED a linking problem when only shared libraries are built on Cygwin +FIXED the problem that in certain environments XML files could not be parsed (MUSR-122) FIXED crash of musrview in case the XML startup file is present but cannot be parsed correctly FIXED crash in case a non-existing userFcn is called from an existing library (MUSR-159) FIXED slightly wrong chisq since the 0-bin entries were treated wrongly for scaled N0/Bkg data (MUSR-193) diff --git a/src/any2many.cpp b/src/any2many.cpp index 78af4ccc..7aedf3ea 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -418,6 +418,9 @@ int main(int argc, char *argv[]) } // read startup file + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); @@ -436,7 +439,23 @@ int main(int argc, char *argv[]) } else { strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); saxParser->ConnectToHandler("PStartupHandler", startupHandler); - status = saxParser->ParseFile(startup_path_name); + //status = saxParser->ParseFile(startup_path_name); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + xmlFile.open(startup_path_name, ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << ">> any2many **WARNING** Reading/parsing musrfit_startup.xml failed."; diff --git a/src/classes/Makefile.am b/src/classes/Makefile.am index bbe2f248..cae0d613 100644 --- a/src/classes/Makefile.am +++ b/src/classes/Makefile.am @@ -89,7 +89,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core lib_LTLIBRARIES = libPMusr.la libPUserFcnBase.la libPMusr_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) -libPMusr_la_LIBADD = $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) +libPMusr_la_LIBADD = libPUserFcnBase.la $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) libPMusr_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS) libPUserFcnBase_la_SOURCES = $(h_sources_userFcn) $(cpp_sources_userFcn) $(dict_h_sources_userFcn) $(dict_cpp_sources_userFcn) diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index 23e129cf..0afae35e 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -419,12 +419,31 @@ int PMsr2Data::SetRunNumbers(const string &runListFile) */ int PMsr2Data::ParseXmlStartupFile() { + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; int status; fSaxParser = new TSAXParser(); fStartupHandler = new PStartupHandler(); string startup_path_name(fStartupHandler->GetStartupFilePath().Data()); fSaxParser->ConnectToHandler("PStartupHandler", fStartupHandler); - status = fSaxParser->ParseFile(startup_path_name.c_str()); + //status = fSaxParser->ParseFile(startup_path_name.c_str()); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = fSaxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << ">> msr2data: **WARNING** Reading/parsing musrfit_startup.xml failed." << endl; diff --git a/src/external/MagProximity/PMagProximityFitter.cpp b/src/external/MagProximity/PMagProximityFitter.cpp index b2acd2b1..bc64b1c0 100644 --- a/src/external/MagProximity/PMagProximityFitter.cpp +++ b/src/external/MagProximity/PMagProximityFitter.cpp @@ -33,6 +33,7 @@ #include #include +#include using namespace std; #include @@ -64,10 +65,30 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal() PMPStartupHandler *fStartupHandler = new PMPStartupHandler(); strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data()); saxParser->ConnectToHandler("PMPStartupHandler", fStartupHandler); - Int_t status = saxParser->ParseFile(startup_path_name); + //Int_t status = saxParser->ParseFile(startup_path_name); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name, ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + Int_t status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error - cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** reading/parsing mag_proximity_startup.xml."; + cout << endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** Reading/parsing mag_proximity_startup.xml failed."; cout << endl; fValid = false; } diff --git a/src/external/Nonlocal/PNL_PippardFitter.cpp b/src/external/Nonlocal/PNL_PippardFitter.cpp index e75701e7..335a631b 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.cpp +++ b/src/external/Nonlocal/PNL_PippardFitter.cpp @@ -33,6 +33,7 @@ #include #include +#include using namespace std; #include @@ -63,10 +64,30 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal() PNL_StartupHandler *fStartupHandler = new PNL_StartupHandler(); strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data()); saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler); - Int_t status = saxParser->ParseFile(startup_path_name); + //Int_t status = saxParser->ParseFile(startup_path_name); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name, ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + Int_t status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error - cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** reading/parsing nonlocal_startup.xml."; + cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed."; cout << endl; fValid = false; } diff --git a/src/external/libFitPofB/classes/TLondon1D.cpp b/src/external/libFitPofB/classes/TLondon1D.cpp index b53ca3c9..46c6d05c 100644 --- a/src/external/libFitPofB/classes/TLondon1D.cpp +++ b/src/external/libFitPofB/classes/TLondon1D.cpp @@ -30,6 +30,7 @@ #include "TLondon1D.h" #include +#include #include #include using namespace std; @@ -153,7 +154,27 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -301,7 +322,27 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -484,7 +525,27 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -654,7 +715,27 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -801,7 +882,27 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -970,7 +1071,27 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -1139,7 +1260,27 @@ double TLondon1D3LS::operator()(double t, const vector &par) const { // TSAXParser *saxParser = new TSAXParser(); // BMWStartupHandler *startupHandler = new BMWStartupHandler(); // saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); -// int status (saxParser->ParseFile(startup_path_name.c_str())); +// //int status (saxParser->ParseFile(startup_path_name.c_str())); +// // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows +// fstream xmlFile; +// unsigned int xmlSize = 0; +// char *xmlBuffer = 0; +// xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file +// if (xmlFile.is_open()) { // check if file has been opened successfully +// xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) +// xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream +// xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file +// xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer +// xmlFile.close(); // close the XML file +// } +// int status; +// if (!xmlBuffer) { // file has not been read into the buffer +// status = 1; +// } else { +// status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer +// delete[] xmlBuffer; // free the buffer memory +// xmlBuffer = 0; +// } // // check for parse errors // if (status) { // error // cout << endl << "**WARNING** Reading/parsing " << startup_path_name << " failed." << endl; diff --git a/src/external/libFitPofB/classes/TVortex.cpp b/src/external/libFitPofB/classes/TVortex.cpp index 79005f36..494df3a4 100644 --- a/src/external/libFitPofB/classes/TVortex.cpp +++ b/src/external/libFitPofB/classes/TVortex.cpp @@ -30,6 +30,7 @@ #include "TVortex.h" #include +#include #include #include using namespace std; @@ -165,7 +166,27 @@ TBulkTriVortexLondon::TBulkTriVortexLondon() : fCalcNeeded(true), fFirstCall(tru TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -222,7 +243,27 @@ TBulkSqVortexLondon::TBulkSqVortexLondon() : fCalcNeeded(true), fFirstCall(true) TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -449,7 +490,27 @@ TBulkTriVortexML::TBulkTriVortexML() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -585,7 +646,27 @@ TBulkTriVortexAGL::TBulkTriVortexAGL() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -720,7 +801,27 @@ TBulkTriVortexAGLII::TBulkTriVortexAGLII() : fCalcNeeded(true), fFirstCall(true) TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -868,7 +969,27 @@ TBulkTriVortexNGL::TBulkTriVortexNGL() : fCalcNeeded(true), fFirstCall(true) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -1020,7 +1141,27 @@ TBulkAnisotropicTriVortexLondonGlobal::TBulkAnisotropicTriVortexLondonGlobal() : TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -1259,7 +1400,27 @@ TBulkAnisotropicTriVortexMLGlobal::TBulkAnisotropicTriVortexMLGlobal() : fCalcNe TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -1498,7 +1659,27 @@ TBulkAnisotropicTriVortexAGLGlobal::TBulkAnisotropicTriVortexAGLGlobal() : fCalc TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ diff --git a/src/external/libLFRelaxation/TLFRelaxation.cpp b/src/external/libLFRelaxation/TLFRelaxation.cpp index 23d783d6..df13d06d 100644 --- a/src/external/libLFRelaxation/TLFRelaxation.cpp +++ b/src/external/libLFRelaxation/TLFRelaxation.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef HAVE_GOMP @@ -201,7 +202,27 @@ TLFDynGssKT::TLFDynGssKT() : fCalcNeeded(true), fFirstCall(true), fCounter(0) { TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ @@ -523,7 +544,27 @@ TLFDynExpKT::TLFDynExpKT() : fCalcNeeded(true), fFirstCall(true), fCounter(0), f TSAXParser *saxParser = new TSAXParser(); BMWStartupHandler *startupHandler = new BMWStartupHandler(); saxParser->ConnectToHandler("BMWStartupHandler", startupHandler); - int status (saxParser->ParseFile(startup_path_name.c_str())); + //int status (saxParser->ParseFile(startup_path_name.c_str())); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; + xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + int status; + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \ diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 1496285c..71025a6f 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -424,6 +424,9 @@ int main(int argc, char *argv[]) } // read startup file + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); @@ -442,7 +445,23 @@ int main(int argc, char *argv[]) } else { strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); saxParser->ConnectToHandler("PStartupHandler", startupHandler); - status = saxParser->ParseFile(startup_path_name); + //status = saxParser->ParseFile(startup_path_name); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + xmlFile.open(startup_path_name, ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << ">> musrfit **WARNING** Reading/parsing musrfit_startup.xml failed."; diff --git a/src/musrt0.cpp b/src/musrt0.cpp index f8e72b8c..49474da9 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -34,6 +34,7 @@ #include #include +#include using namespace std; #include @@ -275,6 +276,9 @@ Int_t main(Int_t argc, Char_t *argv[]) } // read startup file + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; Char_t startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); @@ -293,10 +297,26 @@ Int_t main(Int_t argc, Char_t *argv[]) } else { strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); saxParser->ConnectToHandler("PStartupHandler", startupHandler); - status = saxParser->ParseFile(startup_path_name); + //status = saxParser->ParseFile(startup_path_name); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + xmlFile.open(startup_path_name, ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error - cerr << endl << ">> musrt0 **WARNING** reading/parsing musrfit_startup.xml."; + cerr << endl << ">> musrt0 **WARNING** Reading/parsing musrfit_startup.xml failed."; cerr << endl; // clean up if (saxParser) { diff --git a/src/musrview.cpp b/src/musrview.cpp index 0ea5bc14..40f61ee9 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -34,6 +34,7 @@ #include #include +#include using namespace std; #include @@ -158,6 +159,9 @@ int main(int argc, char *argv[]) } // read startup file + fstream xmlFile; + unsigned int xmlSize = 0; + char *xmlBuffer = 0; char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); @@ -176,7 +180,23 @@ int main(int argc, char *argv[]) } else { strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); saxParser->ConnectToHandler("PStartupHandler", startupHandler); - status = saxParser->ParseFile(startup_path_name); + //status = saxParser->ParseFile(startup_path_name); + // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows + xmlFile.open(startup_path_name, ios::in | ios::ate); // open file for reading and go to the end of the file + if (xmlFile.is_open()) { // check if file has been opened successfully + xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end) + xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream + xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file + xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer + xmlFile.close(); // close the XML file + } + if (!xmlBuffer) { // file has not been read into the buffer + status = 1; + } else { + status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer + delete[] xmlBuffer; // free the buffer memory + xmlBuffer = 0; + } // check for parse errors if (status) { // error cerr << endl << ">> musrview **WARNING** Reading/parsing musrfit_startup.xml failed.";