packages/Utils/utils/Parallel_HDF5_Writer.cc
//---------------------------------------------------------------------------//
// PUBLIC FUNCTIONS
//---------------------------------------------------------------------------//
/*!
 * \brief Open an HDF5 file for output.
 *
 * \param filename output file name, with extension
 * \param mode specify
 */
PUBLIC FUNCTIONS
\brief Open an HDF5 file for output.

\param filename output file name, with extension
\param mode specify
PUBLIC FUNCTIONS \ brief Open an HDF5 file for output . \ param filename output file name with extension \ param mode specify
void Parallel_HDF5_Writer::open(const std_string &filename,
                                File_Mode         mode)
{
    REQUIRE(mode < END_FILE_MODE);
    b_filename = filename;
    b_mode     = mode;
    const char* const filenm = b_filename.c_str();
    hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS);
    H5Pset_fapl_mpio(plist_id, profugus::communicator, MPI_INFO_NULL);
    switch (mode)
    {
        case CLOBBER:
            b_file = H5Fcreate(filenm, H5F_ACC_TRUNC, H5P_DEFAULT, plist_id);
            break;
        case APPEND:
            b_file = H5Fopen(filenm, H5F_ACC_RDWR, plist_id);
            break;
        default:
            throw profugus::assertion("File mode must be CLOBBER or APPEND.");
    }
    H5Pclose(plist_id);
    HDF5_Loc loc = {b_file, ""};
    b_loc_stack.push_back(loc);
    ENSURE(b_file);
    ENSURE(b_loc_stack.size() == 1);
    ENSURE(b_mode != END_FILE_MODE);
}
void Parallel_HDF5_Writer :: open ( const std_string & filename , File_Mode mode ) { REQUIRE ( mode < END_FILE_MODE ) ; b_filename = filename ; b_mode = mode ; const char * const filenm = b_filename . c_str ( ) ; hid_t plist_id = H5Pcreate ( H5P_FILE_ACCESS ) ; H5Pset_fapl_mpio ( plist_id , profugus :: communicator , MPI_INFO_NULL ) ; switch ( mode ) { case CLOBBER : b_file = H5Fcreate ( filenm , H5F_ACC_TRUNC , H5P_DEFAULT , plist_id ) ; break ; case APPEND : b_file = H5Fopen ( filenm , H5F_ACC_RDWR , plist_id ) ; break ; default : throw profugus :: assertion ( " " ) ; } H5Pclose ( plist_id ) ; HDF5_Loc loc = { b_file , " " } ; b_loc_stack . push_back ( loc ) ; ENSURE ( b_file ) ; ENSURE ( b_loc_stack . size ( ) == 1 ) ; ENSURE ( b_mode != END_FILE_MODE ) ; }
PUBLIC FUNCTIONS
 \brief Open an HDF5 file for output.
PUBLIC FUNCTIONS \ brief Open an HDF5 file for output .
// Set file name, mode, and node // filename c-string handle // set property list with parallel I/O access // Open the hdf5 file; create the file if not appending // close the properties // Set location