diff options
Diffstat (limited to 'src/Utils.c')
-rw-r--r-- | src/Utils.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/src/Utils.c b/src/Utils.c index e27594e..e9f11f9 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -70,7 +70,8 @@ CCTK_FILEVERSION(CactusBase_IOUtil_Utils_c) @returntype int @returndesc - 0 for success + 0 for success + -1 no coordinate system of given dimensions found @endreturndesc @@*/ int IOUtil_1DLines (const cGH *GH, @@ -80,7 +81,7 @@ int IOUtil_1DLines (const cGH *GH, int *const *slice_center) { int dim, dir; - char system_name[20]; + char coord_system_name[20]; CCTK_REAL *lower_range, *upper_range; @@ -89,27 +90,37 @@ int IOUtil_1DLines (const cGH *GH, upper_range = lower_range + num_dims; /* get the appropriate coordinate system name */ - sprintf (system_name, "cart%dd", num_dims); - if (CCTK_CoordSystemHandle (system_name) >= 0) + sprintf (coord_system_name, "cart%dd", num_dims); + if (CCTK_CoordSystemHandle (coord_system_name) >= 0) { /* get the ranges in every direction */ for (dir = 0; dir < num_dims; dir++) { if (CCTK_CoordRange (GH, &lower_range[dir], &upper_range[dir], - dir + 1, NULL, system_name) < 0) + dir + 1, NULL, coord_system_name) < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "IOUtil_1DLines: Could not get ranges for %c-direction " "of coordinate system '%s'", - 'x' + dir, system_name); + 'x' + dir, coord_system_name); } } } else { CCTK_VWarn (4, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOUtil_1DLines: Cartesian coordinate system '%s' not found", - system_name); + "IOUtil_1DLines: Cartesian coordinate system '%s' not found" + " - no slice center set up for output of 1D lines from %dD " + "variables", coord_system_name, num_dims); + for (dir = 0; dir < num_dims; dir++) + { + for (dim = 0; dim < num_dims; dim++) + { + slice_center[dir][dim] = -1; + } + } + + return (-1); } /* now set the slice center for each line @@ -216,18 +227,19 @@ int IOUtil_2DPlanes (const cGH *GH, int *slice_center) { int dir; - char system_name[20]; + char coord_system_name[20]; CCTK_REAL *lower_range, *upper_range; /* get the appropriate coordinate system name */ - sprintf (system_name, "cart%dd", num_dims); + sprintf (coord_system_name, "cart%dd", num_dims); - if (CCTK_CoordSystemHandle (system_name) < 0) + if (CCTK_CoordSystemHandle (coord_system_name) < 0) { CCTK_VWarn (4, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOUtil_2DPlanes: Cartesian coordinate system '%s' not found", - system_name); + "IOUtil_2DPlanes: Cartesian coordinate system '%s' not found" + " - no slice center set up for output of 2D planes from %dD " + "variables", coord_system_name, num_dims); return (-1); } @@ -239,12 +251,12 @@ int IOUtil_2DPlanes (const cGH *GH, for (dir = 0; dir < num_dims; dir++) { if (CCTK_CoordRange (GH, &lower_range[dir], &upper_range[dir], - dir + 1, NULL, system_name) < 0) + dir + 1, NULL, coord_system_name) < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "IOUtil_2DPlanes: Could not get ranges for %c-direction " "of coordinate system '%s'", - 'x' + dir, system_name); + 'x' + dir, coord_system_name); } } @@ -259,11 +271,15 @@ int IOUtil_2DPlanes (const cGH *GH, else if (lower_range[dir] > origin_phys[dir] || upper_range[dir] < origin_phys[dir]) { - CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOUtil_2DPlanes: Coordinate in %c-direction (%f, %f) " - "doesn't contain %f", - 'x' + dir, (double) lower_range[dir], - (double) upper_range[dir], (double) origin_phys[dir]); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOUtil_2DPlanes: %c-coordinate for slice center of 2D " + "planes (%f) is out of grid coordinates range (%f, %f)", + 'x' + dir, (double) origin_phys[dir], + (double) lower_range[dir], (double) upper_range[dir]); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOUtil_2DPlanes: no 2D planes in %c-direction will be " + "written for %dD variables with this slice center default", + 'x' + dir, num_dims); slice_center[dir] = 0; } else |