Commit 93bfe5a8 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

particle output creates file if it doesn't exist

there was an implicit assumption that the file exists before.
parent 1e5b4b13
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <hdf5.h> #include <hdf5.h>
#include <sys/stat.h>
#include "abstract_particles_output.hpp" #include "abstract_particles_output.hpp"
#include "scope_timer.hpp" #include "scope_timer.hpp"
...@@ -140,10 +141,23 @@ public: ...@@ -140,10 +141,23 @@ public:
if(Parent::isInvolved()){ if(Parent::isInvolved()){
if (Parent::getMyRank() == 0) if (Parent::getMyRank() == 0)
{ {
hid_t file_id = H5Fopen( bool file_exists = false;
{
struct stat file_buffer;
file_exists = (stat(filename.c_str(), &file_buffer) == 0);
}
hid_t file_id;
if (file_exists)
file_id = H5Fopen(
filename.c_str(), filename.c_str(),
H5F_ACC_RDWR | H5F_ACC_DEBUG, H5F_ACC_RDWR | H5F_ACC_DEBUG,
H5P_DEFAULT); H5P_DEFAULT);
else
file_id = H5Fcreate(
filename.c_str(),
H5F_ACC_EXCL | H5F_ACC_DEBUG,
H5P_DEFAULT,
H5P_DEFAULT);
assert(file_id >= 0); assert(file_id >= 0);
bool group_exists = H5Lexists( bool group_exists = H5Lexists(
file_id, file_id,
......
Supports Markdown
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