aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2000-09-21 13:08:34 +0000
committertradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2000-09-21 13:08:34 +0000
commit5f59dd01551309291af4bd1c00addb8be429bcf4 (patch)
treead4545d2c347c8da78a976eac692ebfa92fabe9b
parentab04f9bd459e858d31f59f0517f37281fffd931a (diff)
Moved IOUtil_PrintTimings() from GHExtensions.c to here.
Untabified source. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@95 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a
-rw-r--r--src/Utils.c229
1 files changed, 157 insertions, 72 deletions
diff --git a/src/Utils.c b/src/Utils.c
index 12d0af8..338bed9 100644
--- a/src/Utils.c
+++ b/src/Utils.c
@@ -7,21 +7,14 @@
@enddesc
@history
@endhistory
- @version $Header$
@@*/
-/*#define DEBUG_IOUTIL*/
+/*#define DEBUG_IOUTIL 1*/
#include "cctk.h"
#include "cctk_Parameters.h"
+#include "ioutil_Utils.h"
-static char *rcsid = "$Header$";
-
-CCTK_FILEVERSION(CactusBase_IOUtils_Utils_c)
-
-/********************************************************************
- ********************* External Routines **********************
- ********************************************************************/
/*@@
@routine IOUtil_1DLines
@@ -43,13 +36,12 @@ CCTK_FILEVERSION(CactusBase_IOUtils_Utils_c)
@@*/
int IOUtil_1DLines (cGH *GH,
- int dimension,
- int **index,
- CCTK_REAL **coord,
- int **spxyz)
+ int dimension,
+ int **index,
+ CCTK_REAL **coord,
+ int **spxyz)
{
DECLARE_CCTK_PARAMETERS
-
int ierr=0;
int dim, dir;
CCTK_REAL lower,upper;
@@ -57,6 +49,7 @@ int IOUtil_1DLines (cGH *GH,
CCTK_REAL lowercoords[3]={0,0,0};
CCTK_REAL uppercoords[3]={0,0,0};
+
/* Get the appropriate coordinate system */
switch (dimension)
{
@@ -65,8 +58,8 @@ int IOUtil_1DLines (cGH *GH,
ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
if (ierr>-1)
{
- lowercoords[0] = lower;
- uppercoords[0] = upper;
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
}
break;
case 2:
@@ -74,14 +67,14 @@ int IOUtil_1DLines (cGH *GH,
ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
if (ierr>-1)
{
- lowercoords[0] = lower;
- uppercoords[0] = upper;
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
}
ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
if (ierr>-1)
{
- lowercoords[1] = lower;
- uppercoords[1] = upper;
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
}
break;
case 3:
@@ -89,25 +82,25 @@ int IOUtil_1DLines (cGH *GH,
ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
if (ierr>-1)
{
- lowercoords[0] = lower;
- uppercoords[0] = upper;
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
}
ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
if (ierr>-1)
{
- lowercoords[1] = lower;
- uppercoords[1] = upper;
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
}
ierr = CCTK_CoordRange(GH, &lower, &upper, 3, NULL, name);
if (ierr>-1)
{
- lowercoords[2] = lower;
- uppercoords[2] = upper;
+ lowercoords[2] = lower;
+ uppercoords[2] = upper;
}
break;
default:
CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII",
- "IOUtil_1DLines: Support only for dim<=3");
+ "IOUtil_1DLines: Support only for dim<=3");
ierr = -1;
break;
}
@@ -118,37 +111,37 @@ int IOUtil_1DLines (cGH *GH,
{
if (dim == dir)
{
- spxyz[dir][dim] = 0;
+ spxyz[dir][dim] = 0;
}
else if (index && index[dir][dim]>-1)
{
- spxyz[dir][dim] = index[dir][dim];
+ spxyz[dir][dim] = index[dir][dim];
}
else if (ierr < 0)
{
- CCTK_VWarn(4, __LINE__,__FILE__,"IOASCII",
- "IOUtil_1DLines: Cartesian coordinate system %s not found",
- name);
- spxyz[dir][dim] = 0;
+ CCTK_VWarn(4, __LINE__,__FILE__,"IOASCII",
+ "IOUtil_1DLines: Cartesian coordinate system %s not found",
+ name);
+ spxyz[dir][dim] = 0;
}
else if (lowercoords[dim]>coord[dir][dim] ||
- uppercoords[dim]<coord[dir][dim])
+ uppercoords[dim]<coord[dir][dim])
{
- CCTK_VWarn(2,__LINE__,__FILE__,"IOUtil",
- "IOUtil_1DLines: Coordinate in direction %d (%f,%f)"
- " doesn't contain %f",
- dim,lowercoords[dim],uppercoords[dim],coord[dir][dim]);
- spxyz[dir][dim] = 0;
+ CCTK_VWarn(2,__LINE__,__FILE__,"IOUtil",
+ "IOUtil_1DLines: Coordinate in direction %d (%f,%f)"
+ " doesn't contain %f",
+ dim,lowercoords[dim],uppercoords[dim],coord[dir][dim]);
+ spxyz[dir][dim] = 0;
}
else
{
- /* Find index for first point above the chosen coordinate */
- spxyz[dir][dim] = 0.5-(lowercoords[dim]-coord[dir][dim])/
- (GH->cctk_delta_space[dim]);
-
+ /* Find index for first point above the chosen coordinate */
+ spxyz[dir][dim] = 0.5-(lowercoords[dim]-coord[dir][dim])/
+ (GH->cctk_delta_space[dim]);
+
#ifdef DEBUG_IOUTIL
- printf("spxyz for %d-coord of lines in %d-direction is %d\n",
- dim,dir,spxyz[dir][dim]);
+ printf("spxyz for %d-coord of lines in %d-direction is %d\n",
+ dim,dir,spxyz[dir][dim]);
#endif
}
}
@@ -160,13 +153,12 @@ int IOUtil_1DLines (cGH *GH,
int IOUtil_2DPlanes (cGH *GH,
- int dimension,
- int *index,
- CCTK_REAL *coord,
- int *sp2xyz)
+ int dimension,
+ int *index,
+ CCTK_REAL *coord,
+ int *sp2xyz)
{
DECLARE_CCTK_PARAMETERS
-
int ierr=0;
int dir;
CCTK_REAL lower,upper;
@@ -174,6 +166,7 @@ int IOUtil_2DPlanes (cGH *GH,
CCTK_REAL lowercoords[3]={0,0,0};
CCTK_REAL uppercoords[3]={0,0,0};
+
/* Get the appropriate coordinate system */
/* Get the appropriate coordinate system */
switch (dimension)
@@ -183,8 +176,8 @@ int IOUtil_2DPlanes (cGH *GH,
ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
if (ierr>-1)
{
- lowercoords[0] = lower;
- uppercoords[0] = upper;
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
}
break;
case 2:
@@ -192,14 +185,14 @@ int IOUtil_2DPlanes (cGH *GH,
ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
if (ierr>-1)
{
- lowercoords[0] = lower;
- uppercoords[0] = upper;
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
}
ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
if (ierr>-1)
{
- lowercoords[1] = lower;
- uppercoords[1] = upper;
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
}
break;
case 3:
@@ -207,25 +200,25 @@ int IOUtil_2DPlanes (cGH *GH,
ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
if (ierr>-1)
{
- lowercoords[0] = lower;
- uppercoords[0] = upper;
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
}
ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
if (ierr>-1)
{
- lowercoords[1] = lower;
- uppercoords[1] = upper;
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
}
ierr = CCTK_CoordRange(GH, &lower, &upper, 3, NULL, name);
if (ierr>-1)
{
- lowercoords[2] = lower;
- uppercoords[2] = upper;
+ lowercoords[2] = lower;
+ uppercoords[2] = upper;
}
break;
default:
CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII",
- "IOUtil_2DPlanes: Support only for dim<=3");
+ "IOUtil_2DPlanes: Support only for dim<=3");
ierr = -1;
break;
}
@@ -240,29 +233,29 @@ int IOUtil_2DPlanes (cGH *GH,
else if (ierr < 0)
{
CCTK_VWarn(4, __LINE__,__FILE__,"IOUtil",
- "IOUtil_2DPlanes: Cartesian coordinate system %s not found",
- name);
+ "IOUtil_2DPlanes: Cartesian coordinate system %s not found",
+ name);
sp2xyz[dir] = 0;
}
else if (lowercoords[dir]>coord[dir] ||
- uppercoords[dir]<coord[dir])
+ uppercoords[dir]<coord[dir])
{
CCTK_VWarn(2,__LINE__,__FILE__,"IOUtil",
- "IOUtil_2DPlanes: Coordinate in direction %d (%lf,%lf)"
- " doesn't contain %f",
- dir,lowercoords[dir],uppercoords[dir],coord[dir]);
+ "IOUtil_2DPlanes: Coordinate in direction %d (%lf,%lf)"
+ " doesn't contain %f",
+ dir,lowercoords[dir],uppercoords[dir],coord[dir]);
sp2xyz[dir] = 0;
}
else
{
/* Find index for first point above the chosen coordinate */
sp2xyz[dir] = 0.5-(lowercoords[dir]-coord[dir])/
- (GH->cctk_delta_space[dir]);
+ (GH->cctk_delta_space[dir]);
#ifdef DEBUG_IOUTIL
printf("sp2xyz for planes perpendicular to"
- " %d-direction is %d\n",
- dir,sp2xyz[dir]);
+ " %d-direction is %d\n",
+ dir,sp2xyz[dir]);
#endif
}
}
@@ -270,3 +263,95 @@ int IOUtil_2DPlanes (cGH *GH,
return 0;
}
+
+
+ /*@@
+ @routine IOUtil_PrintTimings
+ @date Wed Jun 28 2000
+ @author Thomas Radke
+ @desc
+ Gets the timing information for the given timers and prints it
+ as INFO messages to screen.
+ @enddesc
+ @history
+ @endhistory
+ @var description
+ @vdesc description of the timers
+ @vtype const char *
+ @vio in
+ @endvar
+ @var ntimers
+ @vdesc number of timers passed in
+ @vtype int
+ @vio in
+ @endvar
+ @var timers
+ @vdesc array of timers
+ @vtype int [ntimers]
+ @vio in
+ @endvar
+ @var timer_descriptions
+ @vdesc array of timer descriptions
+ @vtype const char * [ntimers]
+ @vio in
+ @endvar
+@@*/
+
+void IOUtil_PrintTimings (const char *description,
+ int ntimers,
+ int timers[/* ntimers */],
+ const char *timer_descriptions[/* ntimers */])
+{
+ int i, j;
+ cTimerData *info;
+
+
+ info = CCTK_TimerCreateData ();
+ if (info)
+ {
+ CCTK_INFO (description);
+
+ for (i = 0; i < info->n_vals; i++)
+ {
+ for (j = 0; j < ntimers; j++)
+ {
+ CCTK_TimerI (timers[j], info);
+ if (j == 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, " %s:", info->vals[i].heading);
+ }
+ switch (info->vals[i].type)
+ {
+ case val_int:
+ CCTK_VInfo (CCTK_THORNSTRING, " %s %5d %s",
+ timer_descriptions [j],
+ info->vals[i].val.i, info->vals[i].units);
+ break;
+
+ case val_long:
+ CCTK_VInfo (CCTK_THORNSTRING, " %s %5d %s",
+ timer_descriptions [j],
+ (int) info->vals[i].val.l, info->vals[i].units);
+ break;
+
+ case val_double:
+ CCTK_VInfo (CCTK_THORNSTRING, " %s %5.1f %s",
+ timer_descriptions [j],
+ info->vals[i].val.d, info->vals[i].units);
+ break;
+
+ default:
+ CCTK_WARN(1, "Unknown data type for timer info");
+ break;
+ }
+ }
+ }
+ CCTK_INFO ("-----------------------------------------\n");
+ CCTK_TimerDestroyData (info);
+ }
+ else
+ {
+ CCTK_WARN (1, "Couldn't create timer info structure ! "
+ "No timing output available.");
+ }
+}