14 #define CHOFFSET(object, member) (int)((char*)&(object.member) - (char*)&object)    16 #ifdef CH_USE_HDF5  // if you don't have CH_USE_HDF5, then this file is useless    43 #include "BoxTools_ExternC_Mangler.H"     45 #include "NamespaceHeader.H"    55   for (
int i=0; i<b.size(); ++i) b[i]= &(a_allocatedBuffers[i][0]);
    56   read(item, b, box, comps);
    97                const int& a_refRatio,
   111               bool setGhost = 
false);
   123               bool setGhost = 
false);
   139           const std::string& 
name = 
"boxes");
   150           const std::string& a_name,
   153           bool  newForm = 
false);
   166           const std::string& a_name,
   209          const std::string& 
name = 
"boxes");
   236                   const std::string& a_dataName = 
"data" );
   248          const std::string& a_name,
   251          bool redefineData = 
true);
   278          const std::string& a_name,
   281          bool redefineData = 
true);
   347         const std::string& a_filename,
   349         const char *a_globalGroupName=
"Chombo_global");
   383         const std::string& a_filename,
   385         const char *a_globalGroupName=
"Chombo_global");
   409   void setGroupToLevel(
int a_level);
   419   int setGroup(
const std::string& groupAbsPath);
   428   int pushGroup( 
const std::string& grp );
   447   const std::string& getGroup() 
const;
   450   const hid_t& fileID() 
const;
   451   const hid_t& groupID() 
const;
   455   static map<std::string, std::string> 
groups;
   472   static void   initialize();
   566   int writeToLocation(hid_t loc_id) 
const;
   567   int readFromLocation(hid_t loc_id);
   573   static herr_t attributeScan(hid_t loc_id, 
const char *
name, 
void *opdata);
   640                  const string&    a_name,
   643                  const bool       a_newForm = 
false);
   670   char m_dataname[128];               
   689 #if ( H5_VERS_MAJOR == 1 && H5_VERS_MINOR > 6 )   692 #if ( H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 6 && H5_VERS_RELEASE >= 4 )   700 hid_t 
H5Type(
const T* dummy);
   703 hid_t 
H5Type(
const int* dummy);
   706 hid_t 
H5Type(
const long long* dummy);
   709 hid_t 
H5Type(
const float* dummy);
   712 hid_t 
H5Type(
const double* dummy);
   734                 const std::string& 
name,
   742                    const std::string& name,
   773 #include "NamespaceFooter.H"   781 int linearSize(
const CH_XDIR::OffsetBuffer& a_input);
   785 void linearIn(CH_XDIR::OffsetBuffer& a_outputT, 
const void* 
const a_inBuf);
   789 void linearOut(
void* 
const a_outBuf, 
const CH_XDIR::OffsetBuffer& a_inputT);
   796 #include "NamespaceHeader.H"   804   a_types[0] = H5T_NATIVE_INT;
   811   a_types[0] = H5T_NATIVE_CHAR;
   901   a_sizes[0] = boxNodes.
numPts() * comps.
size();
   911   const char* name = 
"FArrayBox";
   920   const char* name = 
"BaseFab<int>";
   929   const char* name = 
"BaseFab<char>";
   940   a_types[0] = H5T_NATIVE_CHAR;
   947   a_sizes[0] = item.
size(box, comps);
   954   item.linearOut(a_allocatedBuffers[0], box, comps);
   961   item.linearIn(a_allocatedBuffers[0], box, comps);
   965 inline const char* 
name(
const T& a_dummySpecializationArg)
   967   static const char* name = 
"unknown";
   982   for (
int t=0; t<types; t++) offsets[t][0] = 0;
   984   if (T::preAllocatable()==0)
   987       unsigned int index = 1;
   990           Box region = layout[it()];
   991           region.
grow(outputGhost);
   994             dataSize(dummy, thisSize, region, comps);
   996           for (
unsigned int i=0; i<thisSize.
size(); ++i)
  1000               offsets[i][index] = offsets[i][index-1] + thisSize[i];
  1014           Box region = layout[dit()];
  1015           region.
grow(outputGhost);
  1018             dataSize(a_data[dit()], thisSize, region, comps);
  1032       for (
int i=0; i<
numProc(); ++i)
  1035           for (
int num=0; num<offbuf.
index.
size(); num++)
  1037               int index = offbuf.
index[num];
  1038               for (
unsigned int j=0; j<types; ++j)
  1042                   offsets[j][index+1] = offbuf.
offsets[num][j];
  1046       for (
int i=0; i<layout.
size(); i++)
  1048           for (
unsigned int j=0; j<types; ++j)
  1052               offsets[j][i+1] += offsets[j][i];
  1072   CH_TIME(
"getOffsets (prealloc)");
  1076   for (
int t = 0; t != a_numTypes; ++t)
  1078       a_offsets[t][0] = 0;
  1082   unsigned int index = 1;
  1085       Box region = a_layout[it()];
  1086       region.
grow(a_outputGhost);
  1087       dataSize(dummy, thisSize, region, a_comps);
  1088       for (
int i = 0; i != thisSize.
size(); ++i)  
  1091           a_offsets[i][index] = a_offsets[i][index-1] + thisSize[i];
  1103           const std::string& a_name, 
