aboutsummaryrefslogtreecommitdiff
path: root/CarpetExtra
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-01-20 17:38:06 -0500
committerErik Schnetter <schnetter@gmail.com>2013-01-20 17:38:06 -0500
commit8c3e6378ed7611f479813ef9c780d2b2811a284b (patch)
treeb524fed00fb5a4ad81da8b42562db7520e0e1b12 /CarpetExtra
parent7e08602bb50cfd2ce0396fedc119544211e29aca (diff)
TestLoopControl: New thorn
Diffstat (limited to 'CarpetExtra')
-rw-r--r--CarpetExtra/TestLoopControl/README9
-rw-r--r--CarpetExtra/TestLoopControl/configuration.ccl3
-rw-r--r--CarpetExtra/TestLoopControl/doc/documentation.tex144
-rw-r--r--CarpetExtra/TestLoopControl/interface.ccl33
-rw-r--r--CarpetExtra/TestLoopControl/param.ccl1
-rw-r--r--CarpetExtra/TestLoopControl/schedule.ccl18
-rw-r--r--CarpetExtra/TestLoopControl/src/TestLoopC.c148
-rw-r--r--CarpetExtra/TestLoopControl/src/TestLoopFortran.F9094
-rw-r--r--CarpetExtra/TestLoopControl/src/TestLoopPointwise.c267
-rw-r--r--CarpetExtra/TestLoopControl/src/make.code.defn7
-rw-r--r--CarpetExtra/TestLoopControl/test/testloop.par10
11 files changed, 734 insertions, 0 deletions
diff --git a/CarpetExtra/TestLoopControl/README b/CarpetExtra/TestLoopControl/README
new file mode 100644
index 000000000..fe1f5e54e
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/README
@@ -0,0 +1,9 @@
+Cactus Code Thorn TestLoopControl
+Author(s) : Erik Schnetter <schnetter@gmail.com>
+Maintainer(s): Erik Schnetter <schnetter@gmail.com>
+Licence : LGPL
+--------------------------------------------------------------------------
+
+1. Purpose
+
+not documented
diff --git a/CarpetExtra/TestLoopControl/configuration.ccl b/CarpetExtra/TestLoopControl/configuration.ccl
new file mode 100644
index 000000000..cd8828892
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/configuration.ccl
@@ -0,0 +1,3 @@
+# Configuration definition for thorn TestLoopControl
+
+REQUIRES LoopControl
diff --git a/CarpetExtra/TestLoopControl/doc/documentation.tex b/CarpetExtra/TestLoopControl/doc/documentation.tex
new file mode 100644
index 000000000..05518f1d5
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/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{Erik Schnetter \textless schnetter@gmail.com\textgreater}
+
+% The title of the document (not necessarily the name of the Thorn)
+\title{TestLoopControl}
+
+% the date your document was last changed, if your document is in CVS,
+% please use:
+% \date{$ $Date: 2009-11-12 16:20:48 -0600 (Thu, 12 Nov 2009) $ $}
+\date{December 22 2012}
+
+\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/CarpetExtra/TestLoopControl/interface.ccl b/CarpetExtra/TestLoopControl/interface.ccl
new file mode 100644
index 000000000..06d732cde
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/interface.ccl
@@ -0,0 +1,33 @@
+# Interface definition for thorn TestLoopControl
+
+IMPLEMENTS: TestLoopControl
+
+INHERITS: grid
+
+USES INCLUDE HEADER: loopcontrol.h
+
+
+
+# Convenient way to determine boundary sizes
+CCTK_INT FUNCTION GetBoundarySizesAndTypes \
+ (CCTK_POINTER_TO_CONST IN cctkGH, \
+ CCTK_INT IN size, \
+ CCTK_INT OUT ARRAY bndsize, \
+ CCTK_INT OUT ARRAY is_ghostbnd, \
+ CCTK_INT OUT ARRAY is_symbnd, \
+ CCTK_INT OUT ARRAY is_physbnd)
+REQUIRES FUNCTION GetBoundarySizesAndTypes
+
+
+
+CCTK_REAL csums TYPE=scalar
+{
+ csum_all csum_int csum_bnd csum_intbnd
+} "Result values for C test cases"
+
+CCTK_REAL fsums TYPE=scalar
+{
+ fsum_all fsum_int fsum_bnd fsum_intbnd
+} "Result values for Fortran test cases"
+
+CCTK_INT pointtypes TYPE=GF "Grid function point types"
diff --git a/CarpetExtra/TestLoopControl/param.ccl b/CarpetExtra/TestLoopControl/param.ccl
new file mode 100644
index 000000000..2eab652d9
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/param.ccl
@@ -0,0 +1 @@
+# Parameter definitions for thorn TestLoopControl
diff --git a/CarpetExtra/TestLoopControl/schedule.ccl b/CarpetExtra/TestLoopControl/schedule.ccl
new file mode 100644
index 000000000..ecf656327
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/schedule.ccl
@@ -0,0 +1,18 @@
+# Schedule definitions for thorn TestLoopControl
+
+STORAGE: csums fsums pointtypes
+
+SCHEDULE TestLoopControlPointwise AT initial
+{
+ LANG: C
+} "Test loop iterators pointwise"
+
+SCHEDULE TestLoopControlC AT initial
+{
+ LANG: C
+} "Test loop iterators"
+
+SCHEDULE TestLoopControlFortran AT initial
+{
+ LANG: Fortran
+} "Test loop iterators"
diff --git a/CarpetExtra/TestLoopControl/src/TestLoopC.c b/CarpetExtra/TestLoopControl/src/TestLoopC.c
new file mode 100644
index 000000000..fbd65cbc3
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/src/TestLoopC.c
@@ -0,0 +1,148 @@
+#include <cctk.h>
+#include <cctk_Arguments.h>
+#include <cctk_Parameters.h>
+
+#include <loopcontrol.h>
+
+
+
+void TestLoopControlC(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ switch (cctk_dim) {
+
+ case 1: {
+ /* 1D */
+
+ *csum_all = 0.0;
+ CCTK_LOOP1_ALL(loop1_all, cctkGH, i) {
+ int const ind1d = CCTK_GFINDEX1D(cctkGH, i);
+ *csum_all += r[ind1d];
+ } CCTK_ENDLOOP1_ALL(loop1_all);
+
+ *csum_int = 0.0;
+ CCTK_LOOP1_INT(loop1_int, cctkGH, i) {
+ int const ind1d = CCTK_GFINDEX1D(cctkGH, i);
+ *csum_int += r[ind1d];
+ } CCTK_ENDLOOP1_INT(loop1_int);
+
+ *csum_bnd = 0.0;
+ CCTK_LOOP1_BND(loop1_bnd, cctkGH, i, ni) {
+ int const ind1d = CCTK_GFINDEX1D(cctkGH, i);
+ *csum_bnd += r[ind1d];
+ } CCTK_ENDLOOP1_BND(loop1_bnd);
+
+ *csum_intbnd = 0.0;
+ CCTK_LOOP1_INTBND(loop1_intbnd, cctkGH, i, ni) {
+ int const ind1d = CCTK_GFINDEX1D(cctkGH, i);
+ *csum_intbnd += r[ind1d];
+ } CCTK_ENDLOOP1_INTBND(loop1_intbnd);
+
+ break;
+ }
+
+
+
+ case 2:{
+ /* 2D */
+
+ *csum_all = 0.0;
+ CCTK_LOOP2_ALL(loop2_all, cctkGH, i,j) {
+ int const ind2d = CCTK_GFINDEX2D(cctkGH, i,j);
+ *csum_all += r[ind2d];
+ } CCTK_ENDLOOP2_ALL(loop2_all);
+
+ *csum_int = 0.0;
+ CCTK_LOOP2_INT(loop2_int, cctkGH, i,j) {
+ int const ind2d = CCTK_GFINDEX2D(cctkGH, i,j);
+ *csum_int += r[ind2d];
+ } CCTK_ENDLOOP2_INT(loop2_int);
+
+ *csum_bnd = 0.0;
+ CCTK_LOOP2_BND(loop2_bnd, cctkGH, i,j, ni,nj) {
+ int const ind2d = CCTK_GFINDEX2D(cctkGH, i,j);
+ *csum_bnd += r[ind2d];
+ } CCTK_ENDLOOP2_BND(loop2_bnd);
+
+ *csum_intbnd = 0.0;
+ CCTK_LOOP2_INTBND(loop2_intbnd, cctkGH, i,j, ni,nj) {
+ int const ind2d = CCTK_GFINDEX2D(cctkGH, i,j);
+ *csum_intbnd += r[ind2d];
+ } CCTK_ENDLOOP2_INTBND(loop2_intbnd);
+
+ break;
+ }
+
+
+
+ case 3: {
+ /* 3D */
+
+ *csum_all = 0.0;
+ CCTK_LOOP3_ALL(loop3_all, cctkGH, i,j,k) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ *csum_all += r[ind3d];
+ } CCTK_ENDLOOP3_ALL(loop3_all);
+
+ *csum_int = 0.0;
+ CCTK_LOOP3_INT(loop3_int, cctkGH, i,j,k) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ *csum_int += r[ind3d];
+ } CCTK_ENDLOOP3_INT(loop3_int);
+
+ *csum_bnd = 0.0;
+ CCTK_LOOP3_BND(loop3_bnd, cctkGH, i,j,k, ni,nj,nk) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ *csum_bnd += r[ind3d];
+ } CCTK_ENDLOOP3_BND(loop3_bnd);
+
+ *csum_intbnd = 0.0;
+ CCTK_LOOP3_INTBND(loop3_intbnd, cctkGH, i,j,k, ni,nj,nk) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ *csum_intbnd += r[ind3d];
+ } CCTK_ENDLOOP3_INTBND(loop3_intbnd);
+
+ break;
+ }
+
+
+
+ case 4: {
+ /* 4D */
+
+ *csum_all = 0.0;
+ CCTK_LOOP4_ALL(loop4_all, cctkGH, i,j,k,l) {
+ int const ind4d = CCTK_GFINDEX4D(cctkGH, i,j,k,l);
+ *csum_all += r[ind4d];
+ } CCTK_ENDLOOP4_ALL(loop4_all);
+
+ *csum_int = 0.0;
+ CCTK_LOOP4_INT(loop4_int, cctkGH, i,j,k,l) {
+ int const ind4d = CCTK_GFINDEX4D(cctkGH, i,j,k,l);
+ *csum_int += r[ind4d];
+ } CCTK_ENDLOOP4_INT(loop4_int);
+
+ *csum_bnd = 0.0;
+ CCTK_LOOP4_BND(loop4_bnd, cctkGH, i,j,k,l, ni,nj,nk,nl) {
+ int const ind4d = CCTK_GFINDEX4D(cctkGH, i,j,k,l);
+ *csum_bnd += r[ind4d];
+ } CCTK_ENDLOOP4_BND(loop4_bnd);
+
+ *csum_intbnd = 0.0;
+ CCTK_LOOP4_INTBND(loop4_intbnd, cctkGH, i,j,k,l, ni,nj,nk,nl) {
+ int const ind4d = CCTK_GFINDEX4D(cctkGH, i,j,k,l);
+ *csum_intbnd += r[ind4d];
+ } CCTK_ENDLOOP4_INTBND(loop4_intbnd);
+
+ break;
+ }
+
+
+
+ default:
+ CCTK_WARN(CCTK_WARN_ABORT, "cctk_dim out of range");
+
+ }
+}
diff --git a/CarpetExtra/TestLoopControl/src/TestLoopFortran.F90 b/CarpetExtra/TestLoopControl/src/TestLoopFortran.F90
new file mode 100644
index 000000000..9d9a8f7ad
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/src/TestLoopFortran.F90
@@ -0,0 +1,94 @@
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Functions.h"
+#include "cctk_Parameters.h"
+
+#include "loopcontrol.h"
+
+
+
+subroutine TestLoopControlFortran_all(CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_FUNCTIONS
+ DECLARE_CCTK_PARAMETERS
+
+ CCTK_LOOP3_ALL_DECLARE(all3)
+ integer :: i,j,k
+
+ call CCTK_INFO("TestLoopControlFortran_all")
+ fsum_all = 0
+ CCTK_LOOP3_ALL(all3, i,j,k)
+ fsum_all = fsum_all + r(i,j,k)
+ CCTK_ENDLOOP3_ALL(all3)
+end subroutine TestLoopControlFortran_all
+
+
+
+subroutine TestLoopControlFortran_int(CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_FUNCTIONS
+ DECLARE_CCTK_PARAMETERS
+
+ CCTK_LOOP3_INT_DECLARE(int3)
+ integer :: i,j,k
+
+ call CCTK_INFO("TestLoopControlFortran_int")
+ fsum_int = 0
+ CCTK_LOOP3_INT(int3, i,j,k)
+ fsum_int = fsum_int + r(i,j,k)
+ CCTK_ENDLOOP3_INT(int3)
+end subroutine TestLoopControlFortran_int
+
+
+
+subroutine TestLoopControlFortran_bnd(CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_FUNCTIONS
+ DECLARE_CCTK_PARAMETERS
+
+ CCTK_LOOP3_BND_DECLARE(bnd3)
+ integer :: i,j,k
+ integer :: ni,nj,nk
+
+ call CCTK_INFO("TestLoopControlFortran_bnd")
+ fsum_bnd = 0
+ CCTK_LOOP3_BND(bnd3, i,j,k, ni,nj,nk)
+ fsum_bnd = fsum_bnd + r(i,j,k)
+ CCTK_ENDLOOP3_BND(bnd3)
+end subroutine TestLoopControlFortran_bnd
+
+
+
+subroutine TestLoopControlFortran_intbnd(CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_FUNCTIONS
+ DECLARE_CCTK_PARAMETERS
+
+ CCTK_LOOP3_INTBND_DECLARE(intbnd3)
+ integer :: i,j,k
+ integer :: ni,nj,nk
+
+ call CCTK_INFO("TestLoopControlFortran_intbnd")
+ fsum_intbnd = 0
+ CCTK_LOOP3_INTBND(intbnd3, i,j,k, ni,nj,nk)
+ fsum_intbnd = fsum_intbnd + r(i,j,k)
+ CCTK_ENDLOOP3_INTBND(intbnd3)
+end subroutine TestLoopControlFortran_intbnd
+
+
+
+subroutine TestLoopControlFortran(CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_FUNCTIONS
+ DECLARE_CCTK_PARAMETERS
+
+ call TestLoopControlFortran_all(CCTK_PASS_FTOF)
+ call TestLoopControlFortran_int(CCTK_PASS_FTOF)
+ call TestLoopControlFortran_bnd(CCTK_PASS_FTOF)
+ call TestLoopControlFortran_intbnd(CCTK_PASS_FTOF)
+end subroutine TestLoopControlFortran
diff --git a/CarpetExtra/TestLoopControl/src/TestLoopPointwise.c b/CarpetExtra/TestLoopControl/src/TestLoopPointwise.c
new file mode 100644
index 000000000..8ac6a26bd
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/src/TestLoopPointwise.c
@@ -0,0 +1,267 @@
+#include <cctk.h>
+#include <cctk_Arguments.h>
+#include <cctk_Parameters.h>
+
+#include <stdio.h>
+
+#include <loopcontrol.h>
+
+
+
+static void TestLoopControlPointwise_All(CCTK_ARGUMENTS);
+static void TestLoopControlPointwise_Int(CCTK_ARGUMENTS);
+static void TestLoopControlPointwise_Bnd(CCTK_ARGUMENTS);
+static void TestLoopControlPointwise_IntBnd(CCTK_ARGUMENTS);
+
+
+
+void TestLoopControlPointwise_All(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 1;
+ }
+ }
+ }
+
+#pragma omp parallel
+ CCTK_LOOP3_ALL(loop3_all, cctkGH, i,j,k) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] -= 1;
+ } CCTK_ENDLOOP3_ALL(loop3_all);
+
+ int num_errors = 0;
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ num_errors += pointtypes[ind3d] != 0;
+ }
+ }
+ }
+ if (num_errors > 0) {
+ CCTK_WARN(CCTK_WARN_ABORT, "TestLoopControlPointwise_All failed");
+ }
+}
+
+
+
+void TestLoopControlPointwise_Int(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT bndsize [6];
+ CCTK_INT is_ghostbnd[6];
+ CCTK_INT is_symbnd [6];
+ CCTK_INT is_physbnd [6];
+ GetBoundarySizesAndTypes
+ (cctkGH, 6, bndsize, is_ghostbnd, is_symbnd, is_physbnd);
+
+ int imin[3], imax[3];
+ for (int d=0; d<3; ++d) {
+ imin[d] = cctk_bbox[2*d ] ? bndsize[2*d ] : cctk_nghostzones[d];
+ imax[d] = (cctk_lsh[d] -
+ (cctk_bbox[2*d+1] ? bndsize[2*d+1] : cctk_nghostzones[d]));
+ }
+
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 0;
+ }
+ }
+ }
+
+ for (int k=imin[2]; k<imax[2]; ++k) {
+ for (int j=imin[1]; j<imax[1]; ++j) {
+ for (int i=imin[0]; i<imax[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 1;
+ }
+ }
+ }
+
+#pragma omp parallel
+ CCTK_LOOP3_INT(loop3_int, cctkGH, i,j,k) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] -= 1;
+ } CCTK_ENDLOOP3_INT(loop3_int);
+
+ int num_errors = 0;
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ num_errors += pointtypes[ind3d] != 0;
+ }
+ }
+ }
+ if (num_errors > 0) {
+ CCTK_WARN(CCTK_WARN_ABORT, "TestLoopControlPointwise_Int failed");
+ }
+}
+
+
+
+void TestLoopControlPointwise_Bnd(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT bndsize [6];
+ CCTK_INT is_ghostbnd[6];
+ CCTK_INT is_symbnd [6];
+ CCTK_INT is_physbnd [6];
+ GetBoundarySizesAndTypes
+ (cctkGH, 6, bndsize, is_ghostbnd, is_symbnd, is_physbnd);
+
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 0;
+ }
+ }
+ }
+
+ for (int dir=0; dir<3; ++dir) {
+ for (int face=0; face<2; ++face) {
+ if (is_physbnd[2*dir+face]) {
+ int imin[3], imax[3];
+ for (int d=0; d<3; ++d) {
+ imin[d] = 0;
+ imax[d] = cctk_lsh[d];
+ }
+ if (face==0) {
+ imax[dir] = bndsize[2*dir];
+ } else {
+ imin[dir] = cctk_lsh[dir] - bndsize[2*dir+1];
+ }
+ for (int k=imin[2]; k<imax[2]; ++k) {
+ for (int j=imin[1]; j<imax[1]; ++j) {
+ for (int i=imin[0]; i<imax[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#pragma omp parallel
+ CCTK_LOOP3_BND(loop3_bnd, cctkGH, i,j,k, ni,nj,nk) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] -= 1;
+ } CCTK_ENDLOOP3_BND(loop3_bnd);
+
+ int num_errors = 0;
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ num_errors += pointtypes[ind3d] != 0;
+ if (pointtypes[ind3d] != 0) {
+ printf("[%d %d %d] %d\n", i,j,k, (int)pointtypes[ind3d]);
+ }
+ }
+ }
+ }
+ if (num_errors > 0) {
+ CCTK_WARN(CCTK_WARN_ABORT, "TestLoopControlPointwise_Bnd failed");
+ }
+}
+
+
+
+void TestLoopControlPointwise_IntBnd(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT bndsize [6];
+ CCTK_INT is_ghostbnd[6];
+ CCTK_INT is_symbnd [6];
+ CCTK_INT is_physbnd [6];
+ GetBoundarySizesAndTypes
+ (cctkGH, 6, bndsize, is_ghostbnd, is_symbnd, is_physbnd);
+
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 0;
+ }
+ }
+ }
+
+ for (int dir=0; dir<3; ++dir) {
+ for (int face=0; face<2; ++face) {
+ if (is_physbnd[2*dir+face] &&
+ !is_ghostbnd[2*dir+face] && !is_symbnd[2*dir+face])
+ {
+ int imin[3], imax[3];
+ for (int d=0; d<3; ++d) {
+ imin[d] = 0;
+ imax[d] = cctk_lsh[d];
+ }
+ if (face==0) {
+ imax[dir] = bndsize[2*dir];
+ } else {
+ imin[dir] = cctk_lsh[dir] - bndsize[2*dir+1];
+ }
+ for (int k=imin[2]; k<imax[2]; ++k) {
+ for (int j=imin[1]; j<imax[1]; ++j) {
+ for (int i=imin[0]; i<imax[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#pragma omp parallel
+ CCTK_LOOP3_INTBND(loop3_intbnd, cctkGH, i,j,k, ni,nj,nk) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ pointtypes[ind3d] += 1;
+ } CCTK_ENDLOOP3_INTBND(loop3_intbnd);
+
+ int num_errors = 0;
+ for (int k=0; k<cctk_lsh[2]; ++k) {
+ for (int j=0; j<cctk_lsh[1]; ++j) {
+ for (int i=0; i<cctk_lsh[0]; ++i) {
+ int const ind3d = CCTK_GFINDEX3D(cctkGH, i,j,k);
+ num_errors += pointtypes[ind3d] != 0 && pointtypes[ind3d] != 2;
+ }
+ }
+ }
+ if (num_errors > 0) {
+ CCTK_WARN(CCTK_WARN_ABORT, "TestLoopControlPointwise_IntBnd failed");
+ }
+}
+
+
+
+void TestLoopControlPointwise(CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ if (cctk_dim != 3) {
+ CCTK_WARN(CCTK_WARN_ABORT, "cctk_dim out of range");
+ }
+
+ TestLoopControlPointwise_All(CCTK_PASS_CTOC);
+ TestLoopControlPointwise_Int(CCTK_PASS_CTOC);
+ TestLoopControlPointwise_Bnd(CCTK_PASS_CTOC);
+ TestLoopControlPointwise_IntBnd(CCTK_PASS_CTOC);
+}
diff --git a/CarpetExtra/TestLoopControl/src/make.code.defn b/CarpetExtra/TestLoopControl/src/make.code.defn
new file mode 100644
index 000000000..8aa319c90
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/src/make.code.defn
@@ -0,0 +1,7 @@
+# Main make.code.defn file for thorn TestLoopControl
+
+# Source files in this directory
+SRCS = TestLoopPointwise.c TestLoopC.c TestLoopFortran.F90
+
+# Subdirectories containing source files
+SUBDIRS =
diff --git a/CarpetExtra/TestLoopControl/test/testloop.par b/CarpetExtra/TestLoopControl/test/testloop.par
new file mode 100644
index 000000000..c7dede266
--- /dev/null
+++ b/CarpetExtra/TestLoopControl/test/testloop.par
@@ -0,0 +1,10 @@
+ActiveThorns = "Boundary CartGrid3D CoordBase CycleClock hwloc IOBasic IOUtil LoopControl PUGH SymBase TestLoopControl"
+
+Cactus::cctk_itlast = 0
+
+IO::out_every = 1
+IO::out_dir = $parfile
+IO::out_fileinfo = "none"
+IO::parfile_write = "no"
+
+IOBasic::outScalar_vars = "TestLoopControl::csums TestLoopControl::fsums"