\frame[containsverbatim] { \frametitle{Arrangements}
  \begin{itemize}
    \item Group of thorns
    \item Organizational convenience
    \item Something in common:
      \begin{itemize}
        \item Related functionality
        \item Same author(s), research group
      \end{itemize}
   \item Toolkit: Collection of Arrangements
  \end{itemize}
 Directory structure:\\
 \centering\begin{minipage}{0.6\linewidth}
 \begin{alltt}
Cactus
`-- arrangements
    |-- Arrangement-A
    |   |-- Thorn-A1
    |   `-- Thorn-A2
    `-- Arrangement-B
        |-- Thorn-B1
        `-- Thorn-B2
 \end{alltt}
 \end{minipage}\\
}

\frame { \frametitle{Thorn Structure}
Inside view of a plug-in module, or thorn for Cactus
\begin{figure}
\vspace{0.0cm}
\hspace{0.0cm}
\centering
\includegraphics[height=0.55\textwidth]{thorn_arch}
\end{figure}
}

\frame[containsverbatim] { \frametitle{Thorn Structure}
 Directory structure:\\
 \centering\begin{minipage}{0.6\linewidth}
 \begin{alltt}
\textcolor{gray}{Cactus
`-- arrangements
    `-- Introduction}
        `-- HelloWorld
            |-- interface.ccl
            |-- param.ccl
            |-- schedule.ccl
            |-- README
            |-- doc
            |   `-- documentation.tex
            |-- src
            |   |-- HelloWorld.c
            |   `-- make.code.defn
            |-- test
            `-- utils
 \end{alltt}
 \end{minipage}\\
}

\frame[containsverbatim] { \frametitle{Thorn Structure}
 Directory structure:\\
 \centering\begin{minipage}{0.6\linewidth}
 \begin{alltt}
\textcolor{gray}{Cactus
`-- arrangements
    `-- Introduction}
        `-- HelloWorld
            \textcolor{blue}{|-- interface.ccl
            |-- param.ccl
            |-- schedule.ccl}
            |-- README
            |-- doc
            |   `-- documentation.tex
            |-- src
            |   |-- HelloWorld.c
            |   `-- make.code.defn
            |-- test
            `-- utils
 \end{alltt}
 \end{minipage}\\
}

\frame { \frametitle{Thorn Specification}
  Three configuration files per thorn:
  \begin{itemize}
    \item<1-> \textcolor{blue}{interface.ccl} declares:
      \begin{itemize}
        \item an 'implementation' name
        \item inheritance relationships between thorns
        \item Thorn variables
        \item Global functions, both provided and used
      \end{itemize}
    \item<2-> \textcolor{blue}{schedule.ccl} declares:
      \begin{itemize}
        \item When the flesh should schedule which functions
        \item When which variables should be allocated/freed
        \item Which variables should be syncronized when
      \end{itemize}
    \item<3-> \textcolor{blue}{param.ccl} declares:
      \begin{itemize}
        \item Runtime parameters for the thorn
        \item Use/extension of parameters of other thorns
      \end{itemize}
  \end{itemize}
}

\frame[containsverbatim]{ \frametitle{\texttt{interface.ccl}}
  Variables:
  \begin{itemize}
    \item Flesh needs to know about thorn variables for which it has to care about
          allocation, parallelism, inter-thorn use
    \item Scopes: public, private
    \item Many different basic types (double, integer, string, \ldots
    \item Different 'group types' (grid functions, grid arrays, scalars,
        \ldots)
    \item Different 'tags' (not to be checkpointed, vector types, \ldots)
  \end{itemize}
}

%\input{syntax_interface}

\frame[containsverbatim] { \frametitle{Example \texttt{interface.ccl}}
\begin{verbatim}
IMPLEMENTS: wavetoy

INHERITS: grid

PUBLIC:

REAL scalarevolve TYPE=gf TIMELEVELS=3
{
  phi
} "The evolved scalar field"
\end{verbatim}
}

\frame[containsverbatim] { \frametitle{Example \texttt{interface.ccl} cont.}
\begin{verbatim}
CCTK_INT FUNCTION Boundary_SelectVarForBC (
        CCTK_POINTER_TO_CONST IN cctkGH,
        CCTK_INT IN faces,
        CCTK_INT IN boundary_width,
        CCTK_INT IN options_handle,
        CCTK_STRING IN var_name,
        CCTK_STRING IN bc_name
        )

REQUIRES FUNCTION Boundary_SelectVarForBC
\end{verbatim}
}

\frame[containsverbatim]{ \frametitle{\texttt{schedule.ccl}}
  \begin{itemize}
    \item Flesh contains a flexible rule based scheduler
    \item Order is prescribed in \verb|schedule.ccl|
    \item Scheduler also handles when variables are allocated, freed or
          syncronized between parallel processes
    \item Functions or groups of functions can be
     \begin{itemize}
      \item grouped and whole group scheduled
      \item scheduled before or after each other
      \item scheduled depending on parameters
      \item scheduled while some condition is true
     \end{itemize}
    \item Flesh scheduler sorts all rules and flags an error for inconsistent
          schedule requests.
  \end{itemize}
}

\frame { \frametitle{\texttt{schedule.ccl} cont.}
  \begin{itemize}
  \item Hierarchy: using schedule groups leads to a \emph{schedule
      tree}
  \item Execution order: can schedule \texttt{BEFORE} or
    \texttt{AFTER} other items\\
    e.g.: take time step after calculating RHS
  \item Loops: can schedule \texttt{WHILE} a condition is true\\
    e.g.: loop while error is too large
  \item Conditions: can schedule \texttt{if} a parameter is set\\
    e.g.: choose between boundary conditions
  \item Perform analysis at run time: \texttt{TRIGGERS} statements:
    call routine only if result is needed for I/O
  \end{itemize}
}

\frame { \frametitle{Example scheduling tree}
 \centering\includegraphics[height=7cm]{pics/schedule_tree}\hspace{2cm}
           \includegraphics[height=7cm]{pics/schedule_tree_example}\\
}

%\input{syntax_schedule}

\frame[containsverbatim] { \frametitle{Example \texttt{schedule.ccl}}
\begin{verbatim}
SCHEDULE WaveToyC_Evolution AT evol
{
  LANG: C
} "Evolution of 3D wave equation"

SCHEDULE GROUP WaveToy_Boundaries AT evol \
               AFTER WaveToyC_Evolution
{
} "Boundaries of 3D wave equation"

STORAGE: scalarevolve[3]
\end{verbatim}
}

\frame[containsverbatim]{ \frametitle{\texttt{param.ccl}}
  \begin{itemize}
    \item Definition of parameters
    \item Scopes: Global, Restricted, Private
    \item Thorns can use and extened each others parameters
    \item Different types (double, integer, string, keyword, \ldots)
    \item Range checking and validation
    \item Steerablility at runtime
  \end{itemize}
}

%\input{syntax_param}

\frame[containsverbatim] { \frametitle{Example \texttt{param.ccl}}
\begin{verbatim}
SHARES: grid
USES KEYWORD type

PRIVATE:
KEYWORD initial_data "Type of initial data"
{
    "plane"    :: "Plane wave"
    "gaussian" :: "Gaussian wave"
} "gaussian"

REAL radius "The radius of the gaussian wave"
{
    0:* :: "Positive"
} 0.0
\end{verbatim}
}