IntVect outputGhost,
  1104           const Interval& in_comps, 
bool newForm)
  1122   hsize_t flatdims[1];
  1129   ch_offset_t offset[1];
  1132   for (
unsigned int i=0; i<types.
size(); ++i)
  1134       flatdims[0] = offsets[i][offsets[i].
size()-1];
  1139           strcpy(dataname, 
"Mask");
  1143           sprintf(dataname, 
"%sRegular", a_name.c_str());
  1148         sprintf(dataname, 
"%s:datatype=%i",a_name.c_str(), i);
  1152         dataspace[i]      = H5Screate_simple(1, flatdims, NULL);
  1158         dataset[i]        = H5Dcreate(a_handle.
groupID(), dataname,
  1160                                       dataspace[i], H5P_DEFAULT);
  1162         dataset[i]        = H5Dcreate2(a_handle.
groupID(), dataname,
  1164                                        dataspace[i], H5P_DEFAULT,
  1165                                        H5P_DEFAULT, H5P_DEFAULT);
  1171   hid_t offsetspace, offsetData;
  1172   for (
unsigned int i=0; i<types.
size(); ++i)
  1174       flatdims[0] =  offsets[i].
size();
  1179           strcpy(dataname, 
"MaskOffsets");
  1183           sprintf(dataname, 
"%sOffsets",a_name.c_str());
  1188         sprintf(dataname, 
"%s:offsets=%i",a_name.c_str(), i);
  1191         CH_TIME(
"H5S_H5D_offsets_create");
  1192         offsetspace =  H5Screate_simple(1, flatdims, NULL);
  1195         offsetData  =   H5Dcreate(a_handle.
groupID(), dataname,
  1196                                   H5T_NATIVE_LLONG, offsetspace, 
  1199         offsetData  =   H5Dcreate2(a_handle.
groupID(), dataname,
  1200                                    H5T_NATIVE_LLONG, offsetspace, 
  1202                                    H5P_DEFAULT,H5P_DEFAULT);
  1209           hid_t memdataspace = H5Screate_simple(1, flatdims, NULL);
  1211           err = H5Dwrite(offsetData, H5T_NATIVE_LLONG, memdataspace, offsetspace,
  1212                          H5P_DEFAULT, &(offsets[i][0]));
  1214           H5Sclose(memdataspace);
  1217         CH_TIME(
"H5S_H5D_offsets_close");
  1218         H5Sclose(offsetspace);
  1219         H5Dclose(offsetData);
  1230     info.
m_intvect[
"outputGhost"] = outputGhost;
  1232     std::string group = a_handle.
getGroup();
  1233     a_handle.
setGroup(group+
"/"+a_name+
"_attributes");
  1242   for (
unsigned int i=0; i<types.
size(); ++i)
  1244       type_size[i] = H5Tget_size(types[i]);
  1261 #ifdef AGGREGATE_BOXES_  1281     CH_TIME(
"ComputeBufferCapacity");
  1285         for (
unsigned int i=0; i<types.
size(); ++i)
  1287             long long size = (offsets[i][index+1] - offsets[i][index])
  1291             if (size > bufferCapacity[i]) 
  1293                 bufferCapacity[i] = size;
  1295 #ifdef AGGREGATE_BOXES_  1296             aggBufferSize[i] += size;
  1302   for (
unsigned int i=0; i<types.
size(); ++i)
  1305       buffers[i] = 
mallocMT(bufferCapacity[i]);
  1306       if (buffers[i] == NULL)
  1308         pout() << 
" i=" << i
  1309                << 
" types.size() = " << types.
size()
  1310                << 
" bufferCapacity[i] = " << (int)bufferCapacity[i]
  1314 #ifdef AGGREGATE_BOXES_  1315       aggBuffers[i] = 
mallocMT(aggBufferSize[i]);
  1316       if (aggBuffers[i] == NULL)
  1318         MayDay::Error(
"memory error in aggregate buffer allocation in write");
  1326 #ifdef TRY_MPI_COLLECTIVES_  1335   int maxNumBoxes = dit.
size();
  1336   int sendBuf = maxNumBoxes;
  1337   int result = MPI_Allreduce(&sendBuf, &maxNumBoxes, 1, MPI_INT,MPI_MAX, Chombo_MPI::comm);
  1338   if (result != MPI_SUCCESS)
  1344   hid_t DXPL = H5Pcreate(H5P_DATASET_XFER);
  1346     H5Pset_dxpl_mpio(DXPL, H5FD_MPIO_COLLECTIVE);
  1353     CH_TIME(
"linearize_H5Dwrite");
  1354 #ifdef AGGREGATE_BOXES_  1357     bool isFirstHyperslab = 
true;
  1363     for(
unsigned int i=0; i<types.
size(); ++i)
  1365         bufferLoc[i] = aggBuffers[i];
  1370         const T& data = a_data[it()];
  1373         box.
grow(outputGhost);
  1377 #ifdef AGGREGATE_BOXES_  1380           for(
