diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DumpUtils.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/DumpUtils.c b/src/DumpUtils.c index 8274388..0cdc89f 100644 --- a/src/DumpUtils.c +++ b/src/DumpUtils.c @@ -270,26 +270,34 @@ void IOHDF5Util_DumpCommonAttributes (cGH *GH, WRITE_ATTRIBUTE ("time", &GH->cctk_time, dataset, myGH->scalar_dataspace, 0, IOHDF5_REAL); - /* attributes describing the underlying grid */ + /* attributes describing the underlying grid + These are only stored for CCTK_GF variables if they are associated + with coordinates. */ + /* FIXME: This is hardcoded for cartesian coordinate systems. + A better solution would be to be able to query the coordinate + system which is associated with the variable. */ vdim = CCTK_GroupDimFromVarI (vindex); - attr_real = (CCTK_REAL *) malloc (2 * vdim * sizeof (CCTK_REAL)); - /* FIXME: this hardcodes it for cartesian coordinate systems */ sprintf (coord_system_name, "cart%dd", vdim); - for (dim = 0; dim < vdim; dim++) + if (CCTK_GroupTypeFromVarI (vindex) == CCTK_GF && + CCTK_CoordSystemHandle (coord_system_name) >= 0) { - CCTK_CoordRange (GH, &attr_real[dim], &attr_real[dim + vdim], dim + 1, - NULL, coord_system_name); - } + attr_real = (CCTK_REAL *) malloc (2 * vdim * sizeof (CCTK_REAL)); + for (dim = 0; dim < vdim; dim++) + { + CCTK_CoordRange (GH, &attr_real[dim], &attr_real[dim + vdim], dim + 1, + NULL, coord_system_name); + } - WRITE_ATTRIBUTE ("origin", attr_real, dataset, - myGH->array_dataspace, vdim, IOHDF5_REAL); - WRITE_ATTRIBUTE ("min_ext", attr_real, dataset, - myGH->array_dataspace, vdim, IOHDF5_REAL); - WRITE_ATTRIBUTE ("max_ext", attr_real + vdim, dataset, - myGH->array_dataspace, vdim, IOHDF5_REAL); - WRITE_ATTRIBUTE ("delta", GH->cctk_delta_space, dataset, - myGH->array_dataspace, vdim, IOHDF5_REAL); - free (attr_real); + WRITE_ATTRIBUTE ("origin", attr_real, dataset, + myGH->array_dataspace, vdim, IOHDF5_REAL); + WRITE_ATTRIBUTE ("min_ext", attr_real, dataset, + myGH->array_dataspace, vdim, IOHDF5_REAL); + WRITE_ATTRIBUTE ("max_ext", attr_real + vdim, dataset, + myGH->array_dataspace, vdim, IOHDF5_REAL); + WRITE_ATTRIBUTE ("delta", GH->cctk_delta_space, dataset, + myGH->array_dataspace, vdim, IOHDF5_REAL); + free (attr_real); + } #if 0 /* attributes describing the hyperslab */ |