aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.c')
-rw-r--r--src/Utils.c99
1 files changed, 89 insertions, 10 deletions
diff --git a/src/Utils.c b/src/Utils.c
index 7006acb..e5fd1b0 100644
--- a/src/Utils.c
+++ b/src/Utils.c
@@ -79,7 +79,6 @@ int IOUtil_1DLines (cGH *GH,
CCTK_REAL *const origin_phys[],
int *slice_center[])
{
- DECLARE_CCTK_PARAMETERS
int dim, dir;
char system_name[20];
CCTK_REAL *lower_range, *upper_range;
@@ -121,21 +120,27 @@ int IOUtil_1DLines (cGH *GH,
{
if (dim == dir)
{
+ /* line always starts at the first point */
slice_center[dir][dim] = 0;
}
else if (origin_index && origin_index[dir][dim] >= 0)
{
+/* FIXME: check upper index bounds also ?? */
slice_center[dir][dim] = origin_index[dir][dim];
}
else if (lower_range[dim] > origin_phys[dir][dim] ||
upper_range[dim] < origin_phys[dir][dim])
{
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOUtil_1DLines: Coordinate in %c-direction (%f, %f) "
- "doesn't contain %f",
- 'x' + dim, (double) lower_range[dim],
- (double) upper_range[dim], (double) origin_phys[dir][dim]);
- slice_center[dir][dim] = 0;
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOUtil_1DLines: %c-coordinate for slice center of 1D "
+ "lines in %c-direction (%f) is out of grid coordinates "
+ "range (%f, %f)",
+ 'x' + dim, 'x' + dir, (double) origin_phys[dir][dim],
+ (double) lower_range[dim], (double) upper_range[dim]);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOUtil_1DLines: no 1D %c-line output will be written with "
+ "this slice center default", 'x' + dir);
+ slice_center[dir][dim] = -1;
}
else
{
@@ -145,8 +150,8 @@ int IOUtil_1DLines (cGH *GH,
GH->cctk_delta_space[dim] - 1e-6);
#ifdef DEBUG_IOUTIL
- printf("spxyz for %d-coord of lines in %d-direction is %d\n",
- dim,dir,slice_center[dir][dim]);
+ printf("spxyz for %c-coord of lines in %c-direction is %d\n",
+ 'x' + dim,'x' + dir, slice_center[dir][dim]);
#endif
}
}
@@ -208,7 +213,6 @@ int IOUtil_2DPlanes (cGH *GH,
const CCTK_REAL origin_phys[],
int slice_center[])
{
- DECLARE_CCTK_PARAMETERS
int dir;
char system_name[20];
CCTK_REAL *lower_range, *upper_range;
@@ -371,3 +375,78 @@ void IOUtil_PrintTimings (const char *description,
"No timing output available.");
}
}
+
+
+ /*@@
+ @routine IOUtil_CreateDirectory
+ @date Fri 10 Aug 2001
+ @author Thomas Radke
+ @desc
+ Creates an output directory path and makes sure it is visible
+ on all I/O processors.
+ It is assumed that processor 0 is always an I/O processor.
+ If there are other I/O processors, they will also try and
+ create the directory themselfs. This guarantees the directory
+ be created on all nodes in case the I/O processors don't share
+ a common filesystem.
+ @enddesc
+ @calls CCTK_MyProc
+ CCTK_CreateDirectory
+ CCTK_Barrier
+
+ @var GH
+ @vdesc pointer to the GH extensions
+ @vtype cGH *
+ @vio in
+ @endvar
+ @var dirname
+ @vdesc the directory to create
+ @vtype const char *
+ @vio in
+ @endvar
+ @var multiple_io_procs
+ @vdesc flag indicating that there will be I/O from multiple I/O procs
+ @vtype int
+ @vio in
+ @endvar
+ @var ioproc
+ @vdesc I/O processor associated with this processor
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 for non-I/O processors, or
+ return code of @seeroutine CCTK_CreateDirectory
+ @endreturndesc
+@@*/
+int IOUtil_CreateDirectory (cGH *GH, const char *dirname,
+ int multiple_io_procs, int ioproc)
+{
+ int myproc, retval;
+
+
+ /* default return value for non-I/O processors */
+ retval = 0;
+
+ /* first, processor 0 creates the directory */
+ myproc = CCTK_MyProc (GH);
+ if (myproc == 0)
+ {
+ retval = CCTK_CreateDirectory (0755, dirname);
+ }
+
+ if (multiple_io_procs)
+ {
+ /* now the other I/O processors create the directory
+ after syncing with processor 0 */
+ CCTK_Barrier (GH);
+ if (myproc == ioproc || ioproc != 0)
+ {
+ retval = CCTK_CreateDirectory (0755, dirname);
+ }
+ }
+
+ return (retval);
+}