unsigned int i=0; i<types.
size(); i++)
  1382               data.linearOut(bufferLoc[i], box, comps);
  1383               char* tempLoc = ((
char*)bufferLoc[i]) + data.size(box,comps);
  1384               bufferLoc[i] = (
void*)tempLoc;
  1388           write(data, buffers, box, comps); 
  1396         for (
unsigned int i=0; i<types.
size(); ++i)
  1398             offset[0] = offsets[i][index];
  1399             count[0] = offsets[i][index+1] - offset[0];
  1400 #ifdef AGGREGATE_BOXES_  1407             aggCount[i] += count[0];
  1408             if (isFirstHyperslab)
  1416                     err =  H5Sselect_hyperslab(dataspace[i], H5S_SELECT_SET,
  1420                     isFirstHyperslab = 
false;
  1424                     H5Sselect_none(dataspace[i]);
  1434                     err =  H5Sselect_hyperslab(dataspace[i], H5S_SELECT_OR,
  1444             hid_t memdataspace=0;
  1447                 err =  H5Sselect_hyperslab(dataspace[i], H5S_SELECT_SET,
  1451                 memdataspace = H5Screate_simple(1, count, NULL);
  1456                 H5Sselect_none(dataspace[i]);
  1457                 H5Sselect_none(memdataspace);
  1465 #ifdef TRY_MPI_COLLECTIVES_  1466               err = H5Dwrite(dataset[i], types[i], memdataspace, dataspace[i],
  1469               err = H5Dwrite(dataset[i], types[i], memdataspace, dataspace[i],
  1470                              H5P_DEFAULT, buffers[i]);
  1474             H5Sclose(memdataspace);
  1478                 pout() << 
"Before goto cleanup" << endl;
  1481 #endif // end of ifdef AGGREGATE_BOXES_   1489 #ifdef AGGREGATE_BOXES_  1490     for(
unsigned int i=0; i<types.
size(); ++i)
  1494             hid_t memdataspace = 0;
  1495             memdataspace = H5Screate_simple(1, &(aggCount[i]), NULL);
  1499 #ifdef TRY_MPI_COLLECTIVES_  1500               err = H5Dwrite(dataset[i], types[i], memdataspace, dataspace[i],
  1501                            DXPL, aggBuffers[i]);
  1503               err = H5Dwrite(dataset[i], types[i], memdataspace, dataspace[i],
  1504                                    H5P_DEFAULT, aggBuffers[i]);
  1507             H5Sclose(memdataspace);
  1511                 pout() << 
"Error! goto cleanup" << endl;
  1517 #ifdef TRY_MPI_COLLECTIVES_  1520             hid_t memdataspace = 0;
  1521             memdataspace = H5Screate_simple(1, &(aggCount[i]), NULL);
  1522             H5Sselect_none(memdataspace);
  1523             H5Sselect_none(dataspace[i]);
  1524             err = H5Dwrite(dataset[i], types[i], memdataspace, dataspace[i],
  1525                            DXPL, aggBuffers[i]);
  1529                 pout() << 
"Before goto cleanup" << endl;
  1535 #else // not using aggregated collective buffering  1536 #ifdef TRY_MPI_COLLECTIVES_  1541     hid_t memdataspace = 0;
  1544     memdataspace = H5Screate_simple(1, count, NULL);
  1545     H5Sselect_none(memdataspace);
  1547     for(
int iwrite = nBoxes; iwrite < maxNumBoxes; iwrite++)
  1549         for (
unsigned int i=0; i<types.
size(); ++i)
  1551             H5Sselect_none(dataspace[i]);
  1554             err = H5Dwrite(dataset[i], types[i], memdataspace, dataspace[i],
  1559                 pout() << 
"Before goto cleanup" << endl;
  1564     H5Sclose(memdataspace);
  1566 #endif // end of #ifdef TRY_MPI_COLLECTIVES_  1567 #endif // end of #ifdef AGGREGATE_BOXES_  1571 #ifdef TRY_MPI_COLLECTIVES_  1578   for (
unsigned int i=0; i<types.
size(); ++i)
  1583         #ifdef AGGREGATE_BOXES_  1589         H5Sclose(dataspace[i]);
  1593         H5Dclose(dataset[i]);
  1602           const std::string& a_name, 
const IntVect& outputGhost, 
const Interval& in_comps)
  1605   CH_TIMER(
"calc minimum in outputGhost",t1);
  1615   std::string group = a_handle.
getGroup();
  1616   a_handle.
setGroup(group+
"/"+a_name+
"_attributes");
  1633       std::string group = a_handle.
getGroup();
  1634       if (a_handle.
setGroup(group+
"/"+a_name+
"_attributes"))
  1636           std::string message = 
"error opening "  1637                                 +a_handle.
getGroup()+
"/"+a_name+
"_attributes" ;
  1643       int ncomp =  info.
m_int[
"comps"];
  1645       if (a_comps.
end() > 0 && ncomp < a_comps.
end())
  1647           MayDay::Error(
"attempt to read component interval that is not available");
  1649       if (a_comps.
size() == 0)
  1650         a_data.
define(a_layout, ncomp, ghost);
  1652         a_data.
