Commit 8fc0a545 authored by BRAMAS Berenger's avatar BRAMAS Berenger

remove MPI loading file bug

parent 27bef454
......@@ -81,7 +81,7 @@ public:
MPI_Status status;
if( MPI_File_read(file, &sizeOfElement, 1, MPI_INT, &status) == MPI_SUCCESS
&& MPI_File_read(file, &this->totalNbParticles, 1, MPI_LONG_LONG, &status) == MPI_SUCCESS
&& MPI_File_read(file, xyzBoxWidth, 4, MPI_FLOAT, &status) == MPI_SUCCESS ){
&& MPI_File_read(file, xyzBoxWidth, 4, FMpi::GetType(xyzBoxWidth[0]), &status) == MPI_SUCCESS ){
FLOG(if(sizeOfElement != sizeof(FReal)){)
FLOG( FLog::Controller.writeFromLine("Warning type size between file and FReal are differents\n", __LINE__, __FILE__); )
......@@ -110,13 +110,7 @@ public:
// local number to read
particles = new FReal[bufsize];
if( sizeof(FReal) == sizeof(float) ){
MPI_File_read_at(file, headDataOffSet + startPart * 4 * sizeof(FReal), particles, int(bufsize), MPI_FLOAT, &status);
}
else{
MPI_File_read_at(file, headDataOffSet + startPart * 4 * sizeof(FReal), particles, int(bufsize), MPI_DOUBLE, &status);
}
MPI_File_read_at(file, headDataOffSet + startPart * 4 * sizeof(FReal), particles, int(bufsize), FMpi::GetType(xyzBoxWidth[0]), &status);
// check if needed
int count(0);
......@@ -142,7 +136,6 @@ public:
FLOG( FLog::Controller.writeFromLine("Warning type size between file and FReal are differents\n", __LINE__, __FILE__); )
FLOG(})
removeWarning += fread(&this->totalNbParticles, sizeof(FSize), 1, file);
removeWarning += fread(&this->boxWidth, sizeof(FReal), 1, file);
this->boxWidth *= 2;
......@@ -160,6 +153,7 @@ public:
if(filesize/4 != this->totalNbParticles){
printf("Error fileSize %ld, nbPart %lld\n", filesize/4, this->totalNbParticles);
exit(0);
}
// in number of floats
......@@ -172,7 +166,10 @@ public:
fseek(file, long(headDataOffSet + startPart * 4 * sizeof(FReal)), SEEK_SET);
removeWarning += fread(particles, sizeof(FReal), int(bufsize), file);
if( fread(particles, sizeof(FReal), int(bufsize), file) != unsigned(bufsize)){
printf("Error when reading file.\n");
exit(0);
}
fclose(file);
}
......@@ -226,6 +223,10 @@ public:
* @param the particle to fill
*/
void fillParticle(FPoint*const inParticlePositions, FReal*const inPhysicalValue){
if(nbParticles*4 <= idxParticles){
printf("Error you're loading too much particles.\n");
exit(0);
}
inParticlePositions->setPosition(particles[idxParticles],particles[idxParticles+1],particles[idxParticles+2]);
(*inPhysicalValue) = (particles[idxParticles+3]);
idxParticles += 4;
......
......@@ -327,6 +327,11 @@ int main(int argc, char ** argv){
return 1;
}
std::cout << "Simulation properties :\n";
std::cout << "Nb Particles " << loader.getNumberOfParticles() << "\n";
std::cout << "Box Width : " << loader.getBoxWidth() << "\n";
std::cout << "Box Center : " << loader.getCenterOfBox() << "\n";
// The real tree to work on
OctreeClass realTree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox());
......@@ -371,7 +376,8 @@ int main(int argc, char ** argv){
else{
FPoint position;
FReal physicalValue;
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
const FSize nbParticles = loader.getNumberOfParticles();
for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
loader.fillParticle(&position,&physicalValue);
realTree.insert(position);
}
......@@ -384,10 +390,16 @@ int main(int argc, char ** argv){
OctreeClass treeValide(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox());
{
FFmaBinLoader loaderSeq(filename);
std::cout << "Simulation properties :\n";
std::cout << "Nb Particles " << loaderSeq.getNumberOfParticles() << "\n";
std::cout << "Box Width : " << loaderSeq.getBoxWidth() << "\n";
std::cout << "Box Center : " << loaderSeq.getCenterOfBox() << "\n";
FPoint position;
FReal physicalValue;
for(FSize idxPart = 0 ; idxPart < loaderSeq.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(&position,&physicalValue);
loaderSeq.fillParticle(&position,&physicalValue);
treeValide.insert(position);
}
}
......
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