From 8c3e6378ed7611f479813ef9c780d2b2811a284b Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 20 Jan 2013 17:38:06 -0500 Subject: TestLoopControl: New thorn --- CarpetExtra/TestLoopControl/README | 9 + CarpetExtra/TestLoopControl/configuration.ccl | 3 + CarpetExtra/TestLoopControl/doc/documentation.tex | 144 +++++++++++ CarpetExtra/TestLoopControl/interface.ccl | 33 +++ CarpetExtra/TestLoopControl/param.ccl | 1 + CarpetExtra/TestLoopControl/schedule.ccl | 18 ++ CarpetExtra/TestLoopControl/src/TestLoopC.c | 148 ++++++++++++ .../TestLoopControl/src/TestLoopFortran.F90 | 94 ++++++++ .../TestLoopControl/src/TestLoopPointwise.c | 267 +++++++++++++++++++++ CarpetExtra/TestLoopControl/src/make.code.defn | 7 + CarpetExtra/TestLoopControl/test/testloop.par | 10 + 11 files changed, 734 insertions(+) create mode 100644 CarpetExtra/TestLoopControl/README create mode 100644 CarpetExtra/TestLoopControl/configuration.ccl create mode 100644 CarpetExtra/TestLoopControl/doc/documentation.tex create mode 100644 CarpetExtra/TestLoopControl/interface.ccl create mode 100644 CarpetExtra/TestLoopControl/param.ccl create mode 100644 CarpetExtra/TestLoopControl/schedule.ccl create mode 100644 CarpetExtra/TestLoopControl/src/TestLoopC.c create mode 100644 CarpetExtra/TestLoopControl/src/TestLoopFortran.F90 create mode 100644 CarpetExtra/TestLoopControl/src/TestLoopPointwise.c create mode 100644 CarpetExtra/TestLoopControl/src/make.code.defn create mode 100644 CarpetExtra/TestLoopControl/test/testloop.par (limited to 'CarpetExtra') 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 +Maintainer(s): Erik Schnetter +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 +#include +#include + +#include + + + +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 +#include +#include + +#include + +#include + + + +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 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 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 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 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" -- cgit v1.2.3