aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorravi9 <ravi9@7daa882c-dc44-4453-834e-278d26b18e6a>2004-06-10 15:08:39 +0000
committerravi9 <ravi9@7daa882c-dc44-4453-834e-278d26b18e6a>2004-06-10 15:08:39 +0000
commit75e87ee255659cd3a4cf41f7f06b69d5d627bc69 (patch)
treec98a5b407c355a5c7b3c75c4fb2f31dc64b6711e
parent79c786d55900dec0bc910bbb27d99a2ddcfca0bb (diff)
This commit was generated by cvs2svn to compensate for changes in r4, which
included commits to RCS files with non-trunk default branches. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalReduce/trunk@5 7daa882c-dc44-4453-834e-278d26b18e6a
-rw-r--r--README9
-rw-r--r--doc/documentation.tex144
-rw-r--r--interface.ccl5
-rw-r--r--param.ccl2
-rw-r--r--schedule.ccl7
-rw-r--r--src/Reduction.c328
-rw-r--r--src/ReductionAvg.c256
-rw-r--r--src/Startup.c29
-rw-r--r--src/make.code.defn8
9 files changed, 787 insertions, 1 deletions
diff --git a/README b/README
index 219b93d..70df10f 100644
--- a/README
+++ b/README
@@ -1,2 +1,9 @@
+CVS info : $Header$
+
+Cactus Code Thorn LocalReduce
+Thorn Author(s) : Ravi Paruchuri <ravi9@bit.csc.lsu.edu>
+Thorn Maintainer(s) : Ravi Paruchuri <ravi9@bit.csc.lsu.edu>
+--------------------------------------------------------------------------
+
+Purpose of the thorn:
-General utility thorns, providing for example coordinates, boundary conditions, and basic IO functionality
diff --git a/doc/documentation.tex b/doc/documentation.tex
new file mode 100644
index 0000000..fc61ad3
--- /dev/null
+++ b/doc/documentation.tex
@@ -0,0 +1,144 @@
+% *======================================================================*
+% Cactus Thorn template for ThornGuide documentation
+% Author: Ian Kelley
+% Date: Sun Jun 02, 2002
+% $Header$
+%
+% Thorn documentation in the latex file doc/documentation.tex
+% will be included in ThornGuides built with the Cactus make system.
+% The scripts employed by the make system automatically include
+% pages about variables, parameters and scheduling parsed from the
+% relevant thorn CCL files.
+%
+% This template contains guidelines which help to assure that your
+% documentation will be correctly added to ThornGuides. More
+% information is available in the Cactus UsersGuide.
+%
+% Guidelines:
+% - Do not change anything before the line
+% % START CACTUS THORNGUIDE",
+% except for filling in the title, author, date, etc. fields.
+% - Each of these fields should only be on ONE line.
+% - Author names should be separated with a \\ or a comma.
+% - You can define your own macros, but they must appear after
+% the START CACTUS THORNGUIDE line, and must not redefine standard
+% latex commands.
+% - To avoid name clashes with other thorns, 'labels', 'citations',
+% 'references', and 'image' names should conform to the following
+% convention:
+% ARRANGEMENT_THORN_LABEL
+% For example, an image wave.eps in the arrangement CactusWave and
+% thorn WaveToyC should be renamed to CactusWave_WaveToyC_wave.eps
+% - Graphics should only be included using the graphicx package.
+% More specifically, with the "\includegraphics" command. Do
+% not specify any graphic file extensions in your .tex file. This
+% will allow us to create a PDF version of the ThornGuide
+% via pdflatex.
+% - References should be included with the latex "\bibitem" command.
+% - Use \begin{abstract}...\end{abstract} instead of \abstract{...}
+% - Do not use \appendix, instead include any appendices you need as
+% standard sections.
+% - For the benefit of our Perl scripts, and for future extensions,
+% please use simple latex.
+%
+% *======================================================================*
+%
+% Example of including a graphic image:
+% \begin{figure}[ht]
+% \begin{center}
+% \includegraphics[width=6cm]{MyArrangement_MyThorn_MyFigure}
+% \end{center}
+% \caption{Illustration of this and that}
+% \label{MyArrangement_MyThorn_MyLabel}
+% \end{figure}
+%
+% Example of using a label:
+% \label{MyArrangement_MyThorn_MyLabel}
+%
+% Example of a citation:
+% \cite{MyArrangement_MyThorn_Author99}
+%
+% Example of including a reference
+% \bibitem{MyArrangement_MyThorn_Author99}
+% {J. Author, {\em The Title of the Book, Journal, or periodical}, 1 (1999),
+% 1--16. {\tt http://www.nowhere.com/}}
+%
+% *======================================================================*
+
+% If you are using CVS use this line to give version information
+% $Header$
+
+\documentclass{article}
+
+% Use the Cactus ThornGuide style file
+% (Automatically used from Cactus distribution, if you have a
+% thorn without the Cactus Flesh download this from the Cactus
+% homepage at www.cactuscode.org)
+\usepackage{../../../../doc/latex/cactus}
+
+\begin{document}
+
+% The author of the documentation
+\author{Ravi Paruchuri \textless ravi9@bit.csc.lsu.edu\textgreater}
+
+% The title of the document (not necessarily the name of the Thorn)
+\title{}
+
+% the date your document was last changed, if your document is in CVS,
+% please use:
+% \date{$ $Date$ $}
+\date{May 26 2004}
+
+\maketitle
+
+% Do not delete next line
+% START CACTUS THORNGUIDE
+
+% Add all definitions used in this documentation here
+% \def\mydef etc
+
+% Add an abstract for this thorn's documentation
+\begin{abstract}
+
+\end{abstract}
+
+% The following sections are suggestive only.
+% Remove them or add your own.
+
+\section{Introduction}
+
+\section{Physical System}
+
+\section{Numerical Implementation}
+
+\section{Using This Thorn}
+
+\subsection{Obtaining This Thorn}
+
+\subsection{Basic Usage}
+
+\subsection{Special Behaviour}
+
+\subsection{Interaction With Other Thorns}
+
+\subsection{Examples}
+
+\subsection{Support and Feedback}
+
+\section{History}
+
+\subsection{Thorn Source Code}
+
+\subsection{Thorn Documentation}
+
+\subsection{Acknowledgements}
+
+
+\begin{thebibliography}{9}
+
+\end{thebibliography}
+
+% Do not delete next line
+% END CACTUS THORNGUIDE
+
+\end{document}
diff --git a/interface.ccl b/interface.ccl
new file mode 100644
index 0000000..cd376e1
--- /dev/null
+++ b/interface.ccl
@@ -0,0 +1,5 @@
+# Interface definition for thorn LocalReduce
+# $Header$
+
+implements: LocalInterp
+inherits:
diff --git a/param.ccl b/param.ccl
new file mode 100644
index 0000000..33d07b6
--- /dev/null
+++ b/param.ccl
@@ -0,0 +1,2 @@
+# Parameter definitions for thorn LocalReduce
+# $Header$
diff --git a/schedule.ccl b/schedule.ccl
new file mode 100644
index 0000000..a1c0150
--- /dev/null
+++ b/schedule.ccl
@@ -0,0 +1,7 @@
+# Schedule definitions for thorn LocalReduce
+# $Header$
+
+Schedule LocalReduce_Startup at STARTUP after Driver_Startup
+{
+LANG:C
+} "register LocalReduce's reducation operators"
diff --git a/src/Reduction.c b/src/Reduction.c
new file mode 100644
index 0000000..d49a468
--- /dev/null
+++ b/src/Reduction.c
@@ -0,0 +1,328 @@
+ /*@@
+ @file Reduction.c
+ @date Thu May 27 13:52:53 2004
+ @author Ravi Paruchuri
+ @desc
+ Local Reduction operators
+ @enddesc
+ @version $Id$
+ @@*/
+
+#include <stdlib.h>
+
+
+
+static const char *rcsid = "$Header$";
+
+CCTK_FILEVERSION(CactusBase_LocalReduce_Reduction_c)
+
+/********************************************************************
+ ********************* External Routines **********************
+ ********************************************************************/
+
+ /*@@
+ @routine LocalReductionArrays
+ @author Thomas Radke
+ @date 19 Aug 1999
+ @desc
+ Wrapper to reduce a list of arrays.
+ Just calls the appropriate reduction operator and does
+ the type conversion of the results.
+ @enddesc
+ @calls copy_real_to_outtype
+
+ @var num_dims
+ @vdesc number of dimensions of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var dims
+ @vdesc dimensions of input arrays
+ @vtype int *
+ @vio in
+ @endvar
+ @var intype
+ @vdesc (common) variable type of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var num_inarrays
+ @vdesc number of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var inarrays
+ @vdesc field of input arrays
+ @vtype const void *const *
+ @vio in
+ @endvar
+ @var outtype
+ @vdesc (common) variable type of output arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var num_outvals
+ @vdesc number of values per output array
+ @vtype int
+ @vio in
+ @endvar
+ @var outvals
+ @vdesc pointer to buffer holding the output values
+ @vtype void *
+ @vio in
+ @endvar
+ @var reduction_fn
+ @vdesc reduction operator callback
+ @vtype reduction_fn_t
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ the return code of the reduction operator, or<BR>
+ -1 if array size is zero<BR>
+ -2 if <num_outvals> is invalid
+ @endreturndesc
+@@*/
+int LocalReduce_ReductionArrays ( int num_dims,
+ const int dims[/* num_dims */],
+ int intypes[],
+ int num_inarrays,
+ const void *const inarrays[/* num_inarrays */],
+ int outtypes[],
+ int num_outvals,
+ void *outvals[] /* [num_outvals] */,
+ reduction_fn_t reduction_fn)
+{
+ int i, num_points, retval;
+ int from[1], to[1], iterator[1], points_per_dim[1];
+ int intypes;
+ CCTK_REAL buffer;
+
+ points_per_dim[0] = 1;
+ from[0] = 0;
+ to[0] = dims[0];
+
+ /* get the total number of array elements */
+ for (i = 1; i < num_dims; i++)
+ {
+ to[0] *= dims[i];
+ }
+
+ /* check for zero-sized arrays */
+ if (to[0] <= 0)
+ {
+ CCTK_WARN (2, "LocalReduce_ReductionArrays: Cannot reduce zero-sized arrays");
+ return (-1);
+ }
+
+ if (num_outvals != 1)
+ {
+ if (num_outvals != to[0])
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "LocalReduce_ReductionArrays: Don't know how to reduce "
+ "a %d-dimensional array with %d elements "
+ "to an output array of %d elements",
+ num_dims, to[0], num_outvals);
+ return (-2);
+ }
+ to[0] = 1;
+ }
+ num_points = to[0];
+
+ for(array = 0 ; array < num_inarrays; array++)
+ {
+
+ /* set the array types to intype */
+ /* FIXME: could allow to pass in arrays of different types now !!! */
+ intype = intypes[array];
+
+ /* do the reduction on the input arrays */
+ retval = reduction_fn (num_dims, from, to, iterator, points_per_dim,
+ num_points, 1, 1, intype, inarrays[array],
+ 1, buffer);
+
+ if (retval == 0 )
+ {
+ /* type-cast the result to the requested datatype */
+ retval = copy_real_to_outtype (1,
+ buffer, outtype[array], outvals[array]);
+ }
+ }
+ return (retval);
+}
+
+
+ /*@@
+ @routine copy_real_to_outtype
+ @author Thomas Radke
+ @date 19 Aug 1999
+ @desc
+ Does the type conversion from CCTK_REAL into the requested
+ datatype.
+ @enddesc
+ @calls CCTK_VarTypeSize
+ CCTK_GroupTypeFromVarI
+ ReductionGA
+ copy_real_to_outtype
+
+ @var num_elems
+ @vdesc number of elements to convert
+ @vtype int
+ @vio in
+ @endvar
+ @var inarray
+ @vdesc input array with results of reductions
+ @vtype CCTK_REAL *
+ @vio in
+ @endvar
+ @var outtype
+ @vdesc requested output datatype
+ @vtype int
+ @vio in
+ @endvar
+ @var outarray
+ @vdesc pointer to output buffer to store the converted results
+ @vtype void *
+ @vio out
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 for success, or<BR>
+ -1 if conversion into target datatype is not supported.
+ @endreturndesc
+@@*/
+static int copy_real_to_outtype (int num_elems,
+ CCTK_REAL inarray[/* num_elems */],
+ int outtype,
+ void *outarray /* [num_elems] */)
+{
+ int i, retval;
+
+
+ retval = 0;
+
+ if (outtype == CCTK_VARIABLE_CHAR)
+ {
+ CCTK_BYTE *_outarray = (CCTK_CHAR *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_BYTE) inarray[i];
+ }
+ }
+ else if (outtype == CCTK_VARIABLE_INT)
+ {
+ CCTK_INT *_outarray = (CCTK_INT *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_INT) inarray[i];
+ }
+ }
+#ifdef CCTK_INT1
+ else if (outtype == CCTK_VARIABLE_INT1)
+ {
+ CCTK_INT1 *_outarray = (CCTK_INT1 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_INT1) inarray[i];
+ }
+ }
+#endif
+#ifdef CCTK_INT2
+ else if (outtype == CCTK_VARIABLE_INT2)
+ {
+ CCTK_INT2 *_outarray = (CCTK_INT2 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_INT2) inarray[i];
+ }
+ }
+#endif
+#ifdef CCTK_INT4
+ else if (outtype == CCTK_VARIABLE_INT4)
+ {
+ CCTK_INT4 *_outarray = (CCTK_INT4 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_INT4) inarray[i];
+ }
+ }
+#endif
+#ifdef CCTK_INT8
+ else if (outtype == CCTK_VARIABLE_INT8)
+ {
+ CCTK_INT8 *_outarray = (CCTK_INT8 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_INT8) inarray[i];
+ }
+ }
+#endif
+ else if (outtype == CCTK_VARIABLE_REAL)
+ {
+ CCTK_REAL *_outarray = (CCTK_REAL *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_REAL) inarray[i];
+ }
+ }
+#ifdef CCTK_REAL4
+ else if (outtype == CCTK_VARIABLE_REAL4)
+ {
+ CCTK_REAL4 *_outarray = (CCTK_REAL4 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_REAL4) inarray[i];
+ }
+ }
+#endif
+#ifdef CCTK_REAL8
+ else if (outtype == CCTK_VARIABLE_REAL8)
+ {
+ CCTK_REAL8 *_outarray = (CCTK_REAL8 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_REAL8) inarray[i];
+ }
+ }
+#endif
+#ifdef CCTK_REAL16
+ else if (outtype == CCTK_VARIABLE_REAL16)
+ {
+ CCTK_REAL16 *_outarray = (CCTK_REAL16 *) outarray;
+
+
+ for (i = 0; i < num_elems; i++)
+ {
+ _outarray[i] = (CCTK_REAL16) inarray[i];
+ }
+ }
+#endif
+ else
+ {
+ CCTK_WARN (1, "copy_real_to_outtype: Unsupported output type");
+ retval = -1;
+ }
+
+ return (retval);
+}
diff --git a/src/ReductionAvg.c b/src/ReductionAvg.c
new file mode 100644
index 0000000..4569307
--- /dev/null
+++ b/src/ReductionAvg.c
@@ -0,0 +1,256 @@
+ /*@@
+ @file ReductionAvg.c
+ @date Thu May 27 14:14:53 2004
+ @author Ravi Paruchuri
+ @desc
+ Defines the reduction operator to get the average
+ of an arbitrary array.
+ @enddesc
+ @version $Id$
+ @@*/
+
+#include <stdlib.h>
+#include <string.h>
+
+
+static const char *rcsid = "$Id$";
+
+CCTK_FILEVERSION(CactusBase_LocalReduce_ReductionAvg_c)
+
+/* local function prototypes */
+static int ReductionAvg (int num_dims,
+ const int from[/* dim */],
+ const int to[/* dim */],
+ int iterator[/* dim */],
+ const int points_per_dim[/* dim */],
+ int num_points,
+ int have_local_points,
+ int num_inarrays,
+ const int intypes[/* num_inarrays */],
+ const void *const inarrays[/* num_inarrays */],
+ int num_outvals,
+ void *outvals[/*num_inarrays*num_outvals*/]);
+
+
+/*@@
+ @routine LocalReduce_ReductionAvgArrays
+ @author Ravi Paruchuri
+ @date May 27 2004
+ @desc
+ Registered reduction routine for computing the averages
+ of a set of arrays.
+ The arrays are described by their dimensions and variable type.
+ For the number of output values only 1 is accepted.
+ Type casting of the result is provided by specifying the
+ requested output datatype. The intermediate reduction value
+ is always computed as a CCTK_REAL value internally.
+ @enddesc
+ @history
+ @endhistory
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var proc
+ @vdesc processor that should receive the result of operation
+ (negative value means all processors receive the result)
+ @vtype int
+ @vio in
+ @endvar
+ @var nDims
+ @vdesc number of dimensions of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var dims
+ @vdesc dimensions of input arrays
+ @vtype const int *
+ @vio in
+ @endvar
+ @var nArrays
+ @vdesc number of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var inarrays
+ @vdesc field of input arrays
+ @vtype const void *const
+ @vio in
+ @endvar
+ @var inType
+ @vdesc (common) variable type of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var num_outvals
+ @vdesc number of values per output array
+ @vtype int
+ @vio in
+ @endvar
+ @var outvals
+ @vdesc pointer to buffer holding the output values
+ @vtype void *
+ @vio in
+ @endvar
+ @var outtype
+ @vdesc (common) variable type of output arrays
+ @vtype int
+ @vio in
+ @endvar
+@@*/
+int LocalReduce_ReductionAvgArrays (const cGH *GH,
+ int proc,
+ int num_dims,
+ const int dims[/* num_dims */],
+ int num_inarrays,
+ const void *const inarrays[/* num_inarrays */],
+ int intype,
+ int num_outvals,
+ void *outvals[], /* [num_outvals] */,
+ int outtype)
+{
+ return (LocalReduce_ReductionArrays (num_dims, dims,
+ intype, num_inarrays, inarrays,
+ outtype, num_outvals, outvals,
+ ReductionAvg));
+}
+
+
+/*****************************************************************************/
+/* local functions */
+/*****************************************************************************/
+/*@@
+ @routine ReductionAvg
+ @date Aug 19 1999
+ @author Thomas Radke
+ @desc Returns the average of a distributed array with
+ 'num_points' elements. Global reduction is done element-wise
+ (num_outvals == 1) or on the results of the local reductions.
+ @enddesc
+@@*/
+static int ReductionAvg (int num_dims,
+ const int from[/* dim */],
+ const int to[/* dim */],
+ int iterator[/* dim */],
+ const int points_per_dim[/* dim */],
+ int num_points,
+ int have_local_points,
+ int num_inarrays,
+ const int intypes[/* num_inarrays */],
+ const void *const inarrays[/* num_inarrays */],
+ int num_outvals,
+ CCTK_REAL outvals[/*num_inarrays*num_outvals*/])
+{
+ int i, total_outvals;
+ const char *vtypename;
+ const pGH *pughGH;
+
+
+ /* avoid compiler warnings about unused parameters */
+ (void) (num_points + 0);
+
+/* macros to complete the ITERATE_ARRAY macro */
+#define INITIAL_REDUCTION_VALUE(array) 0
+#define REDUCTION_OPERATION(avg, scalar) avg += scalar
+
+ for (i = total_outvals = 0; i < num_inarrays; i++)
+ {
+ switch (intypes[i])
+ {
+ case CCTK_VARIABLE_CHAR:
+ ITERATE_ARRAY (CCTK_BYTE, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_BYTE, outvals, num_outvals, total_outvals);
+ break;
+
+ case CCTK_VARIABLE_INT:
+ ITERATE_ARRAY (CCTK_INT, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_INT, outvals, num_outvals, total_outvals);
+ break;
+
+#ifdef CCTK_INT1
+ case CCTK_VARIABLE_INT1:
+ ITERATE_ARRAY (CCTK_INT1, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_INT1, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+#ifdef CCTK_INT2
+ case CCTK_VARIABLE_INT2:
+ ITERATE_ARRAY (CCTK_INT2, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_INT2, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+#ifdef CCTK_INT4
+ case CCTK_VARIABLE_INT4:
+ ITERATE_ARRAY (CCTK_INT4, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_INT4, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+#ifdef CCTK_INT8
+ case CCTK_VARIABLE_INT8:
+ ITERATE_ARRAY (CCTK_INT8, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_INT8, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+ case CCTK_VARIABLE_REAL:
+ ITERATE_ARRAY (CCTK_REAL, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_REAL, outvals, num_outvals, total_outvals);
+ break;
+
+#ifdef CCTK_REAL4
+ case CCTK_VARIABLE_REAL4:
+ ITERATE_ARRAY (CCTK_REAL4, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_REAL4, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+#ifdef CCTK_REAL8
+ case CCTK_VARIABLE_REAL8:
+ ITERATE_ARRAY (CCTK_REAL8, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_REAL8, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+#ifdef CCTK_REAL16
+ case CCTK_VARIABLE_REAL16:
+ ITERATE_ARRAY (CCTK_REAL16, num_dims, inarrays[i],
+ from, to, iterator, points_per_dim,
+ CCTK_REAL16, outvals, num_outvals, total_outvals);
+ break;
+#endif
+
+ default:
+ vtypename = CCTK_VarTypeName (intypes[i]);
+ if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0)
+ {
+ CCTK_WARN (1, "LocalReduce_ReductionAvg: Don't know how to compute "
+ "the average of complex variables !!!");
+ }
+ else
+ {
+ CCTK_WARN (1, "LocalReduce_ReductionAvg: Unknown variable type");
+ }
+ return (-1);
+ }
+ }
+
+ for (i = 0; i < total_outvals; i++)
+ {
+ outvals[i] /= num_points;
+ }
+
+ return (0);
+}
diff --git a/src/Startup.c b/src/Startup.c
new file mode 100644
index 0000000..ff8c0f7
--- /dev/null
+++ b/src/Startup.c
@@ -0,0 +1,29 @@
+ /*@@
+ @file Startup.c
+ @date
+ @author
+ @desc
+ Startup routines for LocalReduce.
+ @enddesc
+ @version $Id$
+@@*/
+
+#include "cctk.h"
+
+static const char *rcsid="$Id$";
+
+CCTK_FILEVERSION(CactusBase_LocalReduce_Startup_c)
+
+
+/* prototypes of routines defined in this source file */
+int LocalReduce_Startup(void);
+
+
+int LocalReduce_Startup (void)
+{
+ /* Register the reduction operators */
+
+ CCTK_RegisterReductionArrayOperator (Local_ReductionAvgArrays, "average");
+
+ return (0);
+}
diff --git a/src/make.code.defn b/src/make.code.defn
new file mode 100644
index 0000000..a0ac3c2
--- /dev/null
+++ b/src/make.code.defn
@@ -0,0 +1,8 @@
+# Main make.code.defn file for thorn LocalReduce
+# $Header$
+
+# Source files in this directory
+SRCS = Startup.c Reduction.c ReductionAvg.c
+
+# Subdirectories containing source files
+SUBDIRS =