define(a_layout, a_comps.
size(), ghost);
  1669   ch_offset_t offset[1];
  1683   for (
unsigned int i=0; i<types.
size(); ++i)
  1685       sprintf(dataname, 
"%s:datatype=%i",a_name.c_str(), i);
  1687       dataset[i]        = H5Dopen(a_handle.
groupID(), dataname);
  1689       dataset[i]        = H5Dopen2(a_handle.
groupID(), dataname, H5P_DEFAULT);
  1695       dataspace[i]      = H5Dget_space(dataset[i]);
  1696       if (dataspace[i] < 0)
  1702   hid_t offsetspace, offsetData;
  1703   hsize_t flatdims[1];
  1704   for (
unsigned int i=0; i<types.
size(); ++i)
  1706       flatdims[0] =  offsets[i].
size();
  1707       sprintf(dataname, 
"%s:offsets=%i",a_name.c_str(), i);
  1708       offsetspace =  H5Screate_simple(1, flatdims, NULL);
  1711       offsetData  =   H5Dopen(a_handle.
groupID(), dataname);
  1713       offsetData  =   H5Dopen2(a_handle.
groupID(), dataname,H5P_DEFAULT);
  1716       hid_t memdataspace = H5Screate_simple(1, flatdims, NULL);
  1718       err = H5Dread(offsetData, H5T_NATIVE_LLONG, memdataspace, offsetspace,
  1719                     H5P_DEFAULT, &(offsets[i][0]));
  1721       H5Sclose(memdataspace);
  1722       H5Sclose(offsetspace);
  1723       H5Dclose(offsetData);
  1727   std::string group = a_handle.
getGroup();
  1730       std::string message = 
"error opening "+a_handle.
getGroup()+
"/"+a_name ;
  1737   int ncomps = info.
m_int[
"comps"];
  1741       outputGhost = info.
m_intvect[
"outputGhost"];
  1751     if (a_comps.
size() != 0)
  1757       a_data.
define(a_layout, ncomps);
  1768   for (
unsigned int i=0; i<types.
size(); ++i)
  1770       type_size[i] = H5Tget_size(types[i]);
  1776   for ( ; it.ok(); ++it)
  1779       T& data = a_data[it()];
  1783       for (
unsigned int i=0; i<types.
size(); ++i)
  1786           offset[0] = offsets[i][index];
  1787           count[0] = offsets[i][index+1] - offset[0];
  1790             size_t size = count[0] * type_size[i];
  1791             while (size > buffers[i].size())
  1793                 buffers[i].
