11/* *
2- * Copyright 2013-2016 Felix Schmitt, Axel Huebl, Alexander Grund
2+ * Copyright 2013-2015 Felix Schmitt, Axel Huebl
33 *
44 * This file is part of libSplash.
55 *
3535#include " splash/core/DCAttribute.hpp"
3636#include " splash/core/DCDataSet.hpp"
3737#include " splash/core/DCGroup.hpp"
38+ #include " splash/core/DCHelper.hpp"
3839#include " splash/core/SDCHelper.hpp"
3940#include " splash/core/logging.hpp"
4041#include " splash/basetypes/basetypes.hpp"
@@ -69,18 +70,8 @@ namespace splash
6970 return (stat (filename.c_str (), &fileInfo) == 0 );
7071 }
7172
72- std::string SerialDataCollector::getFullFilename (const Dimensions mpiPos, std::string baseFilename,
73- bool isFullNameAllowed) const throw (DCException)
73+ std::string SerialDataCollector::getFullFilename (const Dimensions mpiPos, std::string baseFilename) const
7474 {
75- // Check for existing extension
76- if (baseFilename.find (" .h5" ) == baseFilename.length () - 3 )
77- {
78- if (isFullNameAllowed)
79- return baseFilename;
80- else
81- throw DCException (" Full filename is not allowed!" );
82- }
83-
8475 std::stringstream serial_filename;
8576 serial_filename << baseFilename << " _" << mpiPos[0 ] << " _" << mpiPos[1 ] <<
8677 " _" << mpiPos[2 ] << " .h5" ;
@@ -106,7 +97,7 @@ namespace splash
10697 *******************************************************************************/
10798
10899 SerialDataCollector::SerialDataCollector (uint32_t maxFileHandles) :
109- handles (maxFileHandles, HandleMgr::FNS_FULLNAME ),
100+ handles (maxFileHandles, HandleMgr::FNS_MPI ),
110101 fileStatus (FST_CLOSED),
111102 maxID (-1 ),
112103 mpiTopology (1 , 1 , 1 )
@@ -122,7 +113,7 @@ namespace splash
122113 " failed to initialize/open HDF5 library" ));
123114
124115#ifndef SPLASH_VERBOSE_HDF5
125- // Suppress automatic output of HDF5 exception messages
116+ // surpress automatic output of HDF5 exception messages
126117 if (H5Eset_auto2 (H5E_DEFAULT, NULL , NULL ) < 0 )
127118 throw DCException (getExceptionString (" SerialDataCollector" ,
128119 " failed to disable error printing" ));
@@ -134,7 +125,6 @@ namespace splash
134125
135126 SerialDataCollector::~SerialDataCollector ()
136127 {
137- close ();
138128 }
139129
140130 void SerialDataCollector::open (const char * filename, FileCreationAttr &attr)
@@ -167,19 +157,16 @@ namespace splash
167157
168158 void SerialDataCollector::close ()
169159 {
170- if (fileStatus == FST_CLOSED)
171- return ;
172-
173160 log_msg (1 , " closing serial data collector" );
174161
175- if ((fileStatus == FST_CREATING || fileStatus == FST_WRITING) &&
176- maxID >= 0 )
162+ if (fileStatus == FST_CREATING || fileStatus == FST_WRITING)
177163 {
164+ DCGroup group;
165+ group.open (handles.get (0 ), SDC_GROUP_HEADER);
166+
178167 // write number of iterations
179168 try
180169 {
181- DCGroup group;
182- group.open (handles.get (0 ), SDC_GROUP_HEADER);
183170 ColTypeInt32 ctInt32;
184171 DCAttribute::writeAttribute (SDC_ATTR_MAX_ID, ctInt32.getDataType (),
185172 group.getHandle (), &maxID);
@@ -759,8 +746,9 @@ namespace splash
759746 {
760747 this ->fileStatus = FST_CREATING;
761748
762- std::string full_filename = getFullFilename (attr.mpiPosition , filename,
763- attr.mpiSize .getScalarSize () == 1 );
749+ // appends the mpiPosition to the filename (e.g. myfile_0_1_0.h5)
750+ std::string full_filename = getFullFilename (attr.mpiPosition , filename);
751+ DCHelper::testFilename (full_filename);
764752
765753 this ->enableCompression = attr.enableCompression ;
766754
@@ -791,8 +779,11 @@ namespace splash
791779 {
792780 fileStatus = FST_WRITING;
793781
794- std::string full_filename = getFullFilename (attr.mpiPosition , filename,
795- attr.mpiSize .getScalarSize () == 1 );
782+ std::string full_filename = filename;
783+ if (full_filename.find (" .h5" ) == std::string::npos)
784+ full_filename = getFullFilename (attr.mpiPosition , filename);
785+
786+ DCHelper::testFilename (full_filename);
796787
797788 this ->enableCompression = attr.enableCompression ;
798789
@@ -814,7 +805,9 @@ namespace splash
814805 this ->fileStatus = FST_MERGING;
815806
816807 // open reference file to get mpi information
817- std::string full_filename = getFullFilename (Dimensions (0 , 0 , 0 ), filename, true );
808+ std::string full_filename = getFullFilename (Dimensions (0 , 0 , 0 ), filename);
809+
810+ DCHelper::testFilename (full_filename);
818811
819812 if (!fileExists (full_filename))
820813 {
@@ -828,7 +821,6 @@ namespace splash
828821 // no compression for in-memory datasets
829822 this ->enableCompression = false ;
830823
831- handles.setFileNameScheme (HandleMgr::FNS_MPI);
832824 handles.open (mpiTopology, filename, fileAccProperties, H5F_ACC_RDONLY);
833825 }
834826
@@ -837,7 +829,11 @@ namespace splash
837829 {
838830 this ->fileStatus = FST_READING;
839831
840- std::string full_filename = getFullFilename (attr.mpiPosition , filename, true );
832+ std::string full_filename = filename;
833+ if (full_filename.find (" .h5" ) == std::string::npos)
834+ full_filename = getFullFilename (attr.mpiPosition , filename);
835+
836+ DCHelper::testFilename (full_filename);
841837
842838 if (!fileExists (full_filename))
843839 {
0 commit comments