Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 308b4157 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

use boost::filesystem to check if the file exists

parent 7e1f7e82
No related branches found
No related tags found
1 merge request!458Resolve "Check read of FROMFILE distribution"
......@@ -45,6 +45,7 @@
#include <sys/time.h>
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
......@@ -1001,28 +1002,25 @@ size_t Distribution::getNumberOfParticlesInFile(std::ifstream &inputFile) {
void Distribution::createDistributionFromFile(size_t /*numberOfParticles*/, double massIneV) {
*gmsg << level3 << "\n"
<< "------------------------------------------------------------------------------------\n";
*gmsg << "READ INITIAL DISTRIBUTION FROM FILE \""
<< Attributes::getString(itsAttr[Attrib::Distribution::FNAME])
<< "\"\n";
*gmsg << "------------------------------------------------------------------------------------\n" << endl;
// Data input file is only read by node 0.
std::ifstream inputFile;
std::string fileName = Attributes::getString(itsAttr[Attrib::Distribution::FNAME]);
bool failedOpen = 0;
if (Ippl::myNode() == 0) {
inputFile.open(fileName.c_str());
failedOpen = static_cast<bool>(inputFile.fail());
}
reduce(failedOpen,failedOpen,OpAddAssign());
if (failedOpen) {
if (!boost::filesystem::exists("fileName")) {
throw OpalException("Distribution::createDistributionFromFile",
"Open file operation failed, please check if \""
+ fileName
+ "\" really exists.");
+ fileName +
"\" really exists.");
}
if (Ippl::myNode() == 0) {
inputFile.open(fileName.c_str());
}
*gmsg << level3 << "\n"
<< "------------------------------------------------------------------------------------\n";
*gmsg << "READ INITIAL DISTRIBUTION FROM FILE \""
<< Attributes::getString(itsAttr[Attrib::Distribution::FNAME])
<< "\"\n";
*gmsg << "------------------------------------------------------------------------------------\n" << endl;
size_t numberOfParticlesRead = getNumberOfParticlesInFile(inputFile);
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment