aboutsummaryrefslogtreecommitdiff
path: root/CarpetDev/CarpetIOF5/src/meta_data_region.cc
diff options
context:
space:
mode:
Diffstat (limited to 'CarpetDev/CarpetIOF5/src/meta_data_region.cc')
-rw-r--r--CarpetDev/CarpetIOF5/src/meta_data_region.cc70
1 files changed, 48 insertions, 22 deletions
diff --git a/CarpetDev/CarpetIOF5/src/meta_data_region.cc b/CarpetDev/CarpetIOF5/src/meta_data_region.cc
index 505508eb9..88963ec34 100644
--- a/CarpetDev/CarpetIOF5/src/meta_data_region.cc
+++ b/CarpetDev/CarpetIOF5/src/meta_data_region.cc
@@ -3,11 +3,14 @@
#include <sstream>
#include <string>
+#include <hdf5.h>
+
#include "cctk.h"
#include "carpet.hh"
-#include "data_region.hh"
+#include "defs.hh"
+
#include "meta_data_region.hh"
#include "utils.hh"
@@ -22,17 +25,14 @@ namespace CarpetIOF5 {
meta_data_region_t::
- meta_data_region_t (tensor_component_t & tensor_component,
+ meta_data_region_t (physical_quantity_t & physical_quantity,
bbox<int, dim> const & region)
- : m_tensor_component (tensor_component),
- m_region (region)
+ : m_physical_quantity (physical_quantity),
+ m_region (region),
+ m_name (string ("region-") + F5::name_from_ibbox (region))
{
assert (not region.empty());
- string const namestr = data_region_t::name_from_region (region);
- char const * const name = namestr.c_str();
- assert (name != 0);
-
assert (invariant());
}
@@ -45,11 +45,11 @@ namespace CarpetIOF5 {
- tensor_component_t & meta_data_region_t::
- get_tensor_component ()
+ physical_quantity_t & meta_data_region_t::
+ get_physical_quantity ()
const
{
- return m_tensor_component;
+ return m_physical_quantity;
}
@@ -58,22 +58,48 @@ namespace CarpetIOF5 {
write (int const proc)
const
{
+ DECLARE_CCTK_PARAMETERS;
+
string filename;
string objectname;
- get_tensor_component().get_link_destination (filename, objectname);
+ get_physical_quantity().get_link_destination (proc, filename, objectname);
- string const name = data_region_t::name_from_region (m_region);
+ hid_t const hdf5_physical_quantity
+ = m_physical_quantity.get_hdf5_physical_quantity();
- hid_t const hdf5_tensor_component
- = m_tensor_component.get_hdf5_tensor_component();
+ bool link_exists;
+ H5E_BEGIN_TRY {
+ H5L_info_t linkbuf;
+ herr_t const herr
+ = H5Lget_info (hdf5_physical_quantity, m_name.c_str(),
+ & linkbuf, H5P_DEFAULT);
+ link_exists = herr == 0;
+ } H5E_END_TRY;
+ if (veryverbose)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "Link \"%s\" %s",
+ m_name.c_str(),
+ link_exists ? "exists" : "does not exist");
+ }
- herr_t const herr
- = H5Lcreate_external (filename.c_str(),
- objectname.c_str(),
- hdf5_tensor_component,
- name.c_str(),
- H5P_DEFAULT, H5P_DEFAULT);
- assert (not herr);
+ if (not link_exists)
+ {
+ if (veryverbose)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "H5Lcreate_external "
+ "(filename=\"%s\", objectname=\"%s\", linkname=\"%s\")",
+ filename.c_str(),
+ objectname.c_str(),
+ m_name.c_str());
+ }
+ check (not H5Lcreate_external (filename.c_str(),
+ objectname.c_str(),
+ hdf5_physical_quantity,
+ m_name.c_str(),
+ H5P_DEFAULT, H5P_DEFAULT));
+ }
}