resize(2*buffers[i].size());
  1796             err =  H5Sselect_hyperslab(dataspace[i], H5S_SELECT_SET,
  1800             hid_t memdataspace = H5Screate_simple(1, count, NULL);
  1802             err = H5Dread(dataset[i], types[i], memdataspace, dataspace[i],
  1803                           H5P_DEFAULT, &(buffers[i][0]));
  1805             H5Sclose(memdataspace);
  1813       box.
grow(outputGhost);
  1814       read(data, buffers,  box, comps);
  1832   for (
unsigned int i=0; i<types.
size(); ++i)
  1835       H5Sclose(dataspace[i]);
  1836       H5Dclose(dataset[i]);
  1848                const Box&  a_domain,
  1849                const int&  a_refRatio,
  1855   std::string currentGroup = a_handle.
getGroup();
  1856   sprintf(levelName, 
"/level_%i",a_level);
  1857   error = a_handle.
setGroup(currentGroup + levelName);
  1858   if (error != 0) 
return 1;
  1861   meta.
m_real[
"dx"] = a_dx;
  1862   meta.
m_real[
"dt"] = a_dt;
  1863   meta.
m_real[
"time"] = a_time;
  1864   meta.
m_box[
"prob_domain"] = a_domain;
  1865   meta.
m_int[
"ref_ratio"] = a_refRatio;
  1868   if (error != 0) 
return 2;
  1870   error = 
write(a_handle, a_data.boxLayout());
  1871   if (error != 0) 
return 3;
  1873   error = 
write(a_handle, a_data, 
"data", outputGhost, comps);
  1874   if (error != 0) 
return 4;
  1888                const Box&  a_domain,
  1895   std::string currentGroup = a_handle.
getGroup();
  1896   sprintf(levelName, 
"/level_%i",a_level);
  1897   error = a_handle.
setGroup(currentGroup + levelName);
  1898   if (error != 0) 
return 1;
  1902   meta.
m_real[
"dt"] = a_dt;
  1903   meta.
m_real[
"time"] = a_time;
  1904   meta.
m_box[
"prob_domain"] = a_domain;
  1905   meta.
m_intvect[
"vec_ref_ratio"] = a_refRatios;
  1908   if (error != 0) 
return 2;
  1910   error = 
write(a_handle, a_data.boxLayout());
  1911   if (error != 0) 
return 3;
  1913   error = 
write(a_handle, a_data, 
"data", outputGhost, comps);
  1914   if (error != 0) 
return 4;
  1940   std::string currentGroup = a_handle.
getGroup();
  1941   sprintf(levelName, 
"/level_%i",a_level);
  1942   error = a_handle.
setGroup(currentGroup + levelName);
  1943   if (error != 0) 
return 1;
  1947   if (error != 0) 
return 2;
  1948   a_dx       = meta.
m_real[
"dx"];
  1949   a_dt       = meta.
m_real[
"dt"];
  1950   a_time     = meta.
m_real[
"time"];
  1951   a_domain   = meta.
m_box[
"prob_domain"];
  1952   a_refRatio = meta.
m_int[
"ref_ratio"];
  1954   { 
CH_TIME(
"readLevel read boxes");
  1955   error = 
read(a_handle, boxes);
  1958   { 
CH_TIME(
"readLevel LoadBalance");
  1963   { 
CH_TIME(
"readLevel define layout");
  1964     layout.
define(boxes, procIDs, a_domain);
  1967   { 
CH_TIME(
"readLevel close layout");
  1970   if (error != 0) 
return 3;
  1972   { 
CH_TIME(
"readLevel read general");
  1973   error = 
read(a_handle, a_data, 
"data", layout, a_comps, 
true);
  1976   if (error != 0) 
return 4;
  2002   std::string currentGroup = a_handle.
getGroup();
  2003   sprintf(levelName, 
"/level_%i",a_level);
  2004   error = a_handle.
setGroup(currentGroup + levelName);
  2005   if (error != 0) 
return 1;
  2009   if (error != 0) 
return 2;
  2021   a_dt       = meta.
m_real[
"dt"];
  2022   a_time     = meta.
m_real[
"time"];
  2023   a_domain   = meta.
m_box[
"prob_domain"];
  2028       a_refRatio = meta.
m_intvect[
"vec_ref_ratio"];
  2032       int refRatioScalar = meta.
m_int[
"ref_ratio"];
  2036   error = 
read(a_handle, boxes);
  2043   if (error != 0) 
return 3;
  2045   error = 
read(a_handle, a_data, 
"data", layout, a_comps, 
true);
  2047   if (error != 0) 
return 4;
  2100                                   const int        a_numIntv,
  2101                                   const string&    a_name,
  2102                                   const int        a_policyFlags,
  2104                                   const bool       a_newForm)
  2106   m_policyFlags(a_policyFlags),
  2107   m_outputGhost(a_outputGhost),
  2108   m_newForm(a_newForm)
  2110   CH_TIME(
"WriteMultiData::constructor");
  2118   write(a_handle, a_layout);
  2134   hsize_t flatdims[1];
  2138     flatdims[0] = m_offsets[0].back();
  2147             sprintf(
m_dataname, 
"%sRegular", a_name.c_str());
  2152         sprintf(
m_dataname, 
"%s:datatype=%i", a_name.c_str(), 0);
  2156       dataspace = H5Screate_simple(1, flatdims, NULL);
  2163                              dataspace, H5P_DEFAULT,
  2164                              H5P_DEFAULT, H5P_DEFAULT);
  2168       CH_TIME(
"H5S_H5D_data_close");
  2169       H5Sclose(dataspace);
  2175     hid_t offsetspace, offsetdataset;
  2176     char offsetname[128];
  2177     flatdims[0] = m_offsets[0].size();  
  2182             strcpy(offsetname, 
"MaskOffsets");
  2186             sprintf(offsetname, 
"%sOffsets", a_name.c_str());
  2191         sprintf(offsetname, 
"%s:offsets=%i", a_name.c_str(), 0);
  2194       CH_TIME(
"H5S_H5D_offsets_create");
  2195       offsetspace = H5Screate_simple(1, flatdims, NULL);
  2197       offsetdataset = H5Dcreate2(a_handle.
groupID(), offsetname,
  2198                                  H5T_NATIVE_LLONG, offsetspace, 
  2200                                  H5P_DEFAULT,H5P_DEFAULT);
  2208         hid_t memdataspace = H5Screate_simple(1, flatdims, NULL);
  2210         err = H5Dwrite(offsetdataset, H5T_NATIVE_LLONG, memdataspace,
  2211                        offsetspace, H5P_DEFAULT, &(m_offsets[0][0]));
  2213         H5Sclose(memdataspace);
  2216       CH_TIME(
"H5S_H5D_offsets_close");
  2217       H5Sclose(offsetspace);
  2218       H5Dclose(offsetdataset);
  2233     std::string group = a_handle.
getGroup();
  2234     a_handle.
setGroup(group+
"/"+a_name+
"_attributes");
  2244     MPI_Allreduce(&myCountBoxes,
  2246                   1, MPI_LONG, MPI_MAX, Chombo_MPI::comm);
  2269   CH_TIME(
"WriteMultiData::writeData");
  2279   hsize_t fileCount[1], memCount[
SpaceDim+1];
  2280   ch_offset_t fileOffset[1], memOffset[
SpaceDim+1];  
  2285   hid_t fileDataSpace = H5Dget_space(
m_dataSet);
  2289   hid_t DXPL = H5Pcreate(H5P_DATASET_XFER);
  2293       H5Pset_dxpl_mpio(DXPL, H5FD_MPIO_COLLECTIVE);
  2303       CH_TIME(
"hyperslab_H5Dwrite");
  2311               const T& data = a_data[dit];
  2313               Box dbox = data.box();         
  2314               Box rbox = a_data.
box(dit());  
  2317               memCount[0] = a_data.
nComp();
  2324               memDataSpace = H5Screate_simple(
SpaceDim+1, memCount, NULL);
  2326               memCount[0] = a_intvMem.
size();
  2333               memOffset[0] = a_intvMem.
begin();
  2341               err = H5Sselect_hyperslab(memDataSpace, H5S_SELECT_SET,
  2342                                         memOffset, NULL, memCount, NULL);
  2345               fileOffset[0] = 
m_offsets[0][globalIdx];
  2346               fileCount[0] = 
m_offsets[0][globalIdx + 1] - fileOffset[0];
  2347               if (fileCount[0] > 0)  
  2350                   const hsize_t dpnts = rbox.
numPts();  
  2351                   fileOffset[0] += dpnts*a_intvFile.
begin();
  2352                   fileCount[0] = dpnts*a_intvFile.
size();
  2353                   CH_assert(fileOffset[0] + fileCount[0] <=
  2355                   err = H5Sselect_hyperslab(fileDataSpace, H5S_SELECT_SET,
  2356                                             fileOffset, NULL, fileCount, NULL);
  2361                   H5Sselect_none(memDataSpace);
  2362                   H5Sselect_none(fileDataSpace);
  2364               buffer = data.dataPtr();
  2369               std::memset(memCount, 0, (
SpaceDim+1)*
sizeof(hsize_t));
  2370               memDataSpace = H5Screate_simple(
SpaceDim+1, memCount, NULL);
  2371               H5Sselect_none(memDataSpace);
  2372               H5Sselect_none(fileDataSpace);
  2379           H5Sclose(memDataSpace);
  2393       CH_TIME(
"linearize_H5Dwrite");
  2399         long long bufferSize = 0;
  2404               const long long allIntvSize =
  2407               if (allIntvSize > bufferSize)
  2409                   bufferSize = allIntvSize;
  2416         linearBuffer = 
mallocMT(bufferSize);
  2417         if (linearBuffer == NULL)
  2419             pout() << 
" bufferCapacity = " << (int)bufferSize << endl;
  2431               const T& data = a_data[dit];
  2433               Box rbox = a_data.
box(dit());  
  2437                 data.linearOut(linearBuffer, rbox, a_intvMem);
  2439               const hsize_t dpnts = rbox.
numPts();  
  2441               memCount[0] = dpnts*a_intvMem.
size();
  2442               memDataSpace = H5Screate_simple(1, memCount, NULL);
  2444               fileOffset[0] = 
m_offsets[0][globalIdx];
  2445               fileCount[0] = 
m_offsets[0][globalIdx + 1] - fileOffset[0];
  2446               if (fileCount[0] > 0)  
  2449                   fileOffset[0] += dpnts*a_intvFile.
begin();
  2450                   fileCount[0] = dpnts*a_intvFile.
size();
  2451                   CH_assert(fileOffset[0] + fileCount[0] <=
  2453                   err = H5Sselect_hyperslab(fileDataSpace, H5S_SELECT_SET,
  2454                                             fileOffset, NULL, fileCount, NULL);
  2459                   H5Sselect_none(memDataSpace);
  2460                   H5Sselect_none(fileDataSpace);
  2467               memDataSpace = H5Screate_simple(
SpaceDim+1, memCount, NULL);
  2468               H5Sselect_none(memDataSpace);
  2469               H5Sselect_none(fileDataSpace);
  2473                          DXPL, linearBuffer);
  2475           H5Sclose(memDataSpace);
  2488   H5Sclose(fileDataSpace);
  2493 #include "NamespaceFooter.H"  2495 #else // CH_USE_HDF5  2498 #define HOFFSET(S,M)    (offsetof(S,M))  2500 #endif // CH_USE_HDF5 not defined std::ostream & pout()
Use this in place of std::cout for program output. 
 
A FArrayBox-like container for edge-centered fluxes. 
Definition: EdgeDataBox.H:21
 
#define CH_TIMERS(name)
Definition: CH_Timer.H:133
 
virtual void define(const BoxLayout &boxes, int comps, const DataFactory< T > &factory=DefaultDataFactory< T >())
Definition: BoxLayoutDataI.H:89
 
IntVect & min(const IntVect &p)
Definition: IntVect.H:1124
 
Interval interval() const
Definition: BoxLayoutData.H:312
 
IntVect size() const
size functions 
Definition: Box.H:1803
 
#define D_TERM6(a, b, c, d, e, f)
Definition: CHArray.H:40
 
#define freeMT(a_a)
Definition: memtrack.H:160
 
#define CH_SPACEDIM
Definition: SPACE.H:51
 
#define CH_assert(cond)
Definition: CHArray.H:37
 
mode m_mode
Definition: CH_HDF5.H:464
 
int readBoxes(HDF5Handle &a_handle, Vector< Vector< Box > > &boxes)
reads the set of Boxes out from the level_* groups of a Chombo HDF5 AMR file 
 
mode
Definition: CH_HDF5.H:316
 
void writeDataset(hid_t a_dataset, hid_t a_dataspace, const void *start, ch_offset_t off, hsize_t count)
 
A not-necessarily-disjoint collective of boxes. 
Definition: BoxLayout.H:145
 
one dimensional dynamic array 
Definition: Vector.H:53
 
const IntVect m_outputGhost
Number of ghost cells written. 
Definition: CH_HDF5.H:667
 
int readFArrayBox(HDF5Handle &a_handle, FArrayBox &a_fab, int a_level, int a_boxNumber, const Interval &a_components, const std::string &a_dataName="data")
FArrayBox-at-a-time read function. FArrayBox gets redefined in the function. Reads data field named b...
 
int size() const
Definition: Interval.H:75
 
std::string m_group
Definition: CH_HDF5.H:467
 
int begin() const
Definition: Interval.H:97
 
#define mallocMT(a_a)
Definition: memtrack.H:159
 
#define CH_START(tpointer)
Definition: CH_Timer.H:145
 
void getOffsets(Vector< Vector< long long > > &offsets, const BoxLayoutData< T > &a_data, int types, const Interval &comps, const IntVect &outputGhost)
Definition: CH_HDF5.H:972
 
void readDataset(hid_t a_dataset, hid_t a_dataspace, void *start, ch_offset_t off, hsize_t count)
 
unsigned int size() const
Returns the total number of boxes in the BoxLayout. 
 
HDF5Handle::mode openMode() const
Definition: CH_HDF5.H:449
 
const BoxLayout & boxLayout() const
Definition: LayoutData.H:107
 
DataIterator dataIterator() const
Definition: LayoutDataI.H:78
 
Box box(const DataIndex &a_index) const
Definition: LayoutDataI.H:66
 
virtual bool ok() const
return true if this iterator is still in its Layout 
Definition: LayoutIterator.H:117
 
Definition: DataIterator.H:190
 
void linearOut(void *const a_outBuf, const CH_XDIR::OffsetBuffer &a_inputT)
 
int readLevel(HDF5Handle &a_handle, const int &a_level, LevelData< T > &a_data, Real &a_dx, Real &a_dt, Real &a_time, Box &a_domain, int &a_refRatio, const Interval &a_comps=Interval(), bool setGhost=false)
Definition: CH_HDF5.H:1922
 
std::ostream & operator<<(std::ostream &os, const HDF5HeaderData &data)
 
herr_t HDF5HeaderDataattributeScan(hid_t loc_id, const char *name, const H5A_info_t *info, void *opdata)
 
int LoadBalance(Vector< Vector< int > > &a_procAssignments, Real &a_effRatio, const Vector< Vector< Box > > &a_Grids, const Vector< Vector< long > > &a_ComputeLoads, const Vector< int > &a_RefRatios, int a_nProc=numProc())
 
int writeData(const BoxLayoutData< T > &a_data, const Interval &a_intvMem, const Interval &a_intvFile)
Write an interval of LevelData to the dataset. 
Definition: CH_HDF5.H:2265
 
unsigned int numProc()
number of parallel processes 
 
int uniqueProc(const SerialTask::task &a_task)
 
An Iterator based on a BoxLayout object. 
Definition: LayoutIterator.H:35
 
void createDataset(hid_t &a_dataset, hid_t &a_dataspace, HDF5Handle &handle, const std::string &name, const T *dummy, hsize_t size)
Definition: CH_HDF5.H:739
 
hid_t m_dataSet
Dataset for level data. 
Definition: CH_HDF5.H:671
 
void dataTypes(Vector< hid_t > &a_types, const BaseFab< int > &dummy)
Definition: CH_HDF5.H:801
 
void dataSize(const BaseFab< int > &item, Vector< int > &a_sizes, const Box &box, const Interval &comps)
Definition: CH_HDF5.H:847
 
const int SpaceDim
Definition: SPACE.H:38
 
Definition: CH_HDF5.H:318
 
#define CH_TIMER(name, tpointer)
Definition: CH_Timer.H:63
 
static const RealVect Unit
Definition: RealVect.H:427
 
Definition: EBInterface.H:45
 
static hid_t realvect_id
Definition: CH_HDF5.H:454
 
void resize(unsigned int isize)
Definition: Vector.H:346
 
const std::string & getGroup() const
 
Definition: CH_HDF5.H:320
 
Interval m_allIntvFile
Interval for components in file. 
Definition: CH_HDF5.H:672
 
A FArrayBox-like container for face-centered fluxes. 
Definition: FluxBox.H:22
 
void gather(Vector< T > &a_outVec, const T &a_input, int a_dest)
Definition: SPMDI.H:197
 
void linearIn(CH_XDIR::OffsetBuffer &a_outputT, const void *const a_inBuf)
 
unsigned int index(const LayoutIndex &index) const
Definition: BoxLayout.H:723
 
IOPolicy
Definition: CH_HDF5.H:61
 
char m_dataname[128]
Name for level data dataset. 
Definition: CH_HDF5.H:670
 
Methods for writing multiple LevelData to an HDF5 file. 
Definition: CH_HDF5.H:631
 
void push_back(const T &in)
Definition: Vector.H:295
 
Vector< hid_t > m_types
Type of data written. 
Definition: CH_HDF5.H:680
 
int size() const
Definition: DataIterator.H:218
 
static bool initialized
Definition: CH_HDF5.H:471
 
#define CH_TIME(name)
Definition: CH_Timer.H:82
 
Structure for passing component ranges in code. 
Definition: Interval.H:23
 
static const IntVect Unit
Definition: IntVect.H:659
 
const char * name(const FArrayBox &a_dummySpecializationArg)
Definition: CH_HDF5.H:907
 
int linearSize(const CH_XDIR::OffsetBuffer &a_input)
 
new code 
Definition: BoxLayoutData.H:170
 
long m_maxBoxPerProc
Maximum boxes written by any proc. 
Definition: CH_HDF5.H:673
 
std::string m_filename
Definition: CH_HDF5.H:466
 
const IntVect & smallEnd() const
{ Accessors} 
Definition: Box.H:1754
 
Data on a BoxLayout. 
Definition: BoxLayoutData.H:97
 
double Real
Definition: REAL.H:33
 
Box surroundingNodes(const Box &b, int dir)
Definition: Box.H:2145
 
Definition: CH_HDF5.H:764
 
virtual void define(const DisjointBoxLayout &dp, int comps, const IntVect &ghost=IntVect::Zero, const DataFactory< T > &a_factory=DefaultDataFactory< T >())
Definition: LevelDataI.H:93
 
Vector< int > index
Definition: CH_HDF5.H:766
 
Definition: CH_HDF5.H:319
 
A BoxLayout that has a concept of disjointedness. 
Definition: DisjointBoxLayout.H:30
 
size_t size() const
Definition: Vector.H:192
 
void createData(hid_t &a_dataset, hid_t &a_dataspace, HDF5Handle &handle, const std::string &name, hid_t type, hsize_t size)
 
const IntVect & ghostVect() const
Definition: LevelData.H:186
 
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code. 
 
int write(HDF5Handle &a_handle, const BoxLayout &a_layout, const std::string &name="boxes")
writes BoxLayout to HDF5 file. 
 
const int m_policyFlags
Policies. 
Definition: CH_HDF5.H:666
 
static const IntVect Zero
Definition: IntVect.H:654
 
static hid_t box_id
Definition: CH_HDF5.H:452
 
Vector< Vector< int > > offsets
Definition: CH_HDF5.H:767
 
hssize_t ch_offset_t
Definition: CH_HDF5.H:695
 
static void Warning(const char *const a_msg=m_nullString)
Print out message to cerr and continue. 
 
A Rectangular Domain on an Integer Lattice. 
Definition: Box.H:465
 
A Real vector in SpaceDim-dimensional space. 
Definition: RealVect.H:41
 
void define(int a_firstComp, int a_lastComp)
Definition: Interval.H:52
 
struct @21 HDF5Handle
Definition: Box.H:1628
 
hid_t m_fileID
Definition: CH_HDF5.H:462
 
int nComp() const
Definition: BoxLayoutData.H:306
 
Vector< Vector< long long > > m_offsets
Definition: CH_HDF5.H:677
 
hid_t H5Type(const T *dummy)
Definition: CH_HDF5.H:724
 
#define CH_STOP(tpointer)
Definition: CH_Timer.H:150
 
Handle to a particular group in an HDF file. 
Definition: CH_HDF5.H:294
 
An integer Vector in SpaceDim-dimensional space. 
Definition: CHArray.H:42
 
Definition: FArrayBox.H:45
 
WriteMultiData(HDF5Handle &a_handle, const BoxLayout &a_layout, const int a_numIntv, const string &a_name, const int a_policyFlags=CH_HDF5::IOPolicyDefault, const IntVect &a_outputGhost=IntVect::Zero, const bool a_newForm=false)
Constructor writes boxes and allocates dataset for LevelData. 
Definition: CH_HDF5.H:2098
 
#define CH_TIMELEAF(name)
Definition: CH_Timer.H:100
 
Box & grow(int i)
grow functions 
Definition: Box.H:2247
 
int setGroup(const std::string &groupAbsPath)
 
virtual void define(const Vector< Box > &a_boxes, const Vector< int > &a_procIDs)
 
void broadcast(T &a_inAndOut, int a_src)
broadcast to every process 
Definition: SPMDI.H:207
 
int end() const
Definition: Interval.H:102
 
int writeLevel(HDF5Handle &a_handle, const int &a_level, const T &a_data, const Real &a_dx, const Real &a_dt, const Real &a_time, const Box &a_domain, const int &a_refRatio, const IntVect &outputGhost=IntVect::Zero, const Interval &comps=Interval())
user-friendly function to write out data on a AMR level 
Definition: CH_HDF5.H:1842
 
LayoutIterator layoutIterator() const
Iterator that processes through ALL the boxes in a BoxLayout. 
 
static hid_t intvect_id
Definition: CH_HDF5.H:453
 
int procID()
local process ID 
 
bool m_isOpen
Definition: CH_HDF5.H:465
 
static map< std::string, std::string > groups
Definition: CH_HDF5.H:455
 
void read(T &item, Vector< Vector< char > > &a_allocatedBuffers, const Box &box, const Interval &comps)
Definition: CH_HDF5.H:51
 
hid_t m_currentGroupID
Definition: CH_HDF5.H:463
 
const hid_t & groupID() const
 
const bool m_newForm
? 
Definition: CH_HDF5.H:668
 
#define H5T_NATIVE_REAL
Definition: REAL.H:35
 
int m_level
Definition: CH_HDF5.H:468
 
~WriteMultiData()
Destructor. 
Definition: CH_HDF5.H:646
 
A wrapper for an FArrayBox to contain NODE-centered data. 
Definition: NodeFArrayBox.H:122