XdmfHDF5ControllerDSM.cpp 4.16 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfHDF5ControllerDSM.cpp                                           */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/
23 24 25 26 27

#include <H5FDdsm.h>
#include <hdf5.h>
#include "XdmfHDF5ControllerDSM.hpp"

28
shared_ptr<XdmfHDF5ControllerDSM>
29 30
XdmfHDF5ControllerDSM::New(const std::string & hdf5FilePath,
                           const std::string & dataSetPath,
31
                           const shared_ptr<const XdmfArrayType> type,
32 33
                           const std::vector<unsigned int> & start,
                           const std::vector<unsigned int> & stride,
34 35
                           const std::vector<unsigned int> & dimensions,
                           const std::vector<unsigned int> & datspaceDimensions,
36
                           H5FDdsmBuffer * const dsmBuffer)
37
{
38 39 40 41 42 43 44 45 46
  shared_ptr<XdmfHDF5ControllerDSM> 
    p(new XdmfHDF5ControllerDSM(hdf5FilePath,
                                dataSetPath,
                                type,
                                start,
                                stride,
                                dimensions,
                                datspaceDimensions,
                                dsmBuffer));
47
  return p;
48 49
}

50 51
XdmfHDF5ControllerDSM::XdmfHDF5ControllerDSM(const std::string & hdf5FilePath,
                                             const std::string & dataSetPath,
52
                                             const shared_ptr<const XdmfArrayType> type,
53 54
                                             const std::vector<unsigned int> & start,
                                             const std::vector<unsigned int> & stride,
55 56
                                             const std::vector<unsigned int> & dimensions,
                                             const std::vector<unsigned int> & dataspaceDimensions,
57
                                             H5FDdsmBuffer * const dsmBuffer) :
58 59 60 61 62 63 64
  XdmfHDF5Controller(hdf5FilePath, 
                     dataSetPath, 
                     type, 
                     start,
                     stride,
                     dimensions, 
                     dataspaceDimensions),
65
  mDSMBuffer(dsmBuffer)
66 67 68 69 70 71 72 73 74
{
}

XdmfHDF5ControllerDSM::~XdmfHDF5ControllerDSM()
{
}

std::string XdmfHDF5ControllerDSM::getName() const
{
75
  return "HDFDSM";
76 77 78 79
}

void XdmfHDF5ControllerDSM::read(XdmfArray * const array)
{
80 81
  // Set file access property list for DSM
  hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
82

83
  // Use DSM driver
84
  H5Pset_fapl_dsm(fapl, MPI_COMM_WORLD, mDSMBuffer, 0);
85

86 87
  // Read from DSM Buffer
  XdmfHDF5Controller::read(array, fapl);
88

89 90
  // Close file access property list
  herr_t status = H5Pclose(fapl);
91
}