14 outStream <<
"<?xml version=\"1.0\" ?>" << std::endl
15 <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>" << std::endl
16 <<
"<Xdmf Version=\"2.0\">" 17 <<
" <Domain>" << std::endl;
22 outStream <<
" </Domain>" << std::endl
23 <<
"</Xdmf>" << std::endl;
26 void OpenGridTag(
const std::string &gridName,
const std::string &
gridType,
double inTime,std::ostream &outStream)
28 outStream <<
" <Grid Name=\"" << gridName <<
"\" GridType=\"" << gridType <<
"\">" << std::endl;
30 outStream <<
" <Time Value=\"" << inTime <<
"\" />" << std::endl;
34 outStream <<
" </Grid>" << std::endl;
39 const std::string &fileName,
const std::string &gridPath,
40 const std::vector<size_t> &gridSize,std::ostream &outStream)
43 unsigned int nDim = gridSize.size();
44 if(nDim > 3 || nDim < 2)
46 std::ostringstream Ostr;
47 std::vector<size_t>::const_iterator gsIt = gridSize.begin();
48 while(gsIt != gridSize.end()){
50 if(gsIt != gridSize.end())
54 outStream <<
" <Topology TopologyType=\"" << topoType <<
"\" Dimensions=\"" 55 << Ostr.str() <<
"\" />" << std::endl
56 <<
" <Geometry GeometryType=\"" << (nDim == 2 ?
"X_Y" :
"X_Y_Z")
57 <<
"\">" << std::endl;
59 outStream <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">" << std::endl
60 <<
" " << fileName <<
":/" << gridPath <<
"/X" << std::endl
61 <<
" </DataItem>" << std::endl
62 <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">" << std::endl
63 <<
" " << fileName <<
":/" << gridPath <<
"/Y" << std::endl
64 <<
" </DataItem>" << std::endl;
67 outStream <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">" << std::endl
68 <<
" " << fileName <<
":/" << gridPath <<
"/Z" << std::endl
69 <<
" </DataItem>" << std::endl;
72 outStream <<
" </Geometry>" << std::endl;
78 const std::string &fileName,
79 const std::string &gridPath,
80 const std::vector<size_t> &gridSize,
81 std::ostream &outStream)
84 unsigned int nDim = gridSize.size();
85 if(nDim > 3 || nDim < 2)
87 std::ostringstream Ostr;
88 std::vector<size_t>::const_iterator gsIt = gridSize.begin();
89 while(gsIt != gridSize.end()){
91 if(gsIt != gridSize.end())
95 outStream <<
" <Topology TopologyType=\"" << topoType <<
"\" Dimensions=\"" 96 << Ostr.str() <<
"\" />" << std::endl
97 <<
" <Geometry GeometryType=\"" << (nDim == 2 ?
"X_Y" :
"X_Y_Z")
98 <<
"\">" << std::endl;
100 outStream <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">" << std::endl
101 <<
" " << fileName <<
":/" << gridPath <<
"/X" << std::endl
102 <<
" </DataItem>" << std::endl
103 <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">" << std::endl
104 <<
" " << fileName <<
":/" << gridPath <<
"/Y" << std::endl
105 <<
" </DataItem>" << std::endl;
108 outStream <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">" << std::endl
109 <<
" " << fileName <<
":/" << gridPath <<
"/Z" << std::endl
110 <<
" </DataItem>" << std::endl;
113 outStream <<
" </Geometry>" << std::endl;
118 int WriteGridData(
const std::string &fileName,
const std::string &dataName,
unsigned int dataSize,
119 const std::string &dataPath,
const std::vector<size_t> &gridSize,std::ostream &outStream)
121 unsigned int nDim = gridSize.size();
122 if(nDim > 3 || nDim < 2)
124 std::ostringstream Ostr;
125 std::vector<size_t>::const_iterator gsIt = gridSize.begin();
126 while(gsIt != gridSize.end()){
128 if(gsIt != gridSize.end())
131 outStream <<
" <Attribute Name=\"" << dataName <<
"\" AttributeType=\"Scalar\" Center=\"Node\">" 132 <<
" <DataItem Dimensions=\"" << Ostr.str() <<
"\" NumberType=\"" << (dataSize == 1 ?
"Char" :
133 (dataSize == 4 ?
"Int" :
134 (dataSize == 8 ?
"Float" :
"")))
135 <<
"\" Precision=\"" << dataSize <<
"\" Format=\"HDF\">" << std::endl
136 <<
" " << fileName <<
":/" << dataPath << std::endl
137 <<
" </DataItem>" << std::endl
138 <<
" </Attribute>" << std::endl;
149 const std::string &hdfFileName(fileInfo.
fileName);
151 hid_t h5attID = H5Aopen(rootGroupID,
"numberOfGrids",H5P_DEFAULT);
152 std::ostringstream Ostr;
155 h5attID = H5Aopen(rootGroupID,
"numGrids",H5P_DEFAULT);
159 if(H5Aread(h5attID,H5T_NATIVE_INT,&numGrids) < 0){
160 Ostr <<
"Unable to read number of grids from legacy HDF5 file." << std::endl;
161 messageStream << Ostr.str();
164 Ostr << hdfFileName <<
" has " << numGrids <<
" grids." << std::endl;
165 messageStream << Ostr.str();
172 std::vector<std::string> &gridNames(fileInfo.
gridNames);
174 if(H5Aexists(rootGroupID,
"gridNames") > 0){
175 h5attID = H5Aopen(rootGroupID,
"gridNames",H5P_DEFAULT);
180 Ostr <<
"No grid names in HDF file, going with names specified in input." 182 messageStream << Ostr.str();
184 for(
int i = 0;i < numGrids;i++){
185 std::ostringstream gridOut;
187 gridOut <<
"Group" << (gridNum < 10 ?
"00" :
188 (gridNum < 100 ?
"0" :
190 gridNames.push_back(gridOut.str());
204 Ostr <<
"Grid sizes:" << std::endl;
208 gridNumDimensions.resize(numGrids);
209 gridSizes.resize(numGrids);
211 for(
int iGrid = 0;iGrid < numGrids;iGrid++){
212 hsize_t gridDimensions = 0;
213 hsize_t maxGridDimensions = 0;
218 Ostr << gridNames[iGrid] <<
" : (";
220 hid_t gridGroupID = H5Gopen(rootGroupID,gridNames[iGrid].c_str(),H5P_DEFAULT);
221 if(H5Lexists(gridGroupID,
"IBLANK",0) > 0){
224 if(H5Lexists(gridGroupID,
"State",0) > 0){
227 if(H5Lexists(gridGroupID,
"cv01",0) > 0) {
231 if(H5Lexists(gridGroupID,
"cvt01",0) > 0) {
235 if(H5Lexists(gridGroupID,
"aux01",0) > 0) {
239 if(H5Lexists(gridGroupID,
"numberOfAuxVars",0) > 0){
240 h5attID = H5Aopen(gridGroupID,
"numberOfAuxVars",H5P_DEFAULT);
242 if(H5Aread(h5attID,H5T_NATIVE_INT,&numAux) < 0){
243 messageStream <<
"pcpp::io:hdf5::FileInfo:Error: Unable to" 244 <<
" read number of Aux vars." << std::endl;
250 h5attID = H5Aopen(gridGroupID,
"gridSize",H5P_DEFAULT);
251 hid_t h5spaceID = H5Aget_space(h5attID);
252 H5Sget_simple_extent_dims(h5spaceID,&gridDimensions,&maxGridDimensions);
253 gridNumDimensions[iGrid] = gridDimensions;
254 std::vector<int> gridGlobalSize(gridDimensions,1);
256 H5Aread(h5attID,H5T_NATIVE_INT,&(gridGlobalSize[0]));
257 for(
int iDim = 0;iDim < gridDimensions;iDim++){
258 Ostr << gridGlobalSize[iDim];
259 if(iDim < (gridDimensions - 1))
262 Ostr <<
")" << std::endl;
263 gridSizes[iGrid].resize(gridDimensions,0);
264 for(
int iDim = 0;iDim < gridDimensions;iDim++)
265 gridSizes[iGrid][iDim] = gridGlobalSize[iDim];
267 H5Gclose(gridGroupID);
270 messageStream << Ostr.str();
279 std::ostringstream Ostr;
280 const std::string fileName(hdf5File.
Name());
283 if(!hdf5File.
Exists(
"PlasCom2")){
284 messageStream <<
"pcpp::io::hdf5::FileInfo:Error: Unable to open PlasCom2 group in " 285 << fileName <<
"." << std::endl;
289 if(hdf5File.
Exists(
"Global"))
291 if(hdf5File.
Exists(
"/PlasCom2/Configuration"))
293 if(hdf5File.
Exists(
"/PlasCom2/Geometry")){
297 if(hdf5File.
Exists(
"/PlasCom2/Simulation"))
308 int totalNumGrids = 0;
309 std::vector<std::string> &allGeometryGridNames(fileInfo.
gridNames);
310 std::vector<std::vector<size_t> > &allGridSizes(fileInfo.
gridSizes);
312 allGeometryGridNames.resize(0);
313 allGridSizes.resize(0);
314 allGridDimensions.resize(0);
316 std::string allGeometryNames;
318 hdf5File.
ReadAttribute(
"/PlasCom2/Geometry/geometryNames",allGeometryNames);
325 std::vector<std::vector<std::string> >::iterator
327 std::vector<std::vector<std::vector<size_t> > >::iterator
329 std::vector<std::string>::iterator geomNameIt = fileInfo.
geometryNames.begin();
332 std::vector<std::string> &gridNames(*geomGridNameIt++);
333 std::vector<std::vector<size_t> > &gridIntervals(*geomGridSizeIt++);
336 std::string &geometryName(*geomNameIt++);
337 std::string geometryGroupName(std::string(
"/PlasCom2/Geometry/")+geometryName);
339 hdf5File.
ReadAttribute(geometryGroupName+
"/numGrids",&numGrids);
340 totalNumGrids += numGrids;
341 std::string allGridNames;
342 hdf5File.
ReadAttribute(geometryGroupName+
"/gridNames",allGridNames);
344 std::vector<std::string>::iterator gridNameIt = gridNames.begin();
345 while(gridNameIt != gridNames.end()){
346 const std::string &gridName(*gridNameIt++);
347 allGeometryGridNames.push_back(geometryName+
":"+gridName);
348 const std::string gridGroupName(geometryGroupName+std::string(
"/")+
352 allGridDimensions.push_back(numDim);
353 std::vector<size_t> reverseGridSizes(numDim,0);
354 hdf5File.
ReadAttribute(gridGroupName+
"/gridSize",&reverseGridSizes[0]);
355 std::vector<size_t>
gridSizes(reverseGridSizes);
356 std::reverse(gridSizes.begin(),gridSizes.end());
359 gridIntervals.push_back(gridSizes);
360 allGridSizes.push_back(gridSizes);
373 hdf5File.
ReadAttribute(
"/PlasCom2/Simulation/numDomains",&numDomains);
379 std::string paramDictionaryString;
380 hdf5File.
ReadAttribute(
"/PlasCom2/Simulation/paramDictionary",paramDictionaryString);
381 std::istringstream Istr(paramDictionaryString);
382 Istr >> simulationParamDictionary;
386 std::string stateDictionaryString;
387 hdf5File.
ReadAttribute(
"/PlasCom2/Simulation/stateDictionary",stateDictionaryString);
388 std::istringstream Istr(stateDictionaryString);
389 Istr >> simulationStateDictionary;
401 std::string allDomainNames;
402 hdf5File.
ReadAttribute(
"/PlasCom2/Simulation/domainNames",allDomainNames);
406 const std::vector<std::string> &domainNames(fileInfo.
domainNames);
408 std::vector<std::vector<std::string> >::iterator domainGridNameIt =
410 std::vector<std::vector<std::string> >::iterator domainFullGridNamesIt =
412 std::vector<pcpp::field::metadataset>::iterator domainParamDictIt =
414 std::vector<pcpp::field::metadataset>::iterator domainStateDictIt =
416 std::vector<std::string>::const_iterator domainNameIt = domainNames.begin();
418 while(domainNameIt != domainNames.end()){
423 const std::string &domainName(*domainNameIt++);
424 std::string domainGroupName(
"/PlasCom2/Simulation/"+domainName);
425 int numDomainGrids = 0;
426 hdf5File.
ReadAttribute(domainGroupName+
"/numGrids",&numDomainGrids);
433 std::string paramDictionaryString;
434 hdf5File.
ReadAttribute(domainGroupName+
"/paramDictionary",paramDictionaryString);
435 std::istringstream Istr(paramDictionaryString);
436 Istr >> domainParamDictionary;
440 std::string stateDictionaryString;
441 hdf5File.
ReadAttribute(domainGroupName+
"/stateDictionary",stateDictionaryString);
442 std::istringstream Istr(stateDictionaryString);
443 Istr >> domainStateDictionary;
446 if(numDomainGrids > 0){
448 std::vector<std::string> &domainGridNames(*domainGridNameIt++);
449 std::vector<std::string> &domainFullGridNames(*domainFullGridNamesIt++);
450 domainFullGridNames.resize(numDomainGrids);
451 std::string allGridNames;
453 std::string attName(domainGroupName+
"/gridNames");
454 hdf5File.
ReadAttribute(domainGroupName+
"/gridNames",allGridNames);
457 for(
int iGrid = 0;iGrid < numDomainGrids;iGrid++){
458 const std::string &gridName(domainGridNames[iGrid]);
459 const std::string gridGroupName(domainGroupName+
"/"+gridName);
460 hdf5File.
ReadAttribute(gridGroupName+
"/gridPath",domainFullGridNames[iGrid]);
472 std::ostringstream Ostr;
473 const std::string fileName(hdf5File.
Name());
475 const std::string &hdfFileName(fileInfo.
fileName);
483 stateDictionary.
AddField(
"simStep",
'd',1,4,
"");
484 stateDictionary.
AddField(
"simTime",
'd',1,8,
"time");
485 paramDictionary.
AddField(
"refRe",
'd',1,8,
"ReynoldsNo");
486 paramDictionary.
AddField(
"refPr",
'd',1,8,
"PrandtlNo");
487 paramDictionary.
AddField(
"refSc",
'd',1,8,
"SchmidtNo");
490 paramDictionary.
AddField(
"numberOfGrids",
'd',1,4,
"");
495 paramDictionary.
AddField(
"numGrids",
'd',1,4,
"");
499 messageStream <<
"pcpp::hdf5::LegacyFileInfo: Could not read number of grids." << std::endl;
503 Ostr << hdfFileName <<
" has " << numGrids <<
" grids." << std::endl;
504 messageStream << Ostr.str();
506 std::vector<std::string> &gridNames(fileInfo.
gridNames);
507 Ostr <<
"No grid names in HDF file, going with names specified in input." 509 messageStream << Ostr.str();
512 for(
int i = 0;i < numGrids;i++){
513 std::ostringstream gridOut;
515 gridOut <<
"Group" << (gridNum < 10 ?
"00" :
516 (gridNum < 100 ?
"0" :
518 gridNames.push_back(gridOut.str());
519 Ostr <<
"Setting grid name " << gridOut.str() << std::endl;
521 messageStream << Ostr.str();
524 Ostr <<
"Grid sizes:" << std::endl;
527 gridNumDimensions.resize(numGrids);
528 gridSizes.resize(numGrids);
530 for(
int iGrid = 0;iGrid < numGrids;iGrid++){
532 const std::string &gridName(gridNames[iGrid]);
533 std::vector<size_t> &gridSize(gridSizes[iGrid]);
534 std::vector<size_t> reverseGridSize;
536 hdf5File.
ReadAttribute(gridName+
"/gridSize",reverseGridSize);
538 gridSize = reverseGridSize;
539 gridNumDimensions[iGrid] = gridSize.size();
540 int numDim = gridNumDimensions[iGrid];
544 if(hdf5File.
Exists(gridName+
"/X")){
547 if(hdf5File.
Exists(gridName+
"/IBLANK")){
550 stateDictionary.
AddField(
"IBLANK",
'n',1,4,
"");
553 if(hdf5File.
Exists(gridName+
"/cv01")){
556 stateDictionary.
AddField(
"cv01",
'n',1,8,
"rho");
557 for(
int iDim = 0;iDim < numDim;iDim++){
558 std::ostringstream attNameStream;
559 attNameStream <<
"cv0" << iDim+2;
560 std::ostringstream unitStream;
561 unitStream <<
"rhoV-" << iDim+1;
563 stateDictionary.
AddField(attNameStream.str(),
'n',1,8,unitStream.str());
565 std::ostringstream attNameStream;
566 attNameStream <<
"cv0" << numDim+2;
567 stateDictionary.
AddField(attNameStream.str(),
'n',1,8,
"rhoE");
570 if(hdf5File.
Exists(gridName+
"/cvt01")){
573 stateDictionary.
AddField(
"cvt01",
'n',1,8,
"rhoTarget");
574 for(
int iDim = 0;iDim < numDim;iDim++){
575 std::ostringstream attNameStream;
576 attNameStream <<
"cvt0" << iDim+2;
577 std::ostringstream unitStream;
578 unitStream <<
"rhoVTarget-" << iDim+1;
579 stateDictionary.
AddField(attNameStream.str(),
'n',1,8,unitStream.str());
581 std::ostringstream attNameStream;
582 attNameStream <<
"cvt0" << numDim+2;
583 stateDictionary.
AddField(attNameStream.str(),
'n',1,8,
"rhoETarget");
586 if(hdf5File.
Exists(gridName+
"/numberOfAuxVars")){
591 for(
int iAux = 0;iAux < fileInfo.
numAuxVars;iAux++){
592 std::ostringstream Ostr;
593 Ostr << std::setfill(
'0') << std::setw(2) << iAux;
594 const std::string auxId(Ostr.str());
595 const std::string auxName(
"aux"+auxId);
596 stateDictionary.
AddField(auxName,
'n',1,8,
"");
598 const std::string auxTarg(
"auxt"+auxId);
599 stateDictionary.
AddField(auxTarg,
'n',1,8,
"");
605 std::vector<double> gridHeader;
607 size_t numHeader = gridHeader.size();
609 fileInfo.
simTime = gridHeader[3];
611 Ostr << gridName <<
" : (";
613 Ostr <<
")" << std::endl;
615 messageStream << Ostr.str();
626 hid_t h5fileID = H5Fopen(hdfFileName.c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
629 messageStream <<
"Unable to open " << hdfFileName <<
"." << std::endl;
632 hid_t rootGroupID = H5Gopen(h5fileID,
"/",H5P_DEFAULT);
634 messageStream <<
"pcpp::io::hdf5::FileInfo::Error: Unable to open root group in " 635 << hdfFileName <<
"." << std::endl;
638 if(H5Lexists(rootGroupID,
"PlasCom2",0) > 0){
645 H5Gclose(rootGroupID);
651 messageStream <<
"pcpp::io::hdf5::FileInfo::Error: Processing of Legacy HDF5 file " 652 << hdfFileName <<
" failed." << std::endl;
657 messageStream <<
"pcpp::io::hdf5::FileInfo::Error: Processing of PlasCom2 HDF5 file " 658 << hdfFileName <<
" failed." << std::endl;
669 int myRank = inComm.
Rank();
671 if(
FileInfo(hdfFileName,fileInfo,messageStream)){
683 int base::Create(
const std::string &inFileName,
bool force)
686 std::ostream &messageStream(*messageStreamPtr);
688 unsigned createFlag = H5F_ACC_EXCL;
690 createFlag = H5F_ACC_TRUNC;
691 hid_t fileProperties = H5P_DEFAULT;
697 int numProc = commPtr->NProc();
699 fileProperties = H5Pcreate(H5P_FILE_ACCESS);
700 H5Pset_fapl_mpio(fileProperties, commPtr->Comm(),MPI_INFO_NULL);
701 collectiveMode =
true;
704 hid_t fileID = H5Fcreate(inFileName.c_str(),createFlag,H5P_DEFAULT,fileProperties);
706 messageStream <<
"pcpp::io::hdf5::base:ERROR: Unable to create " 707 << inFileName <<
"." << std::endl;
710 hdfScope.push_back(fileID);
711 H5Pclose(fileProperties);
712 dataTransferProperties = H5Pcreate(H5P_DATASET_XFER);
718 int base::Open(
const std::string &inFileName,
bool readOnly)
721 std::ostream &messageStream(*messageStreamPtr);
723 unsigned openFlags = H5F_ACC_RDWR;
725 messageStream <<
"pcpp::io::hdf5::base: Opening READONLY file, " << inFileName
727 openFlags = H5F_ACC_RDONLY;
729 hid_t hdfFileID = -1;
732 messageStream <<
"pcpp::io::hdf5::base: Opening " << inFileName
733 <<
" with " << (readOnly ?
"readonly" :
734 "read/write") <<
" access." << std::endl;
735 hdfFileID = H5Fopen(inFileName.c_str(),openFlags,H5P_DEFAULT);
737 messageStream <<
"pcpp::io::hdf5::base:ERROR: Unable to open " 738 << inFileName <<
"." << std::endl;
741 hdfScope.push_back(hdfFileID);
746 int nProc = commPtr->NProc();
747 collectiveMode =
true;
748 messageStream <<
"pcpp::io::hdf5::base: Opening " << inFileName
749 <<
" on " << nProc <<
" processors with " 750 << (readOnly ?
"readonly" :
751 "read/write") <<
" access." << std::endl;
752 hid_t propertyListID = H5Pcreate(H5P_FILE_ACCESS);
753 if(propertyListID < 0){
754 messageStream <<
"pcpp::io::hdf5::base:ERROR: H5Pcreate failed." << std::endl;
757 if(H5Pset_fapl_mpio(propertyListID,hdfComm.
Comm(),MPI_INFO_NULL) < 0){
758 messageStream <<
"pcpp::io::hdf5::base:ERROR: H5Pset_fapl_mpio failed." 762 hdfFileID = H5Fopen(inFileName.c_str(),openFlags,propertyListID);
764 std::ostringstream Ostr;
765 messageStream <<
"pcpp::io::hdf5::base:ERROR: Could not open HDF5 file: " 766 << inFileName << std::endl;
769 hdfScope.push_back(hdfFileID);
770 H5Pclose(propertyListID);
779 messageStream <<
"Opened file on scope(" << hdfFileID <<
")" 785 fileName = inFileName;
786 dataTransferProperties = H5Pcreate(H5P_DATASET_XFER);
792 std::vector<hid_t>::iterator plistIt = hdfAPL.begin();
793 while(plistIt != hdfAPL.end()){
794 if(*plistIt != H5P_DEFAULT)
799 if(dataTransferProperties > 0){
800 H5Pclose(dataTransferProperties);
801 dataTransferProperties = -1;
816 H5Sclose(globalSlab);
819 int numScope = hdfScope.size();
820 for(
int iScope = numScope-1;iScope > 0;iScope--){
821 H5Gclose(hdfScope[iScope]);
825 H5Fclose(hdfScope[0]);
831 int base::OpenGroup(
const std::string &groupName)
833 std::ostream &messageStream(*messageStreamPtr);
834 hid_t parentID = hdfScope.back();
835 if(H5Lexists(parentID,groupName.c_str(),H5P_DEFAULT) <= 0){
836 messageStream <<
"pcpp::io::hdf5::base:ERROR: Group " 837 << groupName <<
" does not exist in " 838 << fileName <<
"." << std::endl;
841 hid_t hdfGroupID = H5Gopen(parentID,groupName.c_str(),H5P_DEFAULT);
843 messageStream <<
"pcpp::io::hdf5::base:ERROR: " 844 <<
"Unable to open group: " 845 << groupName << std::endl;
848 hdfScope.push_back(hdfGroupID);
852 bool base::AttributeExists(
const std::string &inName)
854 *messageStreamPtr <<
"LOCATING ATTRIBUTE: " << inName << std::endl;
855 std::string attributeName(inName);
856 std::string locationName(
".");
857 hid_t parentId = hdfScope.back();
858 if(ResolveName(inName,locationName,attributeName,parentId))
860 *messageStreamPtr <<
"Checking for existence of attribute (" 861 << attributeName <<
") located at (" << locationName
863 << parentId <<
")" << std::endl;
864 if(H5Aexists_by_name(parentId,locationName.c_str(),attributeName.c_str(),H5P_DEFAULT) <= 0){
865 *messageStreamPtr <<
"Not found." << std::endl;
868 *messageStreamPtr <<
"Found." << std::endl;
872 bool base::Exists(
const std::string &linkName)
874 hid_t parentId = hdfScope.back();
875 if(linkName[0] ==
'/')
876 parentId = hdfScope[0];
877 *messageStreamPtr <<
"Checking for existence of " 878 << linkName <<
" in scope (" 879 << parentId <<
")" << std::endl;
880 if(H5Lexists(parentId,linkName.c_str(),H5P_DEFAULT) <= 0){
881 *messageStreamPtr <<
"Not found." << std::endl;
884 *messageStreamPtr <<
"Found." << std::endl;
888 int base::ResolveName(
const std::string &inName,std::string &attLocation,
889 std::string &attName,hid_t &parentId)
895 parentId = hdfScope.back();
896 if(attName[0] ==
'/'){
897 attName = attName.substr(1);
898 parentId = hdfScope[0];
900 std::string::size_type
x = attName.find_last_of(
"/");
901 if(x != std::string::npos){
902 attLocation = attName.substr(0,x);
903 attName = attName.substr(x+1);
904 if(attLocation.empty())
907 if(attLocation.empty() ||
908 attLocation.empty() ||
911 *messageStreamPtr <<
"Resolved(" << inName
912 <<
") = (" << attName <<
"," 913 << attLocation <<
")" 919 hid_t base::OpenDataSet(
const std::string &inName)
923 std::string dataLocation;
924 std::string dataSetName;
926 if(ResolveName(inName,dataLocation,dataSetName,parentID))
928 std::ostream &messageStream(*messageStreamPtr);
929 messageStream <<
"Opening dataset (" << dataSetName
930 <<
") at (" << dataLocation <<
") in scope" 931 <<
"(" << parentID <<
")." << std::endl;
932 hid_t dataSetID = H5Dopen(parentID,inName.c_str(),H5P_DEFAULT);
934 messageStream <<
"pcpp::io::hdf5::base: ERROR: Dataset not found (" 935 << dataSetName <<
")" << std::endl;
941 hid_t base::OpenAttribute(
const std::string &inName)
944 if(!AttributeExists(inName))
946 std::string attributeName;
947 std::string attLocation;
948 hid_t parentID = hdfScope.back();
949 if(ResolveName(inName,attLocation,attributeName,parentID))
951 std::ostream &messageStream(*messageStreamPtr);
952 messageStream <<
"Opening attribute (" << attributeName <<
") located" 953 <<
" at (" << attLocation <<
") in scope (" << parentID
954 <<
")." << std::endl;
955 hid_t h5attID = H5Aopen_by_name(parentID,attLocation.c_str(),attributeName.c_str(),
956 H5P_DEFAULT,H5P_DEFAULT);
958 messageStream <<
"pcpp::io::hdf5::base: ERROR: Attribute not found (" 959 << attributeName <<
")" << std::endl;
965 int base::ReadDataSet(
const std::string &inName,
int *inBuf)
967 std::ostream &messageStream(*messageStreamPtr);
968 hid_t dataSetID = OpenDataSet(inName);
971 if(H5Dread(dataSetID,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,inBuf) < 0){
972 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 973 <<
"attribute (" << inName <<
")" << std::endl;
981 int base::ReadDataSet(
const std::string &inName,
size_t *inBuf)
983 std::ostream &messageStream(*messageStreamPtr);
984 hid_t dataSetID = OpenDataSet(inName);
987 if(H5Dread(dataSetID,H5T_NATIVE_HSIZE,H5S_ALL,H5S_ALL,H5P_DEFAULT,inBuf) < 0){
988 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 989 <<
"attribute (" << inName <<
")" << std::endl;
997 int base::ReadDataSet(
const std::string &inName,
double *inBuf)
999 std::ostream &messageStream(*messageStreamPtr);
1000 hid_t dataSetID = OpenDataSet(inName);
1003 if(H5Dread(dataSetID,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,inBuf) < 0){
1004 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1005 <<
"attribute (" << inName <<
")" << std::endl;
1006 H5Dclose(dataSetID);
1009 H5Dclose(dataSetID);
1013 int base::ReadDataSet(
const std::string &inName,
char *inBuf)
1015 std::ostream &messageStream(*messageStreamPtr);
1016 hid_t dataSetID = OpenDataSet(inName);
1019 if(H5Dread(dataSetID,H5T_NATIVE_CHAR,H5S_ALL,H5S_ALL,H5P_DEFAULT,inBuf) < 0){
1020 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1021 <<
"attribute (" << inName <<
")" << std::endl;
1022 H5Dclose(dataSetID);
1025 H5Dclose(dataSetID);
1029 int base::ReadAttribute(
const std::string &inName,
int *inBuf)
1031 std::ostream &messageStream(*messageStreamPtr);
1032 hid_t h5attID = OpenAttribute(inName);
1036 if(H5Aread(h5attID,H5T_NATIVE_INT,inBuf) < 0){
1037 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1038 <<
"attribute (" << inName <<
")" << std::endl;
1048 int base::ReadAttribute(
const std::string &inName,
size_t *inBuf)
1050 std::ostream &messageStream(*messageStreamPtr);
1051 hid_t h5attID = OpenAttribute(inName);
1055 if(H5Aread(h5attID,H5T_NATIVE_HSIZE,inBuf) < 0){
1056 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1057 <<
"attribute (" << inName <<
")" << std::endl;
1066 int base::ReadAttribute(
const std::string &inName,
double *inBuf)
1068 std::ostream &messageStream(*messageStreamPtr);
1069 hid_t h5attID = OpenAttribute(inName);
1073 if(H5Aread(h5attID,H5T_NATIVE_DOUBLE,inBuf) < 0){
1074 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1075 <<
"attribute (" << inName <<
")" << std::endl;
1084 int base::ReadAttribute(
const std::string &inName,
char *inBuf)
1086 std::ostream &messageStream(*messageStreamPtr);
1087 hid_t h5attID = OpenAttribute(inName);
1091 if(H5Aread(h5attID,H5T_NATIVE_CHAR,inBuf) < 0){
1092 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1093 <<
"attribute (" << inName <<
")" << std::endl;
1102 int base::ReadAttribute(
const std::string &inName,std::string &inBuf)
1104 std::ostream &messageStream(*messageStreamPtr);
1105 hid_t h5attID = OpenAttribute(inName);
1109 hsize_t stringSize = H5Aget_storage_size(h5attID);
1110 hid_t typeID = H5Tcopy(H5T_C_S1);
1111 H5Tset_size(typeID,stringSize);
1112 char *stringBuf =
new char [stringSize];
1113 if(H5Aread(h5attID,typeID,stringBuf) < 0){
1114 messageStream <<
"pcpp::io::hdf5::base: ERROR: Unable to read " 1115 <<
"attribute (" << inName <<
")" << std::endl;
1118 delete [] stringBuf;
1123 inBuf.assign(stringBuf);
1124 delete [] stringBuf;
1129 hid_t base::DataSpace(
const std::string &inName)
1131 hid_t returnValue = -1;
1132 return(returnValue);
1135 std::vector<size_t> base::DataDimensions(
const std::string &inName)
1138 std::vector<size_t> dataDimensions;
1139 std::ostream &messageStream(*messageStreamPtr);
1140 hid_t dataID = OpenDataSet(inName);
1142 return(dataDimensions);
1143 hid_t dataSpace = H5Dget_space(dataID);
1146 return(dataDimensions);
1148 int numSpaceDim = H5Sget_simple_extent_ndims(dataSpace);
1149 if(numSpaceDim <= 0){
1150 H5Sclose(dataSpace);
1152 return(dataDimensions);
1154 std::vector<hsize_t> spaceDims(numSpaceDim,0);
1155 dataDimensions.resize(numSpaceDim,0);
1156 herr_t h5Status = H5Sget_simple_extent_dims(dataSpace,&spaceDims[0],NULL);
1158 H5Sclose(dataSpace);
1160 return(dataDimensions);
1162 for(
size_t iDim = 0;iDim < numSpaceDim;iDim++)
1163 dataDimensions[iDim] = spaceDims[iDim];
1165 H5Sclose(dataSpace);
1167 return(dataDimensions);
1170 std::vector<size_t> base::AttributeDimensions(
const std::string &inName)
1173 std::vector<size_t> attDimensions;
1174 std::ostream &messageStream(*messageStreamPtr);
1175 hid_t attID = OpenAttribute(inName);
1177 return(attDimensions);
1178 hid_t attSpace = H5Aget_space(attID);
1181 return(attDimensions);
1183 int numSpaceDim = H5Sget_simple_extent_ndims(attSpace);
1184 if(numSpaceDim <= 0){
1187 return(attDimensions);
1189 std::vector<hsize_t> spaceDims(numSpaceDim,0);
1190 attDimensions.resize(numSpaceDim,0);
1191 herr_t h5Status = H5Sget_simple_extent_dims(attSpace,&spaceDims[0],NULL);
1195 return(attDimensions);
1197 for(
size_t iDim = 0;iDim < numSpaceDim;iDim++)
1198 attDimensions[iDim] = spaceDims[iDim];
1201 return(attDimensions);
1204 int base::InitializeHyperSlab(std::vector<size_t> &inGlobalSize,
1205 std::vector<size_t> &inLocalSize,
1206 std::vector<size_t> &inLocalStart)
1210 hsize_t numDim = inGlobalSize.size();
1212 std::vector<hsize_t> globalSize(numDim,1);
1213 std::vector<hsize_t> localSize(numDim,1);
1214 std::vector<hsize_t> localStart(numDim,0);
1216 for(
int i = 0;i < numDim;i++){
1217 numPoints *= inLocalSize[i];
1218 globalSize[i] = inGlobalSize[i];
1219 localSize[i] = inLocalSize[i];
1220 localStart[i] = inLocalStart[i];
1224 H5Sclose(globalSlab);
1226 globalSlab = H5Screate_simple(numDim,&globalSize[0],NULL);
1228 *messageStreamPtr <<
"Unable to create space for the HDF global grid." 1234 H5Sclose(localSlab);
1236 localSlab = H5Screate_simple(numDim,&localSize[0],NULL);
1239 *messageStreamPtr <<
"Unable to create space for the HDF local grid." 1244 if(H5Sselect_hyperslab(globalSlab,H5S_SELECT_SET,
1245 &localStart[0],NULL,&localSize[0],NULL) < 0){
1246 *messageStreamPtr <<
"Unable to select local hyperslab." << std::endl;
1253 int base::WriteHyperSlab(
const std::string &inName,
1254 const std::vector<size_t> &globalSize,
1255 const std::vector<size_t> &localStart,
1256 const std::vector<size_t> &localSize,
1257 std::vector<double> &inDataVec)
1259 std::ostream &messageStream(*messageStreamPtr);
1262 hid_t fileSpace = -1;
1263 if(!Exists(inName)){
1264 std::string locationName;
1265 std::string dataSetName;
1267 if(ResolveName(inName,locationName,dataSetName,parentId)){
1270 hid_t dataType = H5T_NATIVE_DOUBLE;
1271 fileSpace = CreateDataSpace(globalSize);
1274 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1275 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1277 H5Sclose(fileSpace);
1281 dataID = OpenDataSet(inName);
1284 fileSpace = H5Dget_space(dataID);
1291 size_t numDim = localStart.size();
1292 if(localSize.size() != numDim){
1294 H5Sclose(fileSpace);
1299 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1300 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1301 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1302 NULL,&h5LocalSize[0],NULL);
1304 H5Sclose(fileSpace);
1309 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
1311 H5Sclose(fileSpace);
1316 size_t numLocalPoints = 1;
1317 for(
size_t iDim = 0;iDim < numDim;iDim++)
1318 numLocalPoints *= localSize[iDim];
1320 if(inDataVec.size() != numLocalPoints){
1321 H5Sclose(fileSpace);
1322 H5Sclose(localSpace);
1327 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1328 if(collectiveMode && (commPtr != NULL)){
1329 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1332 h5Status = H5Dwrite(dataID,H5T_NATIVE_DOUBLE,localSpace,
1333 fileSpace,xferProperties,&inDataVec[0]);
1335 H5Sclose(fileSpace);
1336 H5Sclose(localSpace);
1337 H5Pclose(xferProperties);
1347 int base::WriteHyperSlab(
const std::string &inName,
1348 const std::vector<size_t> &globalSize,
1349 const std::vector<size_t> &localStart,
1350 const std::vector<size_t> &localSize,
1351 const double *inDataPtr)
1353 std::ostream &messageStream(*messageStreamPtr);
1356 hid_t fileSpace = -1;
1357 if(!Exists(inName)){
1358 std::string locationName;
1359 std::string dataSetName;
1361 if(ResolveName(inName,locationName,dataSetName,parentId)){
1364 hid_t dataType = H5T_NATIVE_DOUBLE;
1365 fileSpace = CreateDataSpace(globalSize);
1368 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1369 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1371 H5Sclose(fileSpace);
1375 dataID = OpenDataSet(inName);
1378 fileSpace = H5Dget_space(dataID);
1385 size_t numDim = localStart.size();
1386 if(localSize.size() != numDim){
1388 H5Sclose(fileSpace);
1393 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1394 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1395 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1396 NULL,&h5LocalSize[0],NULL);
1398 H5Sclose(fileSpace);
1403 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
1405 H5Sclose(fileSpace);
1410 size_t numLocalPoints = 1;
1411 for(
size_t iDim = 0;iDim < numDim;iDim++)
1412 numLocalPoints *= localSize[iDim];
1421 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1422 if(collectiveMode && (commPtr != NULL)){
1423 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1426 h5Status = H5Dwrite(dataID,H5T_NATIVE_DOUBLE,localSpace,
1427 fileSpace,xferProperties,inDataPtr);
1429 H5Sclose(fileSpace);
1430 H5Sclose(localSpace);
1431 H5Pclose(xferProperties);
1440 int base::WriteHyperSlab(
const std::string &inName,
1441 const std::vector<size_t> &globalSize,
1442 const std::vector<size_t> &localStart,
1443 const std::vector<size_t> &localSize,
1444 const std::vector<size_t> &bufferStart,
1446 const double *inDataPtr)
1448 std::ostream &messageStream(*messageStreamPtr);
1451 hid_t fileSpace = -1;
1452 if(!Exists(inName)){
1453 std::string locationName;
1454 std::string dataSetName;
1456 if(ResolveName(inName,locationName,dataSetName,parentId)){
1459 hid_t dataType = H5T_NATIVE_DOUBLE;
1460 fileSpace = CreateDataSpace(globalSize);
1463 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1464 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1466 H5Sclose(fileSpace);
1470 dataID = OpenDataSet(inName);
1473 fileSpace = H5Dget_space(dataID);
1480 size_t numDim = localStart.size();
1481 if(localSize.size() != numDim){
1483 H5Sclose(fileSpace);
1488 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1489 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1490 std::vector<hsize_t> h5BufferStart(bufferStart.begin(),bufferStart.end());
1491 std::vector<hsize_t> h5BufferSize(bufferSize.begin(),bufferSize.end());
1493 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1494 NULL,&h5LocalSize[0],NULL);
1496 H5Sclose(fileSpace);
1501 hid_t localSpace = CreateDataSpace(bufferSize);
1504 H5Sclose(fileSpace);
1510 h5Status = H5Sselect_hyperslab(localSpace,H5S_SELECT_SET,&h5BufferStart[0],
1511 NULL,&h5LocalSize[0],NULL);
1513 H5Sclose(fileSpace);
1514 H5Sclose(localSpace);
1519 size_t numLocalPoints = 1;
1520 for(
size_t iDim = 0;iDim < numDim;iDim++)
1521 numLocalPoints *= localSize[iDim];
1530 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1531 if(collectiveMode && (commPtr != NULL)){
1532 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1536 h5Status = H5Dwrite(dataID,H5T_NATIVE_DOUBLE,localSpace,
1537 fileSpace,xferProperties,inDataPtr);
1539 H5Sclose(fileSpace);
1540 H5Sclose(localSpace);
1541 H5Pclose(xferProperties);
1550 int base::WriteHyperSlab(
const std::string &inName,
1551 const std::vector<size_t> &globalSize,
1552 const std::vector<size_t> &localStart,
1553 const std::vector<size_t> &localSize,
1554 const std::vector<size_t> &bufferStart,
1556 const int *inDataPtr)
1558 std::ostream &messageStream(*messageStreamPtr);
1561 hid_t fileSpace = -1;
1562 hid_t dataType = H5T_NATIVE_INT;
1564 if(!Exists(inName)){
1565 std::string locationName;
1566 std::string dataSetName;
1568 if(ResolveName(inName,locationName,dataSetName,parentId)){
1571 fileSpace = CreateDataSpace(globalSize);
1574 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1575 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1577 H5Sclose(fileSpace);
1581 dataID = OpenDataSet(inName);
1584 fileSpace = H5Dget_space(dataID);
1591 size_t numDim = localStart.size();
1592 if(localSize.size() != numDim){
1594 H5Sclose(fileSpace);
1599 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1600 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1601 std::vector<hsize_t> h5BufferStart(bufferStart.begin(),bufferStart.end());
1602 std::vector<hsize_t> h5BufferSize(bufferSize.begin(),bufferSize.end());
1604 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1605 NULL,&h5LocalSize[0],NULL);
1607 H5Sclose(fileSpace);
1612 hid_t localSpace = CreateDataSpace(bufferSize);
1615 H5Sclose(fileSpace);
1621 h5Status = H5Sselect_hyperslab(localSpace,H5S_SELECT_SET,&h5BufferStart[0],
1622 NULL,&h5LocalSize[0],NULL);
1624 H5Sclose(fileSpace);
1625 H5Sclose(localSpace);
1630 size_t numLocalPoints = 1;
1631 for(
size_t iDim = 0;iDim < numDim;iDim++)
1632 numLocalPoints *= localSize[iDim];
1641 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1642 if(collectiveMode && (commPtr != NULL)){
1643 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1647 h5Status = H5Dwrite(dataID,dataType,localSpace,
1648 fileSpace,xferProperties,inDataPtr);
1650 H5Sclose(fileSpace);
1651 H5Sclose(localSpace);
1652 H5Pclose(xferProperties);
1661 int base::WriteHyperSlab(
const std::string &inName,
1662 const std::vector<size_t> &globalSize,
1663 const std::vector<size_t> &localStart,
1664 const std::vector<size_t> &localSize,
1665 const std::vector<size_t> &bufferStart,
1667 const char *inDataPtr)
1669 std::ostream &messageStream(*messageStreamPtr);
1672 hid_t fileSpace = -1;
1673 hid_t dataType = H5T_NATIVE_CHAR;
1675 if(!Exists(inName)){
1676 std::string locationName;
1677 std::string dataSetName;
1679 if(ResolveName(inName,locationName,dataSetName,parentId)){
1682 fileSpace = CreateDataSpace(globalSize);
1685 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1686 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1688 H5Sclose(fileSpace);
1692 dataID = OpenDataSet(inName);
1695 fileSpace = H5Dget_space(dataID);
1702 size_t numDim = localStart.size();
1703 if(localSize.size() != numDim){
1705 H5Sclose(fileSpace);
1710 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1711 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1712 std::vector<hsize_t> h5BufferStart(bufferStart.begin(),bufferStart.end());
1713 std::vector<hsize_t> h5BufferSize(bufferSize.begin(),bufferSize.end());
1715 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1716 NULL,&h5LocalSize[0],NULL);
1718 H5Sclose(fileSpace);
1723 hid_t localSpace = CreateDataSpace(bufferSize);
1726 H5Sclose(fileSpace);
1732 h5Status = H5Sselect_hyperslab(localSpace,H5S_SELECT_SET,&h5BufferStart[0],
1733 NULL,&h5LocalSize[0],NULL);
1735 H5Sclose(fileSpace);
1736 H5Sclose(localSpace);
1741 size_t numLocalPoints = 1;
1742 for(
size_t iDim = 0;iDim < numDim;iDim++)
1743 numLocalPoints *= localSize[iDim];
1752 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1753 if(collectiveMode && (commPtr != NULL)){
1754 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1758 h5Status = H5Dwrite(dataID,dataType,localSpace,
1759 fileSpace,xferProperties,inDataPtr);
1761 H5Sclose(fileSpace);
1762 H5Sclose(localSpace);
1763 H5Pclose(xferProperties);
1772 int base::WriteHyperSlab(
const std::string &inName,
1773 const std::vector<size_t> &globalSize,
1774 const std::vector<size_t> &localStart,
1775 const std::vector<size_t> &localSize,
1776 std::vector<int> &inDataVec)
1778 std::ostream &messageStream(*messageStreamPtr);
1781 hid_t fileSpace = -1;
1782 if(!Exists(inName)){
1783 std::string locationName;
1784 std::string dataSetName;
1786 if(ResolveName(inName,locationName,dataSetName,parentId)){
1789 hid_t dataType = H5T_NATIVE_INT;
1790 fileSpace = CreateDataSpace(globalSize);
1793 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1794 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1796 H5Sclose(fileSpace);
1800 dataID = OpenDataSet(inName);
1803 fileSpace = H5Dget_space(dataID);
1810 size_t numDim = localStart.size();
1811 if(localSize.size() != numDim){
1813 H5Sclose(fileSpace);
1818 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1819 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1820 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1821 NULL,&h5LocalSize[0],NULL);
1823 H5Sclose(fileSpace);
1828 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
1830 H5Sclose(fileSpace);
1835 size_t numLocalPoints = 1;
1836 for(
size_t iDim = 0;iDim < numDim;iDim++)
1837 numLocalPoints *= localSize[iDim];
1839 if(inDataVec.size() != numLocalPoints){
1840 H5Sclose(fileSpace);
1841 H5Sclose(localSpace);
1846 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1847 if(collectiveMode && (commPtr != NULL)){
1848 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1851 h5Status = H5Dwrite(dataID,H5T_NATIVE_INT,localSpace,
1852 fileSpace,xferProperties,&inDataVec[0]);
1854 H5Sclose(fileSpace);
1855 H5Sclose(localSpace);
1856 H5Pclose(xferProperties);
1866 int base::WriteHyperSlab(
const std::string &inName,
1867 const std::vector<size_t> &globalSize,
1868 const std::vector<size_t> &localStart,
1869 const std::vector<size_t> &localSize,
1870 std::vector<size_t> &inDataVec)
1872 std::ostream &messageStream(*messageStreamPtr);
1875 hid_t fileSpace = -1;
1876 if(!Exists(inName)){
1877 std::string locationName;
1878 std::string dataSetName;
1880 if(ResolveName(inName,locationName,dataSetName,parentId)){
1883 hid_t dataType = H5T_NATIVE_HSIZE;
1884 fileSpace = CreateDataSpace(globalSize);
1887 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1888 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1890 H5Sclose(fileSpace);
1894 dataID = OpenDataSet(inName);
1897 fileSpace = H5Dget_space(dataID);
1904 size_t numDim = localStart.size();
1905 if(localSize.size() != numDim){
1907 H5Sclose(fileSpace);
1912 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
1913 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
1914 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
1915 NULL,&h5LocalSize[0],NULL);
1917 H5Sclose(fileSpace);
1922 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
1924 H5Sclose(fileSpace);
1929 size_t numLocalPoints = 1;
1930 for(
size_t iDim = 0;iDim < numDim;iDim++)
1931 numLocalPoints *= localSize[iDim];
1933 if(inDataVec.size() != numLocalPoints){
1934 H5Sclose(fileSpace);
1935 H5Sclose(localSpace);
1940 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
1941 if(collectiveMode && (commPtr != NULL)){
1942 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
1945 h5Status = H5Dwrite(dataID,H5T_NATIVE_HSIZE,localSpace,
1946 fileSpace,xferProperties,&inDataVec[0]);
1948 H5Sclose(fileSpace);
1949 H5Sclose(localSpace);
1950 H5Pclose(xferProperties);
1959 int base::WriteHyperSlab(
const std::string &inName,
1960 const std::vector<size_t> &globalSize,
1961 const std::vector<size_t> &localStart,
1962 const std::vector<size_t> &localSize,
1963 std::vector<char> &inDataVec)
1965 std::ostream &messageStream(*messageStreamPtr);
1968 hid_t fileSpace = -1;
1969 if(!Exists(inName)){
1970 std::string locationName;
1971 std::string dataSetName;
1973 if(ResolveName(inName,locationName,dataSetName,parentId)){
1976 hid_t dataType = H5T_NATIVE_CHAR;
1977 fileSpace = CreateDataSpace(globalSize);
1980 dataID = H5Dcreate(parentId,inName.c_str(),dataType,fileSpace,
1981 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
1983 H5Sclose(fileSpace);
1987 dataID = OpenDataSet(inName);
1990 fileSpace = H5Dget_space(dataID);
1997 size_t numDim = localStart.size();
1998 if(localSize.size() != numDim){
2000 H5Sclose(fileSpace);
2005 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
2006 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
2007 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
2008 NULL,&h5LocalSize[0],NULL);
2010 H5Sclose(fileSpace);
2015 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
2017 H5Sclose(fileSpace);
2022 size_t numLocalPoints = 1;
2023 for(
size_t iDim = 0;iDim < numDim;iDim++)
2024 numLocalPoints *= localSize[iDim];
2026 if(inDataVec.size() != numLocalPoints){
2027 H5Sclose(fileSpace);
2028 H5Sclose(localSpace);
2033 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
2034 if(collectiveMode && (commPtr != NULL)){
2035 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
2038 h5Status = H5Dwrite(dataID,H5T_NATIVE_CHAR,localSpace,
2039 fileSpace,xferProperties,&inDataVec[0]);
2041 H5Sclose(fileSpace);
2042 H5Sclose(localSpace);
2043 H5Pclose(xferProperties);
2052 int base::WriteHyperSlab(
const std::string &inName,
2053 const std::vector<size_t> &localStart,
2054 const std::vector<size_t> &localSize,
2055 std::vector<double> &inDataVec)
2057 std::ostream &messageStream(*messageStreamPtr);
2060 hid_t fileSpace = -1;
2063 dataID = OpenDataSet(inName);
2066 fileSpace = H5Dget_space(dataID);
2072 size_t numDim = localStart.size();
2073 if(localSize.size() != numDim){
2075 H5Sclose(fileSpace);
2080 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
2081 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
2082 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
2083 NULL,&h5LocalSize[0],NULL);
2085 H5Sclose(fileSpace);
2090 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
2092 H5Sclose(fileSpace);
2097 size_t numLocalPoints = 1;
2098 for(
size_t iDim = 0;iDim < numDim;iDim++)
2099 numLocalPoints *= localSize[iDim];
2101 if(inDataVec.size() != numLocalPoints){
2102 H5Sclose(fileSpace);
2103 H5Sclose(localSpace);
2108 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
2109 if(collectiveMode && (commPtr != NULL)){
2110 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
2113 h5Status = H5Dwrite(dataID,H5T_NATIVE_DOUBLE,localSpace,
2114 fileSpace,xferProperties,&inDataVec[0]);
2116 H5Sclose(fileSpace);
2117 H5Sclose(localSpace);
2118 H5Pclose(xferProperties);
2127 int base::WriteHyperSlab(
const std::string &inName,
2128 const std::vector<size_t> &localStart,
2129 const std::vector<size_t> &localSize,
2130 std::vector<int> &inDataVec)
2132 std::ostream &messageStream(*messageStreamPtr);
2135 hid_t fileSpace = -1;
2138 dataID = OpenDataSet(inName);
2141 fileSpace = H5Dget_space(dataID);
2147 size_t numDim = localStart.size();
2148 if(localSize.size() != numDim){
2150 H5Sclose(fileSpace);
2155 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
2156 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
2157 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
2158 NULL,&h5LocalSize[0],NULL);
2160 H5Sclose(fileSpace);
2165 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
2167 H5Sclose(fileSpace);
2172 size_t numLocalPoints = 1;
2173 for(
size_t iDim = 0;iDim < numDim;iDim++)
2174 numLocalPoints *= localSize[iDim];
2176 if(inDataVec.size() != numLocalPoints){
2177 H5Sclose(fileSpace);
2178 H5Sclose(localSpace);
2183 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
2184 if(collectiveMode && (commPtr != NULL)){
2185 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
2188 h5Status = H5Dwrite(dataID,H5T_NATIVE_INT,localSpace,
2189 fileSpace,xferProperties,&inDataVec[0]);
2191 H5Sclose(fileSpace);
2192 H5Sclose(localSpace);
2193 H5Pclose(xferProperties);
2202 int base::WriteHyperSlab(
const std::string &inName,
2203 const std::vector<size_t> &localStart,
2204 const std::vector<size_t> &localSize,
2205 std::vector<char> &inDataVec)
2207 std::ostream &messageStream(*messageStreamPtr);
2210 hid_t fileSpace = -1;
2213 dataID = OpenDataSet(inName);
2216 fileSpace = H5Dget_space(dataID);
2222 size_t numDim = localStart.size();
2223 if(localSize.size() != numDim){
2225 H5Sclose(fileSpace);
2230 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
2231 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
2232 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
2233 NULL,&h5LocalSize[0],NULL);
2235 H5Sclose(fileSpace);
2240 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
2242 H5Sclose(fileSpace);
2247 size_t numLocalPoints = 1;
2248 for(
size_t iDim = 0;iDim < numDim;iDim++)
2249 numLocalPoints *= localSize[iDim];
2251 if(inDataVec.size() != numLocalPoints){
2252 H5Sclose(fileSpace);
2253 H5Sclose(localSpace);
2258 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
2259 if(collectiveMode && (commPtr != NULL)){
2260 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
2263 h5Status = H5Dwrite(dataID,H5T_NATIVE_CHAR,localSpace,
2264 fileSpace,xferProperties,&inDataVec[0]);
2266 H5Sclose(fileSpace);
2267 H5Sclose(localSpace);
2268 H5Pclose(xferProperties);
2277 int base::WriteHyperSlab(
const std::string &inName,
2278 const std::vector<size_t> &localStart,
2279 const std::vector<size_t> &localSize,
2280 std::vector<size_t> &inDataVec)
2282 std::ostream &messageStream(*messageStreamPtr);
2285 hid_t fileSpace = -1;
2288 dataID = OpenDataSet(inName);
2291 fileSpace = H5Dget_space(dataID);
2297 size_t numDim = localStart.size();
2298 if(localSize.size() != numDim){
2300 H5Sclose(fileSpace);
2305 std::vector<hsize_t> h5LocalStart(localStart.begin(),localStart.end());
2306 std::vector<hsize_t> h5LocalSize(localSize.begin(),localSize.end());
2307 herr_t h5Status = H5Sselect_hyperslab(fileSpace,H5S_SELECT_SET,&h5LocalStart[0],
2308 NULL,&h5LocalSize[0],NULL);
2310 H5Sclose(fileSpace);
2315 hid_t localSpace = H5Screate_simple(numDim,&h5LocalSize[0],NULL);
2317 H5Sclose(fileSpace);
2322 size_t numLocalPoints = 1;
2323 for(
size_t iDim = 0;iDim < numDim;iDim++)
2324 numLocalPoints *= localSize[iDim];
2326 if(inDataVec.size() != numLocalPoints){
2327 H5Sclose(fileSpace);
2328 H5Sclose(localSpace);
2333 hid_t xferProperties = H5Pcreate(H5P_DATASET_XFER);
2334 if(collectiveMode && (commPtr != NULL)){
2335 H5Pset_dxpl_mpio(xferProperties,H5FD_MPIO_COLLECTIVE);
2338 h5Status = H5Dwrite(dataID,H5T_NATIVE_HSIZE,localSpace,
2339 fileSpace,xferProperties,&inDataVec[0]);
2341 H5Sclose(fileSpace);
2342 H5Sclose(localSpace);
2343 H5Pclose(xferProperties);
2353 int base::CreateGroup(
const std::string &inName)
2355 std::string groupName;
2356 std::string locationName;
2358 if(ResolveName(inName,locationName,groupName,parentId))
2360 hid_t groupId = H5Gcreate(parentId,inName.c_str(),H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2366 hid_t base::CreateDataSpace(
const std::vector<size_t> &dataSpaceDims)
2368 hsize_t numDim = dataSpaceDims.size();
2374 std::vector<hsize_t> hdf5SpaceDimensions(dataSpaceDims.begin(),dataSpaceDims.end());
2375 hid_t dataSpace = H5Screate_simple(numDim,&hdf5SpaceDimensions[0],NULL);
2380 int base::CreateDataSet(
const std::string &inName,
2381 const std::vector<size_t> &dataSpaceDims,
2384 std::string locationName;
2385 std::string dataSetName;
2387 if(ResolveName(inName,locationName,dataSetName,parentId)){
2390 hid_t dataType = H5T_NATIVE_INT;
2391 switch(elementSize){
2393 dataType = H5T_NATIVE_CHAR;
2396 dataType = H5T_NATIVE_INT;
2400 dataType = H5T_NATIVE_DOUBLE;
2402 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2407 hid_t dataSet = H5Dcreate(parentId,inName.c_str(),dataType,dataSpace,
2408 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2409 H5Sclose(dataSpace);
2415 int base::CreateDataSet(
const std::string &inName,
2416 const std::vector<size_t> &dataSpaceDims,
2417 std::vector<double> &inData)
2419 std::string locationName;
2420 std::string dataSetName;
2422 if(ResolveName(inName,locationName,dataSetName,parentId)){
2425 hid_t dataType = H5T_NATIVE_DOUBLE;
2426 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2431 hid_t dataSet = H5Dcreate(parentId,inName.c_str(),dataType,dataSpace,
2432 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2434 H5Sclose(dataSpace);
2439 herr_t status = H5Dwrite(dataSet,dataType,H5S_ALL,H5S_ALL,
2440 H5P_DEFAULT,&inData[0]);
2441 H5Sclose(dataSpace);
2448 int base::CreateDataSet(
const std::string &inName,
2449 const std::vector<size_t> &dataSpaceDims,
2450 std::vector<int> &inData)
2452 std::string locationName;
2453 std::string dataSetName;
2455 if(ResolveName(inName,locationName,dataSetName,parentId)){
2458 hid_t dataType = H5T_NATIVE_INT;
2459 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2464 hid_t dataSet = H5Dcreate(parentId,inName.c_str(),dataType,dataSpace,
2465 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2467 H5Sclose(dataSpace);
2471 herr_t status = H5Dwrite(dataSet,dataType,H5S_ALL,H5S_ALL,
2472 H5P_DEFAULT,&inData[0]);
2475 H5Sclose(dataSpace);
2482 int base::CreateAttribute(
const std::string &inName,
2483 const std::vector<size_t> &dataSpaceDims,
2486 std::string locationName;
2487 std::string attName;
2489 if(ResolveName(inName,locationName,attName,parentId)){
2492 hid_t dataType = H5T_NATIVE_INT;
2493 switch(elementSize){
2495 dataType = H5T_NATIVE_CHAR;
2498 dataType = H5T_NATIVE_INT;
2502 dataType = H5T_NATIVE_DOUBLE;
2504 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2507 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2508 attName.c_str(),dataType,dataSpace,
2509 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2510 if(attributeId <= 0){
2511 H5Sclose(dataSpace);
2515 H5Sclose(dataSpace);
2517 H5Aclose(attributeId);
2523 int base::CreateAttribute(
const std::string &inName,
2524 const std::vector<size_t> &dataSpaceDims,
2527 std::string locationName;
2528 std::string attName;
2530 if(ResolveName(inName,locationName,attName,parentId)){
2533 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2536 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2537 attName.c_str(),H5T_NATIVE_INT,dataSpace,
2538 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2539 if(attributeId <= 0){
2540 H5Sclose(dataSpace);
2543 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_INT,inBuf);
2545 H5Sclose(dataSpace);
2546 H5Aclose(attributeId);
2555 int base::CreateAttribute(
const std::string &inName,
const std::vector<size_t> &dataSpaceDims,
2556 const std::vector<int> &inData)
2558 std::string locationName;
2559 std::string attName;
2561 if(ResolveName(inName,locationName,attName,parentId)){
2564 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2567 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2568 attName.c_str(),H5T_NATIVE_INT,dataSpace,
2569 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2570 if(attributeId <= 0){
2571 H5Sclose(dataSpace);
2574 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_INT,&inData[0]);
2576 H5Sclose(dataSpace);
2577 H5Aclose(attributeId);
2585 int base::CreateAttribute(
const std::string &inName,
2586 const std::vector<size_t> &dataSpaceDims,
2587 const double *inBuf)
2589 std::string locationName;
2590 std::string attName;
2592 if(ResolveName(inName,locationName,attName,parentId)){
2595 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2598 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2599 attName.c_str(),H5T_NATIVE_DOUBLE,dataSpace,
2600 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2601 if(attributeId <= 0){
2602 H5Sclose(dataSpace);
2606 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_DOUBLE,inBuf);
2608 H5Sclose(dataSpace);
2609 H5Aclose(attributeId);
2617 int base::CreateAttribute(
const std::string &inName,
2618 const std::vector<size_t> &dataSpaceDims,
2619 const std::vector<double> &inData)
2621 std::string locationName;
2622 std::string attName;
2624 if(ResolveName(inName,locationName,attName,parentId)){
2627 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2630 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2631 attName.c_str(),H5T_NATIVE_DOUBLE,dataSpace,
2632 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2633 if(attributeId <= 0){
2634 H5Sclose(dataSpace);
2638 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_DOUBLE,&inData[0]);
2640 H5Sclose(dataSpace);
2641 H5Aclose(attributeId);
2649 int base::CreateAttribute(
const std::string &inName,
2650 const std::vector<size_t> &dataSpaceDims,
2651 const size_t *inBuf)
2653 std::string locationName;
2654 std::string attName;
2656 if(ResolveName(inName,locationName,attName,parentId)){
2659 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2662 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2663 attName.c_str(),H5T_NATIVE_HSIZE,dataSpace,
2664 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2665 if(attributeId <= 0){
2666 H5Sclose(dataSpace);
2670 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_HSIZE,inBuf);
2672 H5Sclose(dataSpace);
2673 H5Aclose(attributeId);
2681 int base::CreateAttribute(
const std::string &inName,
2682 const std::vector<size_t> &dataSpaceDims,
2683 const std::vector<size_t> &inData)
2685 std::string locationName;
2686 std::string attName;
2688 if(ResolveName(inName,locationName,attName,parentId)){
2691 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2695 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2696 attName.c_str(),H5T_NATIVE_HSIZE,dataSpace,
2697 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2698 if(attributeId <= 0){
2699 H5Sclose(dataSpace);
2703 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_HSIZE,&inData[0]);
2705 H5Sclose(dataSpace);
2706 H5Aclose(attributeId);
2714 int base::CreateAttribute(
const std::string &inName,
2715 const std::vector<size_t> &dataSpaceDims,
2718 std::string locationName;
2719 std::string attName;
2721 if(ResolveName(inName,locationName,attName,parentId)){
2724 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2727 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2728 attName.c_str(),H5T_NATIVE_CHAR,dataSpace,
2729 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2730 if(attributeId <= 0){
2731 H5Sclose(dataSpace);
2735 herr_t retVal = H5Awrite(attributeId,H5T_NATIVE_CHAR,inBuf);
2737 H5Sclose(dataSpace);
2738 H5Aclose(attributeId);
2746 int base::CreateAttribute(
const std::string &inName,
2747 const std::string &inData)
2749 std::string locationName;
2750 std::string attName;
2752 if(ResolveName(inName,locationName,attName,parentId)){
2756 std::vector<size_t> dataSpaceDims(1,1);
2757 hid_t dataSpace = CreateDataSpace(dataSpaceDims);
2761 size_t attributeSize = inData.size() + 1;
2762 hid_t typeID = H5Tcopy(H5T_C_S1);
2763 H5Tset_size(typeID,inData.size()+1);
2764 const char *stringToWrite = inData.c_str();
2767 hid_t attributeId = H5Acreate_by_name(parentId,locationName.c_str(),
2768 attName.c_str(),typeID,dataSpace,
2769 H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
2770 if(attributeId <= 0){
2771 H5Sclose(dataSpace);
2776 herr_t retVal = H5Awrite(attributeId,typeID,stringToWrite);
2779 H5Sclose(dataSpace);
2780 H5Aclose(attributeId);
std::vector< pcpp::field::metadataset > domainStateDictionaries
void OpenFileTag(std::ostream &outStream)
void size_t int size_t int size_t int int int int double int int double double *void size_t int size_t int int int int int double int size_t size_t size_t double double *void size_t int size_t int size_t size_t int double int double double *void size_t size_t * bufferSize
void CloseFileTag(std::ostream &outStream)
void const size_t * numPoints
int ReadAttribute(const std::string &inName, int *inBuf)
std::vector< std::vector< std::string > > geometryGridNames
Grid names for each geometry.
void CloseGridTag(std::ostream &outStream)
pcpp::field::metadataset simulationParamDictionary
Dictionaries summarizing the attribute and datatsets in the file.
void const size_t const size_t * gridSizes
int FileInfo(const std::string &hdfFileName, pcpp::io::simfileinfo &fileInfo, std::ostream &messageStream)
void RenewStream(std::ostringstream &outStream)
int LegacyFileInfo(pcpp::io::hdf5::base &hdf5File, simfileinfo &fileInfo, std::ostream &messageStream)
bool Exists(const std::string &linkName)
void const size_t const size_t const size_t const int const int * gridType
std::vector< std::vector< std::string > > domainGridPaths
Path to grid data (including file name, geometry and grid names)
std::vector< int > gridNumDimensions
std::bitset< NUMFORMATBITS > formatBits
int WriteGridData(const std::string &fileName, const std::string &dataName, unsigned int dataSize, const std::string &dataPath, const std::vector< size_t > &gridSize, std::ostream &outStream)
void const size_t const size_t const size_t const double const double * x
void OpenGridTag(const std::string &gridName, const std::string &gridType, double inTime, std::ostream &outStream)
bool AttributeExists(const std::string &inName)
int PlasCom2FileInfo(pcpp::io::hdf5::base &hdf5File, simfileinfo &fileInfo, std::ostream &messageStream)
int Check(comm::Ops op=comm::MAXOP)
std::vector< std::vector< size_t > > gridSizes
Main encapsulation of MPI.
pcpp::field::metadataset simulationStateDictionary
std::vector< double > legacyHeader
Time Re Pr from PlasComCM.
int WriteGridSection(const std::string &topoType, const std::string &geomType, const std::string &fileName, const std::string &gridPath, const std::vector< size_t > &gridSize, std::ostream &outStream)
std::vector< std::vector< std::string > > domainGridNames
Domain-specific grid names for which there is data.
std::vector< std::string > geometryNames
Names of all geometries in file.
std::vector< std::string > gridNames
Full grid names (geometryName:gridName)
std::vector< std::vector< std::vector< size_t > > > geometryGridSizes
Sizes for each geometry grid.
int StreamBroadCast(DataType &inData, int root_rank=0)
std::vector< pcpp::field::metadataset > domainParamDictionaries
std::vector< std::string > domainNames