aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOHDF5/src/Output.cc
diff options
context:
space:
mode:
authorThomas Radke <tradke@aei.mpg.de>2005-06-28 11:32:00 +0000
committerThomas Radke <tradke@aei.mpg.de>2005-06-28 11:32:00 +0000
commita882373dce0c5cb8396675dcd07767b4eeb2f5d8 (patch)
tree1e66d7ab69622b880e992c5434ddee22097dd757 /Carpet/CarpetIOHDF5/src/Output.cc
parentd2552f96b45a95001e024a05923373344e851f1a (diff)
CarpetIOHDF5: add "cctk_bbox" and "cctk_nghostzones" attributes to each dataset
darcs-hash:20050628113206-776a0-3ed3eae73dcc785de93273c16df556c3c6531de3.gz
Diffstat (limited to 'Carpet/CarpetIOHDF5/src/Output.cc')
-rw-r--r--Carpet/CarpetIOHDF5/src/Output.cc43
1 files changed, 28 insertions, 15 deletions
diff --git a/Carpet/CarpetIOHDF5/src/Output.cc b/Carpet/CarpetIOHDF5/src/Output.cc
index 5851a74cc..a42c9a727 100644
--- a/Carpet/CarpetIOHDF5/src/Output.cc
+++ b/Carpet/CarpetIOHDF5/src/Output.cc
@@ -535,9 +535,6 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
const ioRequest* request,
const ibbox& bbox, hid_t dataset)
{
- DECLARE_CCTK_ARGUMENTS;
-
-
// Legacy arguments
hid_t attr, dataspace, datatype;
HDF5_ERROR (dataspace = H5Screate (H5S_SCALAR));
@@ -553,7 +550,7 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
HDF5_ERROR (attr = H5Acreate (dataset, "timestep", H5T_NATIVE_INT,
dataspace, H5P_DEFAULT));
- HDF5_ERROR (H5Awrite (attr, H5T_NATIVE_INT, &cctk_iteration));
+ HDF5_ERROR (H5Awrite (attr, H5T_NATIVE_INT, &cctkGH->cctk_iteration));
HDF5_ERROR (H5Aclose (attr));
HDF5_ERROR (attr = H5Acreate (dataset, "group_timelevel", H5T_NATIVE_INT,
@@ -563,7 +560,7 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
HDF5_ERROR (attr = H5Acreate (dataset, "time", HDF5_REAL,
dataspace, H5P_DEFAULT));
- HDF5_ERROR (H5Awrite (attr, HDF5_REAL, &cctk_time));
+ HDF5_ERROR (H5Awrite (attr, HDF5_REAL, &cctkGH->cctk_time));
HDF5_ERROR (H5Aclose (attr));
HDF5_ERROR (datatype = H5Tcopy (H5T_C_S1));
@@ -572,13 +569,30 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
dataspace, H5P_DEFAULT));
HDF5_ERROR (H5Awrite (attr, datatype, fullname));
HDF5_ERROR (H5Aclose (attr));
+ HDF5_ERROR (H5Sclose (dataspace));
-#if 0
- // FIXME TR: output bbox and nghostzones again for chunked output
- // Cactus arguments
- WriteAttribute (dataset, "cctk_bbox", cctk_bbox, 2*vdim);
- WriteAttribute (dataset, "cctk_nghostzones", cctk_nghostzones, vdim);
-#endif
+ // store cctk_bbox and cctk_nghostzones (for grid arrays only)
+ if (CCTK_GroupTypeFromVarI (request->vindex) != CCTK_SCALAR) {
+ vector<int> cctk_bbox(2*vdim);
+ hsize_t size = cctk_bbox.size();
+ HDF5_ERROR (dataspace = H5Screate_simple (1, &size, NULL));
+ CCTK_GroupbboxVI (cctkGH, size, &cctk_bbox[0], request->vindex);
+ HDF5_ERROR (attr = H5Acreate (dataset, "cctk_bbox", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT));
+ HDF5_ERROR (H5Awrite (attr, H5T_NATIVE_INT, &cctk_bbox[0]));
+ HDF5_ERROR (H5Aclose (attr));
+ HDF5_ERROR (H5Sclose (dataspace));
+
+ ivect cctk_nghostzones;
+ size = vdim;
+ HDF5_ERROR (dataspace = H5Screate_simple (1, &size, NULL));
+ CCTK_GroupnghostzonesVI (cctkGH, size, &cctk_nghostzones[0],
+ request->vindex);
+ HDF5_ERROR (attr = H5Acreate (dataset, "cctk_nghostzones", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT));
+ HDF5_ERROR (H5Awrite (attr, H5T_NATIVE_INT, &cctk_nghostzones[0]));
+ HDF5_ERROR (H5Aclose (attr));
+ }
// write bbox attributes if we have coordinate system info
CCTK_REAL origin[dim], delta[dim];
@@ -586,7 +600,6 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
int coord_system_handle = Coord_GroupSystem (cctkGH, groupname);
free (groupname);
- HDF5_ERROR (H5Sclose (dataspace));
hsize_t size = vdim;
HDF5_ERROR (dataspace = H5Screate_simple (1, &size, NULL));
@@ -602,8 +615,8 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
for (int d = 0; d < vdim; d++) {
Util_TableGetReal (coord_handles[d], &origin[d], "COMPMIN");
Util_TableGetReal (coord_handles[d], &delta[d], "DELTA");
- delta[d] /= cctk_levfac[d];
- origin[d] += delta[d] * (cctk_levoff[d] / cctk_levoffdenom[d] + pos[d]);
+ delta[d] /= cctkGH->cctk_levfac[d];
+ origin[d] += delta[d] * (cctkGH->cctk_levoff[d] / cctkGH->cctk_levoffdenom[d] + pos[d]);
}
HDF5_ERROR (attr = H5Acreate (dataset, "origin", HDF5_REAL,
@@ -616,7 +629,7 @@ static void AddAttributes (const cGH *const cctkGH, const char *fullname,
HDF5_ERROR (H5Aclose (attr));
}
- vect<int, dim> iorigin = bbox.lower() / bbox.stride();
+ ivect iorigin = bbox.lower() / bbox.stride();
HDF5_ERROR (attr = H5Acreate (dataset, "iorigin", H5T_NATIVE_INT,
dataspace, H5P_DEFAULT));
HDF5_ERROR (H5Awrite (attr, H5T_NATIVE_INT, &iorigin[0]));