% CO5BOLD manual
% 2001-12-30,
% 2002-01-02,31, 02-16, 05-16, 12-11,14,
% 2003-01-15,16,21,23,26,27
% 2003-05-01 (hgl)
% 2003-05-05, 06-07, 10-21
% 2003-11-20 (SW, BF)
%
\documentclass[a4paper,11pt,twoside]{article}

\usepackage{html}

%\usepackage{amsmath}
%\usepackage{epsfig}
%\usepackage[dvips]{color}
\usepackage{color}

%\usepackage[pdftex]{graphicx}
\usepackage{graphicx}

\usepackage{latexsym}
\usepackage{makeidx}

\usepackage{alltt}
%\usepackage{fancyvrb}


% --- Page format ---
\setlength{\unitlength}{1cm}
\setlength{\textwidth}{16.2cm}
\setlength{\textheight}{26.0cm}
\addtolength{\oddsidemargin}{-0.9cm}    % right page (single-side)
\addtolength{\evensidemargin}{-2.2cm}
\addtolength{\topmargin}{-2.3cm}        % Distance header-text

% --- New LaTeX commands ---
\newcommand{\papa}[2] { \frac{\partial #1}{\partial #2} }
\newcommand{\papaco}[3] {{ \left. \frac{\partial #1}{\partial #2}\right|_{#3}}}
\newcommand{\tildepapaco}[3] {{ \left. \widetilde{\frac{\partial #1}{\partial #2}}\right|_{#3}}}

% --- HD abbreviations ---
\newcommand{\I}[1] {i{\rm #1}}
\newcommand{\m}[1] {m{\rm #1}}
\newcommand{\n}[1] {n{\rm #1}}
\newcommand{\mghost}[1] {m{\rm #1}_{\rm ghost}}
\newcommand{\nghost}[1] {n{\rm #1}_{\rm ghost}}
\newcommand{\dx}[1] {\Delta x{\rm #1}}
\newcommand{\xc}[1] {x{\rm c#1}}
\newcommand{\xb}[1] {x{\rm b#1}}
\newcommand{\g}[1]{g{\rm #1}}
\newcommand{\phic}{\phi{\rm c}}
\newcommand{\phib}{\phi{\rm b}}
\newcommand{\rhov}[1]{\rho v{\rm #1}}
\newcommand{\rhoei} {\rho e{\rm i}}
\newcommand{\rhoeik} {\rho e{\rm ik}}
\newcommand{\rhoeip} {\rho e{\rm ip}}
\newcommand{\rhoek} {\rho e{\rm k}}
\newcommand{\rhoeg} {\rho e{\rm g}}
\newcommand{\rhoeikg} {\rho e{\rm ikg}}
\newcommand{\V}[1]{v{\rm #1}}
\newcommand{\tildeV}[1]{\tilde{v}{\rm #1}}
\newcommand{\ei} {e{\rm i}}
\newcommand{\eg} {e{\rm g}}
\newcommand{\tildeei} {\tilde{e}{\rm i}}
\newcommand{\tildeeik} {\tilde{e}{\rm ik}}
\newcommand{\tildeek} {\tilde{e}{\rm k}}
\newcommand{\tildeeip} {\tilde{e}{\rm ip}}
\newcommand{\eikp} {e{\rm ikp}}
\newcommand{\tildeeikp} {\tilde{e}{\rm ikp}}
\newcommand{\dPdei} {\papaco{P}{\ei}{\rho}}
\newcommand{\dPdrho} {\papaco{P}{\rho}{\ei}}
\newcommand{\drhoeidP} {\papaco{\rhoei}{P}{s}}
\newcommand{\drhoeidrho} {\papaco{\rhoei}{\rho}{P}}
\newcommand{\tildedrhoeidP} {\tildepapaco{\rhoei}{P}{s}}
\newcommand{\CCour} {C_{\rm Courant}}
\newcommand{\CCourmax} {C_{\rm Courant,max}}
\newcommand{\iup} {i_{\rm up}}
\newcommand{\cs} {c}
\newcommand{\wL} {w{\rm L}}
\newcommand{\wR} {w{\rm R}}
\newcommand{\Pred}{{P_{\rm st}}}
\newcommand{\Deltat}{\mbox{\small $\Delta$} t}
\newcommand{\dvdx}[2] { \frac{\Delta \V{#1}}{\dx{#2}} }

\newcommand{\negsp}{\begin{latexonly}$\!$\end{latexonly}}
%\begin{latexonly}
%\newcommand{\negsp}{$\!$}
%\end{latexonly}
%\begin{htmlonly}
%\newcommand{\negsp}{}
%\end{htmlonly}

\definecolor{DEFcolor}{rgb}{0.0,0.0,0.0}
\definecolor{F90color}{rgb}{0.3,0.0,0.4}
\definecolor{IDLcolor}{rgb}{0.5,0.0,0.0}
\definecolor{MANcolor}{rgb}{0.4,0.3,0.0}
\definecolor{SHcolor}{rgb}{0.0,0.5,0.0}
\definecolor{TXTcolor}{rgb}{0.2,0.4,0.4}
\definecolor{UIOcolor}{rgb}{0.0,0.0,0.5}

%\DefineVerbatimEnvironment{UIOVerbatim}{Verbatim}
%  {frame=lines,rulecolor=\color{UIOcolor},formatcom=\color{UIOcolor}}

\sloppy

\makeindex

%##################################################################################################
\begin{document}

\DeclareGraphicsExtensions{.png}
%\DeclareGraphicsExtensions{.eps}

%\color{DEFcolor}

%\renewcommand{\labelitemii}{\color{blue} $\Box$}
%\renewcommand{\labelitemii}{$\Box$}
\renewcommand{\labelitemii}{$\circ$}


%\markboth{CO5BOLD User Manual}{CO5BOLD User Manual}
%\pagestyle{myheadings}
\pagestyle{headings}

\title{CO5BOLD User Manual}
\author{Bernd Freytag \and Matthias Steffen \and Sven Wedemeyer \and
  Hans-G\"unter Ludwig}
\date{\today}

\maketitle

\clearpage
%==================================================================================================
%\begin{latexonly}
\tableofcontents
%\end{latexonly}

%\tableofchildlinks


\clearpage
%==================================================================================================
\listoffigures
\listoftables


\clearpage
%==================================================================================================
\section{Introduction}

CO5BOLD\index{CO5BOLD} -- nickname COBOLD --
is the short form of
``COnservative COde for the COmputation of COmpressible COnvection
in a BOx of L Dimensions with l=2,3''.

It is used to model solar and stellar surface convection.
For solar-type stars only a small fraction of the stellar surface layers are included
in the computational domain.
In the case of red supergiants the computational box contains the entire star.

CO5BOLD solves the coupled non-linear equations
of compressible hydro\-dynamics\index{hydrodynamics}
in an external gravity field
together with non-local frequency-dependent radiation transport\index{radiation transport}.
Operator splitting is applied to solve
the equations of hydro\-dynamics (including gravity),
the radiative energy transfer (with a long-characteristics or
a short-characteristics ray scheme),
and possibly additional 3D (turbulent) diffusion
in individual sub steps.
The 3D hydro\-dynamics step is further simplified with directional splitting.
The 1D sub steps are performed with a Roe solver,
accounting for an external gravity field
and an arbitrary equation of state from a table.


The radiation transport is computed with either one of three modules:
\begin{itemize}

\item \verb|MSrad| module\index{MSrad}:
  It uses long characteristics. The lateral boundaries have to be periodic.
  Top and bottom can be closed or open (``solar module'').

\item \verb|LHDrad| module\index{LHDrad}:
  It uses long characteristics and is restricted to an equidistant grid and
  open boundaries at all surfaces (old ``supergiant module'').

\item \verb|SHORTrad| module\index{SHORTrad}:
  It uses short characteristics and is restricted to an equidistant grid and
  open boundaries at all surfaces (new ``supergiant module'').

\end{itemize}

There are preliminary versions of modules for the formation and advection of
dust\index{dust} and the transport of magnetic fields\index{magnetic fields}
available.

CO5BOLD is written in Fortran90\index{Fortran}.
The parallelization is done with OpenMP directives\index{OpenMP}.

\vspace{5mm}

To get a brief overview you might want to look into the
``Quickstart Sections''
``How to Compile CO5BOLD'' (Sect.~\ref{s:quickstart_compile}),
``Introduction to UIO'' (Sect.~\ref{s:quickstart_UIO}),
``How to Make a Proper Parameter File'' (Sect.~\ref{s:quickstart_parameterfile}),
``How to Run CO5BOLD'' (Sect.~\ref{s:quickstart_runCO5BOLD}).


\clearpage
%==================================================================================================
\section{Basic Equations}

The 3D hydro\-dynamics\index{hydrodynamics} equations,
including source terms due to gravity, are
the mass conservation equation
\begin{equation} \label{eq:3dhydrorho}
  \papa{\rho}{t} + \papa{\; \rho \; \V{1}}{x1}
                 + \papa{\; \rho \; \V{2}}{x2}
                 + \papa{\; \rho \; \V{2}}{x3} = 0 \enspace ,
\end{equation}
the momentum equation
\begin{equation} \label{eq:3dhydrov}
  \papa{}{t}
    \left( \!
      \begin{array}{c}
        \rhov{1} \\
        \rhov{2} \\
        \rhov{3}
      \end{array}
    \! \right)
  +
  \papa{}{x1}
    \left( \!
      \begin{array}{l}
        \rhov{1}  \; \V{1} + P \! \\
        \rhov{2}  \; \V{1} \\
        \rhov{3}  \; \V{1}
      \end{array}
    \right)
  +
  \papa{}{x2}
    \left( \!
      \begin{array}{l}
        \rhov{1}  \; \V{2} \\
        \rhov{2}  \; \V{2} + P \! \\
        \rhov{3}  \; \V{2}
      \end{array}
    \right)
  +
  \papa{}{x3}
    \left( \!
      \begin{array}{l}
        \rhov{1}  \; \V{3} \\
        \rhov{2}  \; \V{3} \\
        \rhov{3}  \; \V{3} + P \!
      \end{array}
    \right)
  \! = \!
    \left( \!
      \begin{array}{c}
        \rho \; \g{1} \\
        \rho \; \g{2} \\
        \rho \; \g{3}
      \end{array}
    \! \right)
\end{equation}
and the energy equation
\begin{equation}  \label{eq:3dhydroe}
   \papa{\rhoeik}{t} + \papa{\; (\rhoeik + P) \; \V{1}}{x1}
                     + \papa{\; (\rhoeik + P) \; \V{2}}{x2}
                     + \papa{\; (\rhoeik + P) \; \V{3}}{x3} = \rho \; ( \g{1} \; \V{1} + \g{2} \; \V{2} + \g{3} \; \V{3} ) .
\end{equation}
In addition, there are equations for the 3D tensor viscosity and the non-local radiation transport.


\clearpage
%==================================================================================================
\section{Program Files, Installation, Compilation}\index{compilation|(}

In this section all the files and modules CO5BOLD contains are listed.
The installation procedure is outlined
and compiler switches necessary to compile CO5BOLD and to optimize its performance
are described.


%--------------------------------------------------------------------------------------------------
\subsection{Quickstart: How to Compile CO5BOLD\label{s:quickstart_compile}}\index{compilation}

If you are going to install CO5BOLD on a machine with a ``known''
(to setup script and makefile)
operating system and compiler
(see Sections \ref{s:configure} and \ref{s:optimization})
then the procedure should be fairly easy.
The general compilation procedure is now:

If a directory for the current machine exists (in the tar ball) and the configure script
is there:
%\begin{Verbatim}[commandchars=+\[\]]
%\begin{Verbatim}[commandchars=\\\{\}]
%\begin{verbatim}

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
tar -zxvf for.tar.gz
cd for/hd/rhd/YOUR_MACHINE
./configure
make
\end{alltt}}}
%\end{verbatim}
%\end{Verbatim}

If the directory for the current machine has to be created:

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
tar -zxvf for.tar.gz
cd for/hd/rhd
mkdir YOUR_MACHINE
cd YOUR_MACHINE
ln -s ../conf/configure .
./configure
make
\end{alltt}}}

The compilation process is explained in more detail in Sect.~\ref{s:compile}.
The configure script is described in its header and in Sect.~\ref{s:configure}.
The directory structure is shown in Tab.~\ref{t:alldirs}.
All Fortran files are listed in Tab.~\ref{t:allmodules}.


%--------------------------------------------------------------------------------------------------
\subsection{Compilation Procedure for CO5BOLD\label{s:compile}}
\index{compilation}

The installation procedure has changed significantly since the last release:
now, there is a configure script (see Sect.~\ref{s:configure})
that creates the complete (temporary) makefile which can be used to
compile CO5BOLD and produce
the executable \verb|rhd.exe|.\label{s:rhd.exe}\index{rhd.exe}

Installation procedure:

\begin{enumerate}

\item Choose/create a proper base directory.
(This will usually be \verb|$HOME|.
Then the master directory will typically be \verb|$HOME/for| --
this is the default created by the tar file.
Some prefer to rename it to \verb|$HOME/HYDRO|.)

\item Put all source files and the configure script there.
This will be done typically by expanding the gzipped tar file \verb|for.tar.gz|
e.g.\ with

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  tar -zxvf for.tar.gz
\end{alltt}}}

(or by copying all files from an existing installation).
On a restricted Unix you might be forced to use

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  gunzip for.tar.gz
  tar -xvf for.tar
\end{alltt}}}

instead.
Unpacking the tar file creates a sub directory \verb|for| in the local directory
(and possible overwrites existing files!).
You get sub sub directories as described in Sect.~\ref{s:directorystructure}
and files as listed in Tab.~\ref{t:allmodules}.
See the Readme file '\verb|for/README|\index{README}'.

\item Change with 
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  cd for/hd/rhd
\end{alltt}}}
into the main directory.

\item Look at the existing sub directories, e.g.\ with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  ls -og | grep "^d"
\end{alltt}}}
to see if you find one that fits your machine. The directory
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  for/hd/rhd/conf
\end{alltt}}}
should not be used. It contains only the configure script. But any other 
directory will do.
If you don't like any of the existing directories create your own e.g. with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  mkdir YOUR_MACHINE
\end{alltt}}}
Change into this directory with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  cd YOUR_MACHINE
\end{alltt}}}

\item Check if there is a configure script or a link to it with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  ls -og configure
\end{alltt}}}
which should give something like
{\color{DEFcolor}{\color{TXTcolor}\begin{alltt}
  lrwxrwxrwx  1  17 2002-12-04 17:39 configure -> ../conf/configure
\end{alltt}}}
If it is not there, create the link with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  ln -s ../conf/configure .
\end{alltt}}}

\item Start the configure script to create the (first version of the) Makefile
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  ./configure
\end{alltt}}}
This gives you a screen output like

{\color{DEFcolor}{\color{TXTcolor}\begin{alltt}
Configuration script for CO5BOLD Makefile
=========================================

No parallelization requested, assume default:  F90_PARALLEL=scalar
No debugging requested, assume default:        F90_DEBUG=0
No LHDrad   module requested, assume default:  F90_LHDRAD=0
No MSrad    module requested, assume default:  F90_MSRAD=0
No SHORTrad module requested, assume default:  F90_SHORTRAD=1
No dust     module requested, assume default:  F90_DUST=0
No MHD      module requested, assume default:  F90_MHD=0
No explicit machine requested, assume default: F90_MACHINE=local

List of control environment variables:
F90_COMPILER =
F90_PREFLAGS =
F90_POSTFLAGS=
F90_PARALLEL = scalar
F90_DEBUG    = 0
F90_LHDRAD   = 0
F90_MSRAD    = 0
F90_SHORTRAD = 1
F90_DUST     = 0
F90_MHD      = 0
F90_MACHINE  = local
 -> MACHINE  = i686
F90_BASEPATH = /home/bf/for

Linux system with i686 architecture
  PGI compiler
  version=3.3-2

pgf90 -byteswapio -fast -Mvect=sse -Mcache_align -Minfo=inline 

Write compiler name and flags into file compiler_flags.info

Makefile already exists. It is appended to Makefile_old.
New Makefile written..........................................
\end{alltt}}}

A new '\verb|Makefile|' is produced. An existing one is appended to '\verb|Makefile_old|'.
Additionally, the file '\verb|compiler_flags.info|' is written which contains the
compiler call in Fortran format.

\item Check the output of the configure script and the header of the new Makefile.
You get an overview over the relevant environment variables that control the
configure script (see Sect.~\ref{s:configure}) with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  env | grep F90_
\end{alltt}}}
Obs: at the beginning there might be none.

\item Look into the header (and if necessary the rest) of the configure script
or into Sect.~\ref{s:configure} to
find out how to change the environment variables to control the script
properly. For instance, if you want to enable debugging options, type:
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  export F90_DEBUG=1
\end{alltt}}}
Restart the configure script after every change in the control variables!

\item Start the compilation with
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
  make
\end{alltt}}}
to produce the executable \verb|rhd.exe|.\index{rhd.exe}

\end{enumerate}

A simple sample installation may look like the following
(the sub directory '\verb|for|' is put into the home directory).

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
# --- Choose base directory ---
cd ${HOME}

# --- Put the tar file there ---
# ...

# --- Expand the tar file ---
tar -zxvf for.tar.gz

# --- Go into (default) master directory ---
cd for/hd/rhd/YOUR_MACHINE

# --- Activate OpenMP und MSrad radiation transport ---
export F90_PARALLEL=openmp
export F90_MSRAD=1

# --- Start the configure script ---
./configure

# --- Compile ---
make

echo 'Voila!'
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsection{Directory Structure\label{s:directorystructure}}

The files necessary to compile CO5BOLD are distributed over a few directories.
A typical setup would be to put everything into the main directory \verb|for|.
Then the source files would be located as in Tab.~\ref{t:alldirs}.

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|lll|} \hline
Paths                            & Abb. & Description \\ \hline
\verb|${HOME}/for/con/f90/|      & CON  & constants and units \\ 
\verb|${HOME}/for/dust/f90/|     & DUST & source terms due to dust or molecules \\ 
\verb|${HOME}/for/eos/f90/|      & EOS  & equation of state \\ 
\verb|${HOME}/for/hd/mhd/|       & MHD  & MHD routines \\ 
\verb|${HOME}/for/hd/rhd/|       & RHD  & main rhd routines (hydro, Bernd's radiation transport) \\ 
\verb|${HOME}/for/hd/rhdb/|      & RHDB & basic rhd routines \\ 
\verb|${HOME}/for/mat/str/|      & STR  & string handling \\ 
\verb|${HOME}/for/opa/opta/|     & OPTA & opacities \\ 
\verb|${HOME}/for/rad/hdrad/|    & RAD  & Matthias' radiation transport \\ 
\verb|${HOME}/for/uio/f90/|      & UIO  & I/O routines \\ 
\verb|${HOME}/for/time/f90/|     & TIME & timing routines \\ \hline
  \end{tabular} 
  \caption[List of source directories]{List of source directories
     with path and file name, abbreviation, and a short description.
     }\label{t:alldirs}
 \end{center}
\end{table}

The executables (and makefiles, object files, module information files) are usually
located in subdirectories of the source code directories.
These subdirectories typically have the name of the machine, architecture, or
operating system the executable is compiled for.

The former directory organization can be found in Tab.~\ref{t:alldirs_old}
and Fig.~\ref{f:alldirs_old}.

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|lll|} \hline
Paths                            & Abb. & Description \\ \hline
\verb|${HOME}/for/mat/str/|      & STR  & string handling \\
\verb|${HOME}/for/uio/f90/|      & UIO  & I/O routines \\
\verb|${HOME}/for/eos/f90/|      & EOS  & equation of state \\
\verb|${HOME}/for/rad/hdrad/|    & RAD  & opacities, Matthias' radiation transport \\
\verb|${HOME}/for/hd/rhd/|       & RHD  & main rhd routines \\ \hline
  \end{tabular} 
  \caption[List of old source directories]{For historical reasons:
     list of old source directories
     with path and file name, abbreviation, and a short description.
     }\label{t:alldirs_old}
 \end{center}
\end{table}

\begin{latexonly}
\begin{figure}[hbtp]
\centering
\includegraphics[width=16.2cm]{co5bold/COBOLD_directories}
  \caption[Old directory scheme]{Old directory scheme}
  \label{f:alldirs_old}
\end{figure}
\end{latexonly}

\begin{htmlonly}
\begin{figure}[hbtp]
\htmlimage{external,thumbnail=1.0,no_transparent}
\centering
\includegraphics[width=16.2cm]{co5bold/COBOLD_directories.eps}
  \caption[Old directory scheme]{Old directory scheme
, \htmladdnormallink{Postscript version}{COBOLD_directories.eps}
}
  \label{f:alldirs_old}
\end{figure}
\end{htmlonly}


%--------------------------------------------------------------------------------------------------
\subsection{Old Setup File for Paths\label{s:oldsetupfile}}

For the previous version of CO5BOLD all paths were stored in environment
variables\index{environment variables} and could be set with the scripts
\begin{verbatim}
setarcdeppaths.sh
\end{verbatim}
or
\begin{verbatim}
setarcdeppaths.csh .
\end{verbatim}
These variables are now {\em ignored\/} by the configure script that produces the
Makefile to generate the CO5BOLD executable \verb|rhd.exe|.

However, they are still used e.g.\ by the makefile that produces the executables that
are called by the UIO scripts.
The environment variables\index{environment variables} for the UIO routines can be e.g.\
\begin{verbatim}
UIOSRCPATH=/home/user/for/uio/f90
UIOEXEPATH=/home/user/for/uio/f90/sun .
\end{verbatim}

A script to set all necessary variables and paths can be (here for the Bourne shell)

{\color{DEFcolor}{\small\color{SHcolor}\begin{alltt}
#!/bin/sh
#
# --- Disk where all Fortran programs are located ---
FORTRANDISK=${HOME}/for ; export FORTRANDISK
#
if [ `uname -s` = "craSH" ]; then
  # --- Kiel: craSHi ---
  #
  UIOMAC=uio_mac_crayxmp_module ; export UIOMAC
  RHDMAC=rhd_mac_cray_module ; export RHDMAC
elif [ `uname -s` = "craSH" ]; then
  # --- Kiel: craSH ---
  #
  UIOMAC=uio_mac_crayts_module ; export UIOMAC
  RHDMAC=rhd_mac_cray_module ; export RHDMAC
elif [ `uname -m` = "SR8000" ]; then
  # --- Potsdam: Hitachi ---
  #
  UIOMAC=uio_mac_hitachi_module ; export UIOMAC
  RHDMAC=rhd_mac_hitachi_module ; export RHDMAC
else
  # --- Default: Suns MAC files ---
  #
  UIOMAC=uio_mac_sun_module; export UIOMAC
  RHDMAC=rhd_mac_sun_module; export RHDMAC
fi
#
# --- Architecture dependent sub directory names for object file and executables ---
if [ `uname -s` = "craSH" ]; then
  MAC=crash
elif [ `uname -s` = "craSHi" ]; then
  MAC=crashi
elif [ `uname -s` = "SunOS" ]; then
  MAC=sun
elif [ `uname -s` = "HP-UX" ]; then
  if [ `uname -m` = "ia64" ]; then
    MAC=hpia64
  else
    MAC=hp
  fi
elif [ `uname -s` = "Linux" ]; then
  MAC=linux
elif [ `uname -n` = "vx1" ]; then
  MAC=vx1
else
  MAC=sgi
fi
#
# --- Individual libraries ---
# --- Timing ---
TIMEPATH=${FORTRANDISK}/time/f90 ; export TIMEPATH
TIMESRCPATH=${TIMEPATH} ; export TIMESRCPATH
#
# --- Constants & units ---
CONPATH=${FORTRANDISK}/con/f90 ; export CONPATH
CONSRCPATH=${CONPATH} ; export CONSRCPATH
#
# --- uio ---
UIOPATH=${FORTRANDISK}/uio ; export UIOPATH
UIOSRCPATH=${UIOPATH}/f90 ; export UIOSRCPATH
#
# --- String handling ---
STRPATH=${FORTRANDISK}/mat/str ; export STRPATH
STRSRCPATH=${STRPATH} ; export STRSRCPATH
#
# --- Math ---
MATPATH=${FORTRANDISK}/mat ; export MATPATH
MATSRCPATH=${MATPATH}/f90 ; export MATSRCPATH
#
# --- gas ---
GASPATH=${FORTRANDISK}/eos/gas ; export GASPATH
GASSRCPATH=${GASPATH} ; export GASSRCPATH
#
# --- EOS ---
EOSPATH=${FORTRANDISK}/eos ; export EOSPATH
EOSSRCPATH=${EOSPATH}/f90 ; export EOSSRCPATH
#
# --- Opacity ---
OPTAPATH=${FORTRANDISK}/opa/opta ; export OPTAPATH
OPTASRCPATH=${OPTAPATH} ; export OPTASRCPATH
#
# --- hydrostatic ---
HSTPATH=${FORTRANDISK}/hd/qf15 ; export HSTPATH
HSTSRCPATH=${HSTPATH} ; export HSTSRCPATH
#
# --- rad ---
RADPATH=${FORTRANDISK}/rad/hdrad ; export RADPATH
RADSRCPATH=${RADPATH} ; export RADSRCPATH
#
# --- RHD ---
RHDPATH=${FORTRANDISK}/hd/rhd ; export RHDPATH
RHDSRCPATH=${RHDPATH} ; export RHDSRCPATH
#
# --- RHDB ---
RHDBPATH=${FORTRANDISK}/hd/rhdb ; export RHDBPATH
RHDBSRCPATH=${RHDBPATH} ; export RHDBSRCPATH
#
# --- HDW ---
HDWPATH=${FORTRANDISK}/hd/hdw ; export HDWPATH
HDWSRCPATH=${HDWPATH} ; export HDWSRCPATH
#
# --- DUST ---
DUSTPATH=${FORTRANDISK}/hd/dust ; export DUSTPATH
DUSTSRCPATH=${DUSTPATH} ; export DUSTSRCPATH
#
# --- MHD ---
MHDPATH=${FORTRANDISK}/hd/mhd ; export MHDPATH
MHDSRCPATH=${MHDPATH} ; export MHDSRCPATH
#
# --- mean ---
MEANPATH=${FORTRANDISK}/hd/mean ; export MEANPATH
MEANSRCPATH=${MEANPATH} ; export MEANSRCPATH
#
# --- Architecture dependent directories for object file and executables ---
TIMEEXEPATH=${TIMEPATH}/${MAC}   ; export TIMEEXEPATH
CONEXEPATH=${CONPATH}/${MAC}     ; export CONEXEPATH
UIOEXEPATH=${UIOSRCPATH}/${MAC}  ; export UIOEXEPATH
STREXEPATH=${STRPATH}/${MAC}     ; export STREXEPATH
MATEXEPATH=${MATSRCPATH}/${MAC}  ; export MATEXEPATH
GASEXEPATH=${GASPATH}/${MAC}     ; export GASEXEPATH
EOSEXEPATH=${EOSSRCPATH}/${MAC}  ; export EOSEXEPATH
OPTAEXEPATH=${OPTAPATH}/${MAC}   ; export OPTAEXEPATH
HSTEXEPATH=${HSTPATH}/${MAC}     ; export HSTEXEPATH
RADEXEPATH=${RADPATH}/${MAC}     ; export RADEXEPATH
RHDEXEPATH=${RHDPATH}/${MAC}     ; export RHDEXEPATH
RHDBEXEPATH=${RHDBPATH}/${MAC}   ; export RHDBEXEPATH
HDWEXEPATH=${HDWPATH}/${MAC}     ; export HDWEXEPATH
DUSTEXEPATH=${DUSTPATH}/${MAC}   ; export DUSTEXEPATH
MHDEXEPATH=${MHDPATH}/${MAC}     ; export MHDEXEPATH
MEANEXEPATH=${MEANPATH}/${MAC}   ; export MEANEXEPATH
\end{alltt}}}

\noindent This script can be executed with

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
. $HOME/bin/setarcdeppaths.sh
\end{alltt}}}

\noindent This line can be put e.g.\ into the \verb|.bashrc| file.

\noindent Some lines can be edited to account for individual choices and the
target machine.
With

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
FORTRANDISK=$HOME/for ; export FORTRANDISK
\end{alltt}}}

\noindent the master directory is specified.
With

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
UIOMAC=uio_mac_sun_module; export UIOMAC
RHDMAC=rhd_mac_sun_module; export RHDMAC
\end{alltt}}}

\noindent you set some machine dependent modules. The \verb|sun| modules
work for most machines (e.g.\ for Linux PCs).
With

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
MAC=linux
\end{alltt}}}

\noindent you specify the name of the subdirectories with the makefiles\index{makefile}.
The other lines only have to be edited if you want to organize
the directories in a completely different way. In this case you have to adapt
the configure script, too.


%--------------------------------------------------------------------------------------------------
\subsection{Fortran Files\label{s:fortran_files}}\index{Fortran}

Table~\ref{t:allmodules} shows a list of all source files necessary to compile CO5BOLD.
Table~\ref{t:allmodulesold} shows the former list.


\begin{table}[htbp]
 \begin{center}
  \begin{tabular}{|lll|} \hline
File and path                             & Abb. & Description \\ \hline
\verb|hd/rhd/rhd.F90|                     & RHD  & main program \\ \hline

\verb|hd/rhd/rhd_hyd_module.F90|          & RHD  & hydrodynamics routines\index{hydrodynamics routines} \\
\verb|hd/rhd/rhd_lhdrad_module.F90|       & RHD  & radiative transfer routines,\index{LHDrad} \\
                                          &      & long characteristics, supergiant case \\
\verb|hd/rhd/rhd_shortrad_module.F90|     & RHD  & radiative transfer routines,\index{SHORTrad} \\
                                          &      & short characteristics, supergiant case \\
\verb|hd/rhd/rhd_shortrad_dtauop01.f90|   & RHD  & short characteristics tau-coupling \\
\verb|hd/rhd/rhd_shortrad_dtauop02.f90|   & RHD  & short characteristics tau-coupling \\
\verb|hd/rhd/rhd_shortrad_operator00.f90| & RHD  & short characteristics operator \\
%\verb|hd/rhd/rhd_shortrad_operator01.f90| & RHD  & short characteristics operator \\
%\verb|hd/rhd/rhd_shortrad_operator02.f90| & RHD  & short characteristics operator \\
%\verb|hd/rhd/rhd_shortrad_operator03.f90| & RHD  & short characteristics operator \\
%\verb|hd/rhd/rhd_shortrad_operator04.f90| & RHD  & short characteristics operator \\
%\verb|hd/rhd/rhd_shortrad_operator05.f90| & RHD  & short characteristics operator \\
%\verb|hd/rhd/rhd_shortrad_operator06.f90| & RHD  & short characteristics operator \\
                    \ldots                &      & \\
\verb|hd/rhd/rhd_shortrad_operator08.f90| & RHD  & short characteristics operator \\
\verb|hd/rhd/rhd_vis_module.F90|          & RHD  & tensor viscosity routines\index{tensor viscosity routine} \\
\verb|rad/hdrad/rhd_rad_module.f90|       & RAD  & interface for Matthias' radiation routine\negsp \\
\verb|rad/hdrad/MSrad3D.F90|              & RAD  & Matthias' radiation transport routines\index{MSrad}, \\
                                          &      & long characteristics, periodic sides \\
\verb|hd/dust/rhd_dust_module.F90|        & DUST & dust/molecule formation \\
\verb|hd/dust/dust_k3mon_module.f|        & DUST & 1 or 2 component dust model \\
\verb|hd/mhd/rhd_mhd_module.F90|          & MHD  & magnet fields (first version) \\ \hline

\verb|eos/f90/gasinter_routines.f90|      & EOS  & equation of state \\
\verb|opa/opta/cubit_module.f|            & OPTA & cubic interpolation \\
\verb|opa/opta/opta_par_module.f90|       & OPTA & parameters for opacity routines \\
\verb|opa/opta/opta_routines.f|           & OPTA & opacity \\
\verb|hd/rhdb/rhd_action_module.f90|      & RHDB & routines for control parameter passing \\
\verb|hd/rhdb/rhd_box_module.f90|         & RHDB & box handling routines \\
\verb|hd/rhdb/rhd_dat_module.f90|         & RHDB & handling of additional data (averages) \\
\verb|hd/rhdb/rhd_gl_module.f90|          & RHDB & global parameters \\
\verb|hd/rhdb/rhd_io_module.f90|          & RHDB & input/output routines \\
\verb|hd/rhdb/rhd_mac_cray_module.f90|    & RHDB & machine dependent routines (CRAY) \\
\verb|hd/rhdb/rhd_mac_default_module.f90| & RHDB & machine dependent routines (default) \\
\verb|hd/rhdb/rhd_mac_hitachi_module.f90| & RHDB & machine dependent routines (Hitachi) \\
\verb|hd/rhdb/rhd_mac_sun_module.f90|     & RHDB & mac-dependent routines (Sun, others) \\
\verb|hd/rhdb/rhd_mean_module.f90|        & RHDB & averaging routines \\
\verb|hd/rhdb/rhd_prop_module.f90|        & RHDB & box properties \\
\verb|hd/rhdb/rhd_sub_module.f90|         & RHDB & additional routines \\ \hline

\verb|con/f90/const_module.f90|           & CON  & physical and mathematical constants \\
\verb|mat/str/str_module.f90|             & STR  & string handling \\
\verb|time/f90/timing_module.f90|         & TIME  & timing routines \\
\verb|uio/f90/uio_base_module.f90|        & UIO  & I/O routines \\
\verb|uio/f90/uio_bulk_module.f90|        & UIO  & I/O routines \\
\verb|uio/f90/uio_filedef_module.f90|     & UIO  & I/O routines \\
\verb|uio/f90/uio_mac_crayts_module.f90|  & UIO  & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_crayxmp_module.f90| & UIO  & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_decalpha_module.f90|\negsp\negsp
                                          & UIO & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_hitachi_module.f90| & UIO  & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_ieee_module.f90|    & UIO  & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_intel_module.f90|   & UIO  & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_module.f90|         & UIO  & I/O routines, m.-d., minimal version \\
\verb|uio/f90/uio_mac_nec_module.f90|     & UIO  & I/O routines, machine dependent part \\
\verb|uio/f90/uio_mac_sun_module.f90|     & UIO  & I/O, m.-d., works in most cases \\ \hline
  \end{tabular} 
  \caption[List of all modules]{List of all modules:
the table shows the file name with part of its path,
the shortcut for the directory,
and its description.
     }\label{t:allmodules}
 \end{center}
\end{table}


\begin{table}[htbp]
 \begin{center}
  \begin{tabular}{|lll|} \hline
File and path                             & Abb. & Description \\ \hline
\verb|mat/str/str_module.f90|             & STR  & string handling \\ \hline
\verb|uio/f90/uio_base_module.f90|        & UIO  & I/O routines \\
\verb|uio/f90/uio_bulk_module.f90|        & UIO  & I/O routines \\
\verb|uio/f90/uio_filedef_module.f90|     & UIO  & I/O routines \\
\verb|uio/f90/uio_mac_sun_module.f90|     & UIO  & I/O routines, machine dependent part \\ \hline
\verb|eos/f90/gasinter_routines.f90|      & EOS  & equation of state \\ \hline
\verb|rad/hdrad/cubit_module.f|           & RAD  & cubic interpolation \\
\verb|rad/hdrad/opta_par_module.f90|      & RAD  & parameters for opacity routines \\
\verb|rad/hdrad/opta_routines.f|          & RAD  & opacity \\ \hline
\verb|rad/hdrad/MSrad3D.F90|              & RAD  & Matthias' radiation transport routines\index{MSrad}, \\
                                          &      & long characteristics, periodic sides \\ \hline
\verb|hd/rhd/timing_module.f90|           & RHD  & timing routines \\ \hline
\verb|hd/rhd/rhd_const_module.f90|        & RHD  & physical and mathematical constants \\
\verb|hd/rhd/rhd_gl_module.f90|           & RHD  & global parameters \\
\verb|hd/rhd/rhd_action_module.f90|       & RHD  & routines for control parameter passing \\
\verb|hd/rhd/rhd_box_module.f90|          & RHD  & box handling routines \\
\verb|hd/rhd/rhd_dat_module.f90|          & RHD  & handling of additional data (averages) \\
\verb|hd/rhd/rhd_mean_module.f90|         & RHD  & averaging routines \\
\verb|hd/rhd/rhd_io_module.f90|           & RHD  & input/output routines \\
\verb|hd/rhd/rhd_mac_cray_module.f90|     & RHD  & machine dependent routines (CRAY) \\
\verb|hd/rhd/rhd_mac_default_module.f90|  & RHD  & machine dependent routines (default) \\
\verb|hd/rhd/rhd_mac_sun_module.f90|      & RHD  & machine dependent routines (Sun) \\
\verb|hd/rhd/rhd_sub_module.f90|          & RHD  & additional routines \\
\verb|hd/rhd/rhd_hyd_module.F90|          & RHD  & hydrodynamics routines\index{hydrodynamics routines} \\
\verb|hd/rhd/rhd_vis_module.F90|          & RHD  & tensor viscosity routines\index{tensor viscosity routine} \\
\verb|hd/rhd/rhd_rad_module.f90|          & RHD  & interface for Matthias' radiation routine \\
\verb|hd/rhd/rhd_lhdrad_module.F90|       & RHD  & radiative transfer routines,\index{LHDrad} \\
                                          &      & long characteristics, supergiant case \\
\verb|hd/rhd/rhd_shortrad_module.F90|     & RHD  & radiative transfer routines,\index{SHORTrad} \\
                                          &      & short characteristics, supergiant case \\
\verb|hd/rhd/rhd.F90|                     & RHD  & main program \\ \hline
  \end{tabular} 
  \caption[List of all old modules]{For historical reasons: list of all old modules:
the table shows the file name with part of its path,
the shortcut for the directory,
and its description.
     }\label{t:allmodulesold}
 \end{center}
\end{table}


%--------------------------------------------------------------------------------------------------
\subsection{Configure Script\label{s:configure}}
\index{configure script|(}

The configure script produces a Makefile\index{makefile!configure script}.

It is controlled by environment variables (see below).
It tries to use reasonable default values if they are not set (properly).
In the script the machine type is determined with `uname -m`.
According to the control variables and the machine architecture
the compiler name and its compiler flags are composed.
These are written into the header of a Makefile which is produced in the end.
An existing Makefile is appended to
\begin{verbatim}
  Makefile_old.
\end{verbatim}
Additionally the compilation command is written into the file
\begin{verbatim}
  'compiler_flags.info'
\end{verbatim}
in a form ready to be included in a Fortran program.

The environment variables that control the script are
\index{configure script!control variables}

\begin{itemize}

\item \verb|F90_COMPILER|:
  \index{configure script!F90COMPILER@\verb/F90_COMPILER/}
  \label{s:F90_COMPILER} \\
  Fortran compiler:
  \begin{itemize}
    \item \verb|''|: a machine dependent default is chosen individually for each architecture
    \item \verb|f90|: general default
  \end{itemize}

\item \verb|F90_PREFLAGS|:
  \index{configure script!F90PREFLAGS@\verb/F90_PREFLAGS/}
  \label{s:F90_PREFLAGS} \\
  Compiler flags to be put at the beginning of the list.
  Usually, the list of compiler flags produced by the configure script should be pretty complete.
  But you might want to add special switches like '-Bstatic' to enforce static linking of
  libraries.
  \begin{itemize}
    \item \verb|''|: No extra flags
  \end{itemize}

\item \verb|F90_POSTFLAGS|:
  \index{configure script!F90POSTFLAGS@\verb/F90_POSTFLAGS/}
  \label{s:F90_POSTFLAGS} \\
  Compiler flags to be put at the end of the list.
  Usually, the list of compiler flags produced by the configure script should be pretty complete.
  However, you might want to overwrite some settings. This can be done by setting this variable
  to a none-empty value because typically a compiler should interpret the flags from left to right.
  \begin{itemize}
    \item \verb|''|: No extra flags
  \end{itemize}

\item \verb|F90_PARALLEL|:
  \index{configure script!F90PARALLEL@\verb/F90_PARALLEL/}
  \label{s:F90_PARALLEL} \\
  Parallelization scheme:
  \begin{itemize}
    \item \verb|scalar|: no parallelization (default)
    \item \verb|openmp|: OpenMP\index{OpenMP!activation in configure script} (appropriate for CO5BOLD)
    \item \verb|auto|:   auto-parallelization (not implemented for all machines)
  \end{itemize}

\item \verb|F90_DEBUG|:
  \index{configure script!F90DEBUG@\verb/F90_DEBUG/}
  \label{s:F90_DEBUG} \\
  Debugging level:
  \begin{itemize}
    \item \verb|0|: No extra debugging information produced,
                    full optimization is chosen (default)
    \item \verb|1|: standard debugging mode (typically switch '-g' instead of '-fast')
    \item \verb|2|: other debbuging (or array checking) modes possible if
                    implemented for the requested machine
  \end{itemize}


\item \verb|F90_LHDRAD|:
  \index{configure script!F90LHDRAD@\verb/F90_LHDRAD/}
  \label{s:F90_LHDRAD} \\
  LHDrad radiation transport:
  \begin{itemize}
    \item \verb|0|: do not activate (compile and link) this module (default)
    \item \verb|1|: activate this radiation transport module
  \end{itemize}

\item \verb|F90_MSRAD|:
  \index{configure script!F90MSRAD@\verb/F90_MSRAD/}
  \label{s:F90_MSRAD} \\
  MSrad radiation transport:
  \begin{itemize}
    \item \verb|0|: do not activate (compile and link) this module (default)
    \item \verb|1|: activate this radiation transport module
  \end{itemize}

\item \verb|F90_SHORTRAD|:
  \index{configure script!F90SHORTRAD@\verb/F90_SHORTRAD/}
  \label{s:F90_SHORTRAD} \\
  SHORTrad radiation transport:
  \begin{itemize}
    \item \verb|0|: do not activate (compile and link) this module (default)
    \item \verb|1|: activate this radiation transport module
  \end{itemize}

\item \verb|F90_DUST|:
  \index{configure script!F90DUST@\verb/F90_DUST/}
  \label{s:F90_DUST} \\
  DUST module:
  \begin{itemize}
    \item \verb|0|: do not activate (compile and link) this module (default)
    \item \verb|1|: activate this radiation transport module
  \end{itemize}
  If this variable is set to 1 the compiler is called with \verb|-Drhd_box_quc01=1|,
  see Sect.~\ref{s:rhd_box_quc01}.

\item \verb|F90_MHD|:
  \index{configure script!F90MHD@\verb/F90_MHD/}
  \label{s:F90_MHD} \\
  MHD module:
  \begin{itemize}
    \item \verb|0|: do not activate (compile and link) this module (default)
    \item \verb|1|: activate this radiation transport module
  \end{itemize}

\item \verb|F90_MACHINE|:
  \index{configure script!F90MACHINE@\verb/F90_MACHINE/}
  \label{s:F90_MACHINE} \\
  Explicit machine specification. This isusually not necessary, use 'local' or '' instead.
  \begin{itemize}
    \item \verb|''|: local machine
    \item \verb|sun4u|: Sun
    \item \ldots: See the header of the configure script for an up to date list
    \item \verb|local|: local machine (default)
    \item \verb|dummy|: Do not use any machine dpedendent flags but use module selections
    \item \verb|empty|: Compiler flags are composed from \verb|F90_PREFLAGS| and \verb|F90_POSTFLAGS| only
  \end{itemize}

\item \verb|F90_BASEPATH|:
  \index{configure script!F90BASEPATH@\verb/F90_BASEPATH/}
  \label{s:F90_BASEPATH} \\
  Path for CO5BOLD base directory.
  \begin{itemize}
    \item \verb|''|: The configure script tries to determine the base directory name
                     automatically (default). This should work if the local directory is
                     located somewhere below \verb|.../hd/rhd/|
    \item otherwise: This string is used as base directory name (e.g.\ \verb|/home/user/for|)
  \end{itemize}

\end{itemize}

Some examples can be found in Sect.~\ref{s:compile}.

\index{configure script|)}


%--------------------------------------------------------------------------------------------------
\subsection{Compiler Macros\label{s:compiler_macros}}\index{compiler macro|(}

Some of the modules of the CO5BOLD code (with suffix ``.F90'') employ compiler macros
to switch between code versions during compile time.
Typically you define at least one of the three switches \verb|rhd_r01|, \verb|rhd_r02|,
or \verb|rhd_r03| to choose a radiation transport module.
The others have reasonable default values.
To find the combination with the optimal performance, you should look into Sect.~\ref{s:optimization}

The macros are sorted into different categories:\index{compiler macro!category}

Some {\em activate a certain feature\/} (like a radiation transport module or
the dust module). They have to be selected by the user (typically via
environment variables\index{environment variables} and the configure
script\index{configure script}, see Sect.~\ref{s:configure}) each time
the code is compiled for a certain purpose.

Other macros are meant to {\em improve the performance\/} by offering the
choice between e.g.\ different loop structures or case distinctions. These
macros are set by the configure script to the best knowledge of the author(s).
Ideally, they should be checked and modified if necessary each time CO5BOLD is
compiled on a new machine. It should be save to modify these settings: the
results between runs with different settings should only differ slightly due
to round-off errors.

Some macros {\em select between different numerical approximations\/}. A change here
should be visible in a (more or less drastic) change of the results of a simulation.
Usually, the default values should be accepted. Other settings typically only exist
to allow the comparison with older versions of CO5BOLD or because there are new
developments going on which have not yet managed to become the default.

A couple of macros only activate timing measurements and result in {\em additional output\/}.
Some of them are not thread-save und should only be activated for runs on one thread
(as done by the configure script). It is always save to switch any of them off
(by removing or undefining them).

The macros in the category {\em test\/} mark parts of code under development.
The default values should only be changed with great care (typically by the author of
that code segment). The configure script does not touch these settings.

\noindent General:

\begin{itemize}

%  \label{s:}
%\item \verb||: in \verb|rhd__module.F90|,
%  \index{compiler macro!@\verb//}
%  (``''). \\
%  Category: \\
%  Values:
%  \begin{itemize}
%  \item \verb||: (default)
%  \item \verb||:
%  \end{itemize}

  \label{s:timing_c_factor}
\item \verb|timing_c_factor|: \\
  in \verb|timing_module.F90|,
  \index{compiler macro!timingcfactor@\verb/timing_c_factor/}
  (``timing count factor''). \\
  Category: account for property of machine. \\
  To produce the timing statistics\index{timing statistics} printed at the end of a
  simulation run the standard Fortran routine \verb|SYSTEM_CLOCK| is used. The macro
  \verb|timing_c_factor| specifies by how much the count rate of this routine is reduced
  when storing its count value. This does not prevent all overflows but can make the
  output much more useful.
  Values:
  \begin{itemize}
  \item \verb|1|: (default) count rate of \verb|SYSTEM_CLOCK| is used directly.
  \item otherwise: e.g.\ 1000, count rate of \verb|SYSTEM_CLOCK| is reduced by this factor.
  \end{itemize}
  By a proper choice of this factor the timing measurements of individual routines can
  be made meaningful: the reduction of the count rate prevents overflows due to the
  addition of several measurements.
  An overflow during an individual measurement can not be prevented. 
  Therefore, the count rate for the entire program still tends to produce overflows.

  \label{s:gasinter_l01}
\item \verb|gasinter_l01|: \\
  in \verb|gasinter_routines.F90|,
  \index{compiler macro!gasinterl01@\verb/gasinter_l01/}
  (``gas interpolation l01''). \\
  Category: performance enhancement. \\
  This switch determines how temporary arrays are handled to improve performance
  Values:
  \begin{itemize}
    \item \verb|0|: (default) Temporary coefficient arrays are actually copied.
    \item \verb|1|: Temporary coefficient arrays just get a pointer link into the big arrays.
  \end{itemize}

  \label{s:rhd_box_grav01}
\item \verb|rhd_box_grav01|: \\
  in \verb|rhd_box_module.F90|,
  \index{compiler macro!rhdboxgrav01@\verb/rhd_box_grav01/}
  (``rhd box gravitation 01''). \\
  Category: feature activation. \\
  Switch to activate the array for the gravitational potential in the box
  structure.
  If the switch is set to 1, a 3D array for the potential is created, copied,
  removed, ... There is no module to compute the gravitational potential, yet. Therefore
  the entire thing has no practical value, yet.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) no handling of array.
  \item \verb|1|: array handling activated.
  \end{itemize}

\item \verb|rhd_box_quc01|: \\
  in \verb|rhd_box_module.F90| and \verb|rhd.F90|,
  \index{compiler macro!rhdboxquc01@\verb/rhd_box_quc01/}
  \label{s:rhd_box_quc01}
  (``rhd box quantity centered 01''). \\
  Category: feature activation. \\
  Now, CO5BOLD is able to handle a number of additional quantities (e.g.\ density arrays)
  in addition to the basic hydrodynamics quantities ($\rho$, $\ei$, ...) if this
  compiler switch is activated. These additional quantities can be e.g.\ densities of
  dust\index{dust} distribution moments or densities of molecules.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) no handling of additional quantities (density arrays).
  \item \verb|1|: handling of additional density arrays is activated.
  \end{itemize}
  To actually include dust formation in a simulation, it is necessary to
  \begin{enumerate}
  \item set the switch \verb|-Drhd_box_quc01=1| during compilation (this is done by the
        configure script if the environment variable \verb|F90_DUST| is set to 1,
        see the description of the variable in Sect.~\ref{s:F90_DUST}),
  \item put arrays specifying the initial conditions of the additional density into
        the start model (as \verb|real quc001|, \verb|real quc002|, ...),
  \item select a proper model describing dust (or molecule) formation in the parameter
        file (with \verb|character dustscheme|).
  \end{enumerate}

\item \verb|rhd_box_bmag01|: \\
  in \verb|rhd_box_module.F90| and \verb|rhd.F90|,
  \index{compiler macro!rhdboxbmag01@\verb/rhd_box_bmag01/}
  \label{s:rhd_box_bmag01}
  (``rhd box b magnetic 01''). \\
  Category: feature activation. \\
  CO5BOLD can handle magnetic field\index{magnetic fields} arrays if this compiler switch is set.
  Values:
  \begin{itemize}
  \item \verb||: (default) no handling of magnetic field arrays.
  \item \verb||: handling of magnetic field arrays is activated.
  \end{itemize}
  To actually account for magnetic fiels in a simulation, it is necessary to
  \begin{enumerate}
  \item set the switch \verb|-Drhd_box_bmag01=1| during compilation (this is done by the
        configure script if the environment variable \verb|F90_MHD| is set to 1,
        see Sect.~\ref{s:configure}),
  \item put arrays specifying the initial conditions of the
        boundary centered magnetic field arrays into
        the start model (as \verb|real bb1|, \verb|real bb2|, \verb|real bb3|),
  \item select an hydrodynamics scheme that is able to handle magnetic fields in the parameter
        file (with \verb|character hdscheme|).
  \end{enumerate}

\end{itemize}


\noindent Hydrodynamics (Roe solver):

\begin{itemize}

  \label{s:sw:rhd_roe1d_slope_l01}
\item \verb|rhd_roe1d_slope_l01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdroe1dslopel01@\verb/rhd_roe1d_slope_l01/}
  (``rhd roe 1 dimension slope loop 01''). \\
  Category: feature activation. \\
  When this compiler switch is set,
  a new extra stabilization mechanism can be activated:
  If one of the reconstruction methods \verb|VanLeer|, \verb|Superbee|, or \verb|PP|
  (see Sect.~\ref{s:par:reconstruction}) is activated, the slope can be reduced
  (by averaging with the results from a \verb|MinMod| reconstruction) by setting
  \verb|c_slopered| (see Sect.~\ref{s:par:c_slopered}) to a positive non-zero value.
  This can improve the stability without significantly
  reducing the effective numerical resolution.
  Switch values:
  \begin{itemize}
    \item \verb|0|: (default) no slope reduction.
    \item \verb|1|: slope reduction in case of expansion wave.
    \item \verb|2|: slope reduction in case of strong density contrast.
  \end{itemize}

\item \verb|IDF|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!IDF@\verb/IDF/}
  (``Integer Delta Flux''). \\
  Category: performance enhancement. \\
  Number of padding cells for flux-like variables. This number was introduced to check
  whether the increase of the size of vectors for flux-like quantities (defined at
  cell boundaries) can improve the performance (especially on a CRAY machine).
  The gain is marginal (if present at all). The parameter is usually set to zero
  or left undefined.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) no padding cells
  \item \verb|1,2,3,|\ldots: extra padding cells
  \end{itemize}

\item \verb|rhd_hyd_gravcorr_p01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdhydgravcorrp01@\verb/rhd_hyd_gravcorr_p01/}
  \label{s:rhd_hyd_gravcorr_p01}
  (``rhd hydrodynamics gravitation correction parameter 01''). \\
  Category: selection of approximation. \\
  This parameter controls the way the Roe solver handles the source terms
  due to gravity. A different choice results in different simulation results
  and not just in slightly faster (or slower) code.
  The problem is that the original Roe solver interpretes the pressure gradient
  in a hydrostatic stratification a fluctuation due to shock waves.
  In case of strong stratification this can lead to weird effects.
  With activated correction the Roe solver treats only the deviations from
  a hydrostatic stratification as due to waves (or shocks).
  Several correction formulas have been tried.
  The latest is the recommended default.
  Values:
  \begin{itemize}
  \item \verb|0|: No pressure correction terms in Roe solver.
  \item \verb|1|: Simple correction with rhomean, no new average pressure.
  \item \verb|2|: Simple correction with rhomean, new average pressure.
  \item \verb|3|: Correction with local rho, limited, new average pressure.
  \item \verb|4|: Correction with local rho, new (different formula) average pressure.
  \item \verb|5|: (default) Correction with local rho, new limit, new average pressure.
  \end{itemize}

\item \verb|rhd_hyd_entropyfix_p01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{entropy fix}
  \index{compiler macro!rhdhydentropyfixp01@\verb/rhd_hyd_entropyfix_p01/}
  \label{s:rhd_hyd_entropyfix_p01}
  (``rhd hydrodynamics entropy fix parameter 01''). \\
  Category: performance enhancement. \\
  The entropy fix can be done in one of two ways
  to get optimum performance (with essentially the same results).
  Values:
  \begin{itemize}
  \item \verb|0|: (default) ``if\ldots then\ldots else'' construction
  \item \verb|1|: use a mask and the signum function
  \end{itemize}

\item \verb|rhd_hyd_upwind_p01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdhydupwindp01@\verb/rhd_hyd_upwind_p01/}
  (``rhd hydrodynamics upwind parameter 01''). \\
  Category: performance enhancement. \\
  The determination of the upwind direction can be done in one of two ways
  to get optimum performance (with essentially the same results).
  Values:
  \begin{itemize}
  \item \verb|0|: (default) ``if\ldots then\ldots else'' construction
  \item \verb|1|: use a mask and the signum function
  \end{itemize}

\item \verb|rhd_hyd_roe1d_l01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdhydroe1dl01@\verb/rhd_hyd_roe1d_l01/}
  \label{s:rhd_hyd_roe1d_l01}
  (``rhd hydrodynamics roe 1 dimension loop 01''). \\
  Category: performance enhancement. \\
  The computation of the Roe fluxes can be done by either of two sets of routines
  to find the set which gives optimum performance (with essentially the same results).
  Values:
  \begin{itemize}
  \item \verb|0|: (default) lots of small routines acting on scalars, inlining needed,
                    cache reuse is optimized
  \item \verb|1|: routines acting on arrays, more temporary arrays necessary,
                    vectorization is easier
  \end{itemize}

\item \verb|rhd_roe1d_flux_l01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdroe1dfluxl01@\verb/rhd_roe1d_flux_l01/}
  \label{s:rhd_roe1d_flux_l01}
  (``rhd roe 1 dimension flux loop 01''). \\
  Category: test. \\
  By setting this switch an alternative way of computing the upwind centered Roe states
  is activated (only for 'constant' reconstruction,
  for performance test purposes only: do not activate!).
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) Use standard method to compute the Roe states.
  \item \verb|defined|:   Use non-standard method to compute the Roe states.
  \end{itemize}

\item \verb|rhd_bound_t01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdboundt01@\verb/rhd_bound_t01/}
  (``rhd bound timing 01''). \\
  Category: additional output. \\
  Produce timing information for ``inner boundary'' routine (central potential)
  or lower and upper boundary routines (constant gravitation).
  It can be used together with OpenMP.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information.
  \item \verb|defined|: call subroutines to measure elapsed time.
  \end{itemize}

\item \verb|rhd_roe1d_flux_t01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdroe1dfluxt01@\verb/rhd_roe1d_flux_t01/}
  (``rhd roe 1 dimension flux timing 01''). \\
  Category: additional output. \\
  Produce timing information for the routine which computes the Roe fluxes.
  It should not be used in conjunction with OpenMP.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\item \verb|rhd_roe1d_step_t01|: \\
  in \verb|rhd_hyd_module.F90|,
  \index{compiler macro!rhdroe1dstept01@\verb/rhd_roe1d_step_t01/}
  (``rhd roe 1 dimension step timing 01''). \\
  Category: additional output. \\
  Produce timing information for the routine which performs the Roe step.
  It should not be used in conjunction with OpenMP.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\end{itemize}


\noindent Hydrodynamics (tensor viscosity):

\begin{itemize}

\item \verb|rhd_vis_density_p01|: \\
  in \verb|rhd_vis_module.F90|,
  \index{compiler macro!rhdvisdensityp01@\verb/rhd_vis_density_p01/}
  (``rhd viscosity density parameter 01''). \\
  Category: selection of approximation. \\
  Choose formula for density average at cell boundary in tensor viscosity routines.
  Values:
  \begin{itemize}
  \item \verb|0|: rhomean=min(rholeft,rhoright)
  \item \verb|1|: (default) rhomean=0.5 * (rholeft + rhoright)
  \end{itemize}

\item \verb|rhd_vis_t01|: \\
  in \verb|rhd_vis_module.F90|,
  \index{compiler macro!rhdvist01@\verb/rhd_vis_t01/}
  (``rhd viscosity timing 01''). \\
  Category: additional output. \\
  Produce timing information for 2D/3D tensor viscosity routines.
  It should not be used in conjunction with OpenMP.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\end{itemize}


\noindent Radiation transport:

\begin{itemize}

\item \verb|rhd_r01|: \\
  in \verb|rhd.F90|,
  \index{compiler macro!rhdr01@\verb/rhd_r01/}
  \label{s:rhd_r01}
  (``rhd radiation 01''). \\
  Category: feature activation. \\
  Switch to include LHDrad radiation transport module.
  It uses long characteristics and is restricted to an equidistant grid and
  open boundaries at all surfaces (old ``supergiant module'').
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) LHDrad routines are deactivated.
  \item \verb|1|:         LHDrad routines are recognized by the compiler.
  \end{itemize}

\item \verb|rhd_r02|: \\
  in \verb|rhd.F90|,
  \index{compiler macro!rhdr02@\verb/rhd_r02/}
  \label{s:rhd_r02}
  (``rhd radiation 02''). \\
  Category: feature activation. \\
  Switch to include MSrad\index{MSrad} radiation transport module.
  It uses long characteristics. The lateral boundaries have to be periodic.
  Top and bottom can be closed or open (``solar module'').
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) MSrad routines are deactivated.
  \item \verb|1|:         MSrad routines are recognized by the compiler.
  \end{itemize}

\item \verb|rhd_r03|: \\
  in \verb|rhd.F90|,
  \index{compiler macro!rhdr03@\verb/rhd_r03/}
  \label{s:rhd_r03}
  (``rhd radiation 03''). \\
  Category: feature activation. \\
  Switch to include SHORTrad radiation transport module.
  It uses short characteristics and is restricted to an equidistant grid and
  open boundaries at all surfaces (new ``supergiant module'').
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) SHORTrad routines are deactivated.
  \item \verb|1|:         SHORTrad routines are recognized by the compiler.
  \end{itemize}

\item \verb|rhd_rad3d_toray_l01|: \\
  in \verb|rhd_lhdrad_module.F90|,
  \index{compiler macro!rhdrad3dtorayl01@\verb/rhd_rad3d_toray_l01/}
  (``rhd radiation 3 dimensions to ray loop 01''). \\
  Category: performance enhancement. \\
  There might be a performance gain by splitting the main loop in routine \verb|rhd_rad3d_toray|
  into three separate loops. Typically, one big loop is to be preferred.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) One big loop
  \item \verb|defined|: Three smaller loops
  \end{itemize}

\item \verb|rhd_rad3d_fromray_l01|: \\
  in \verb|rhd_lhdrad_module.F90|,
  \index{compiler macro!rhdrad3dfromrayl01@\verb/rhd_rad3d_fromray_l01/}
  (``rhd radiation 3 dimensions from ray loop 01''). \\
  Category: performance enhancement. \\
  There might be a performance gain by splitting a big loop in routine \verb|rhd_rad3d_fromray|
  into two separate loops. Typically, one big loop is to be preferred.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) One big loop
  \item \verb|defined|: Two smaller loops
  \end{itemize}

\item \verb|rhd_rad3d_r02|: \\
  in \verb|rhd_lhdrad_module.F90|,
  \index{compiler macro!rhdrad3dr02@\verb/rhd_rad3d_r02/}
  (``rhd radiation 3 dimensions radiation 02''). \\
  Category: test. \\
  Module \verb|rhd_lhdrad_module| contains a routine for the handling of periodic
  boundaries.
  It is in an experimental state and is deactivated by default.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) Skip routine \verb|rhd_rad3d_dirper| during compilation
  \item \verb|defined|: Compile routine \verb|rhd_rad3d_dirper|
  \end{itemize}

\item \verb|rhd_rad3d_solve_t01|: \\
  in \verb|rhd_lhdrad_module.F90|,\index{compiler macro!rhdrad3dsolvet01@\verb/rhd_rad3d_solve_t01/}
  (``rhd radiation 3 dimensions solve timing 01''). \\
  Category: additional output. \\
  Produce timing information for the routines which solves the 1D radiation transport
  equation along single ray.
  This routine is called very frequently. The timing measurement might slow it down somewhat.
  It should not be used in conjunction with OpenMP.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\item \verb|rhd_rad3d_dir_t01|: \\
  in \verb|rhd_lhdrad_module.F90|,\index{compiler macro!rhdrad3ddirt01@\verb/rhd_rad3d_dir_t01/}
  (``rhd radiation 3 dimensions direction timing 01''). \\
  Category: additional output. \\
  Produce timing information for the routines which solves the radiation transport
  equation for one direction field.
  The timing measurement are called very frequently and might slow down the code.
  It should not be used in conjunction with OpenMP.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\item \verb|rhd_rad3d_step_t01|: \\
  in \verb|rhd_lhdrad_module.F90|,
  \index{compiler macro!rhdrad3dstept01@\verb/rhd_rad3d_step_t01/}
  (``rhd radiation 3 dimensions step timing 01''). \\
  Category: additional output. \\
  Produce timing information with main 3D radiation transport routine.
  It can be used together with OpenMP and should cause no noticeable performance loss.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}


\item \verb|rhd_shortrad_operator_l01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortradoperatorl01@\verb/rhd_shortrad_operator_l01/}
  \label{s:rhd_shortrad_operator_l01}
  (``rhd short-characteristics radiation operator loop 01''). \\
  Category: performance enhancement, selection of approximation. \\
  Choose type of short characteristics operator. The operators usually come in pairs (1/2, 3/4, 5/6).
  There is a development from 1/2 over 3/4 to 5/6 towards higher stability.
  Both members of each pair should do the same operation but use different ways
  to do a case distinction. The 'even' operator has in most case the better
  performance. But the 'odd' operator might be saver to use.
  Values:
  \begin{itemize}
  \item \verb|0|: simple test operator, fast but results are utterly useless!
  \item \verb|1|: case distinction with ``if..then..else'' construct.
  \item \verb|2|: case distinction with masks (weights 0.0 or 1.0).
  \item \verb|3|: case distinction with ``if..then..else'' construct,
                  slope reduction of source function.
  \item \verb|4|: case distinction with masks (weights 0.0 or 1.0),
                  slope reduction of source function.
  \item \verb|5|: case distinction with ``if..then..else'' construct,
                  modified slope reduction of source function.
  \item \verb|6|: (default) case distinction with masks (weights 0.0 or 1.0),
                  modified slope reduction of source function.
  \item \verb|8|: test version.
  \end{itemize}

\item \verb|rhd_shortrad_operator_l02|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortradoperatorl02@\verb/rhd_shortrad_operator_l02/}
  \label{s:rhd_shortrad_operator_l02}
  (``rhd short-characteristics radiation operator loop 02''). \\
  Category: performance enhancement. \\
  Select the way the short characteristics operator is accessed.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) The routine with the short characteristics operator is called
                  within a loop and should be inlined.
  \item \verb|1|: The program fragment with the short characteristics operator is included.
                  No inlining necessary.
  \end{itemize}

\item \verb|rhd_shortrad_dtauop_l01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortraddtauopl01@\verb/rhd_shortrad_dtauop_l01/}
  \label{s:rhd_shortrad_dtauop_l01}
  (``rhd short-characteristics radiation delta tau operator loop 01''). \\
  Category: performance enhancement. \\
  Choose type of short characteristics tau coupling operator.
  Values:
  \begin{itemize}
  \item \verb|1|: case distinction with ``if..then..else'' construct,
                  default if \verb|rhd_shortrad_operator_l01|=1,3,5.
  \item \verb|2|: case distinction with masks (weights 0.0 or 1.0),
                  default if \verb|rhd_shortrad_operator_l01|=2,4,6.
  \end{itemize}

\item \verb|rhd_shortrad_dtauop_l02|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortraddtauopl02@\verb/rhd_shortrad_dtauop_l02/}
  \label{s:rhd_shortrad_dtauop_l02}
  (``rhd short-characteristics radiation delta tau operator loop 02''). \\
  Category: performance enhancement. \\
  Select the way the operator for the tau coupling (short characteristics module) is accessed.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) The routine with the tau coupling operator is called
                  within a loop and should be inlined.
  \item \verb|1|: The program fragment with the tau coupling operator is included.
                  No inlining necessary.
  \end{itemize}

\item \verb|rhd_shortrad_formal_l01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortradformall01@\verb/rhd_shortrad_formal_l01/}
  \label{s:rhd_shortrad_formal_l01}
  (``rhd short-characteristics radiation formal loop 01''). \\
  Category: performance enhancement. \\
  Select version of loop splitting for exp(-dtau) computation.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) \verb|dtauhalf|, \verb|exp_mdtauhalf|, \verb|expl2t_mdtauhalf|
                    are computed in single loop
  \item \verb|1|: (\verb|dtauhalf|, \verb|exp_mdtauhalf|), (\verb|expl2t_mdtauhalf|)
                    are computed in separate loops.
                    This prevents the SUN1 machine (Sunfire, Solaris, Forte~6.2) from doing
                    some performance degrading optimization
  \end{itemize}

\item \verb|rhd_shortrad_dir1_l01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortraddir1l01@\verb/rhd_shortrad_dir1_l01/}
  \label{s:rhd_shortrad_dir1_l01}
  (``rhd short-characteristics radiation direction 1 loop 01''). \\
  Category: performance enhancement. \\
  Choose routine version for rays in x1 direction.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) Use routine with permuted indices for rays in x1 direction.
                    In this case the innermost loop index is the third array index.
                   The transposition of arrays is not needed but some machines (e.g.\ SUN1) do not like
                   this index arrangement.
  \item \verb|1|: Transpose arrays and use routine \verb|rhd_shortrad_dir3| for rays in x1 direction.
                    The extra step for the transposition of some arrays (and the reverse procedure)
                    needs some time. But now the routine with the optimum index ordering can be used.
  \end{itemize}

\item \verb|rhd_shortrad_dir_l02|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortraddirl02@\verb/rhd_shortrad_dir_l02/}
  (``rhd short-characteristics radiation direction loop 02''). \\
  Category: performance enhancement. \\
  Determine position of PARALLEL statement relative to outer loop in \verb|rhd_shortrad_dirX|.
  Both settings give the same results but might show a different performance on a specific machine.
  Values:
  \begin{itemize}
  \item \verb|0|: (default) PARALLEL statement inside of outer loop
  \item \verb|1|: PARALLEL statement outside of outer loop
  \end{itemize}

\item \verb|rhd_shortrad_lambda_l01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhd_shortradlambdal01@\verb/rhd_shortrad_lambda_l01/}
  \label{s:rhd_shortrad_lambda_l01}
  (``rhd short-characteristics radiation lambda loop 01''). \\
  Category: feature activation. \\
  Handling of extra arrays to allow partially implicit Lambda* iteration 
  Values:
  \begin{itemize}
  \item \verb|0|: (default) Only fully implicit Lambda* iteration allowed
                  (or fully explicit treatment).
  \item \verb|1|: Also partially implicit Lambda* iteration allowed.
  \end{itemize}

\item \verb|rhd_shortrad_formal_t01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortradformalt01@\verb/rhd_shortrad_formal_t01/}
  (``rhd short-characteristics radiation formal timing 01''). \\
  Category: additional output. \\
  Produce timing information for routine which gives the formal solution of the
  radiation transport equation with the help of short characteristics.
  It can be used together with OpenMP and should cause no noticeable performance loss.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\item \verb|rhd_shortrad_step_t01|: \\
  in \verb|rhd_shortrad_module.F90|,
  \index{compiler macro!rhdshortradstept01@\verb/rhd_shortrad_step_t01/}
  (``rhd short-characteristics radiation step timing 01''). \\
  Category: additional output. \\
  Produce timing information for main short characteristics routine.
  It can be used together with OpenMP and should cause no noticeable performance loss.
  Values:
  \begin{itemize}
  \item \verb|undefined|: (default) no timing information
  \item \verb|defined|: call subroutines to measure elapsed time
  \end{itemize}

\item \verb|MSrad_raytas|: \\
  in \verb|MSrad3D.F90|,
  \index{compiler macro!MSradraytas@\verb/MSrad_raytas/}
  \label{s:MSrad_raytas}
  (``Matthias Steffen radiation ray tau s''). \\
  Category: performance enhancement. \\
  Values:
  \begin{itemize}
  \item \verb|0|: (default) Loop with IF..THEN..ELSE
  \item \verb|1|: Loop with ABS,SIGN
  \item \verb|2|: Loop with MIN,MAX
  \end{itemize}

%\item \verb||: in \verb|rhd__module.F90|,
%  (``''). \\
%  Category: . \\
%  Values:
%  \begin{itemize}
%  \item \verb||: (default)
%  \item \verb||: 
%  \end{itemize}

\end{itemize}

\index{compiler macro|)}


%--------------------------------------------------------------------------------------------------
\subsection{Optimization, Compiler Switches\label{s:optimization}}
\label{s:compopt}

In this section some mandatory or useful compiler flags are described.
These have different functions:
\begin{itemize}

\item Enable necessary macro processing/expansion for the \verb|F90| files.

\item Force proper handling of binary I/O.

\item Choose module for radiative transfer.

\item Activate module for dust formation and/or magnetic field transport.

\item Enable parallelization with OpenMP\index{OpenMP} directives.

\item Choose a version of a subroutine or loop which is optimized for
  a specific architecture.

\item Tell the compiler if and what to inline\index{inlining}.

\item Improve the general performance.

\end{itemize}


%..................................................................................................
\subsubsection{Cray: SV1}\index{Cray}\index{craSHi}\index{compiler!Cray}

On craSHi in Kiel (a ``CRAY SV1 20-32768 SN9542'', now out of service)
CO5BOLD could use all 4 processors per board.
Documentation about the system and the compiler can be found with the
\htmladdnormallinkfoot{CRAYdoc}{http://www.cray.com/craydoc/} system.
The new configure script still includes a branch for this system even
if has never been tested on that machine.

In some cases the non-default versions of loops in the CO5BOLD code
vectorize better and are preferred over the standard ones:

\begin{itemize}

\item \verb|-F|: Enable macro expansion

\item \verb|-Otask1|: Parallelization: Enable tasking (in this case OpenMP\index{OpenMP!on Cray VX1}).

\item \verb|-Oinline3|: Optimization: enable (high level) of inlining\index{inlining!Cray VX1}.

\item \verb|-Ovector3 -Oscalar3|: General optimization

\item \verb|-Drhd_hyd_roe1d_l01=1|: Optimization: Choose non-standard set of routines for
  Roe solver\index{Roe solver}.
  See Sect.~\ref{s:rhd_hyd_roe1d_l01}.

\item \verb|-Drhd_hyd_entropyfix_p01=1|: Optimization: version with masks (weights).
  See Sect.~\ref{s:rhd_hyd_entropyfix_p01}

\item \verb|-Drhd_hyd_upwind_p01=1|: Optimization: version with masks (weights).

\item \verb|-Drhd_shortrad_operator_l01=2|: Optimization:
  short characteristics operator with masks (weights).

\item \verb|-Drhd_shortrad_dir_l02=1|: Optimization:
  \verb|OMP PARALLEL| statement outside of outer loop in \verb|rhd_shortrad_dirX|.

\end{itemize}


%..................................................................................................
\subsubsection{Compaq: alpha}\index{alpha}\index{compiler!alpha}

\htmladdnormallinkfoot{Documentation about the Compaq Fortran compiler}{http://www.compaq.com/fortran/docs/index.html}.

The appropriate machine dependent UIO module is \verb|uio_mac_decalpha_module.f90|.

\begin{itemize}

\item \verb|-assume byterecl|: Necessary for the UIO routines\index{UIO!record length unit}:
  specify that the length of a record is measured in bytes (and not in words).
 
\item \verb|-cpp|: invoke the preprocessor on all source files.
 
\item \verb|-inline speed -V|: Force automatic inlining\index{inlining!alpha},
  optimized for speed.
 
\item \verb|-O4|: General optimization.
 
\item \verb|-Drhd_hyd_roe1d_l01=0|: Optimization: Choose standard set of routines for
  Roe solver\index{Roe solver}.
  See Sect.~\ref{s:rhd_hyd_roe1d_l01}.
 
\item \verb|-DMSrad_raytas=0|: Optimization: choose default version
  of loop in \verb|SUBROUTINE raytas| in file \verb|MSrad3D.F90|.\index{MSrad}
  See Sect.~\ref{s:MSrad_raytas}.
 
\end{itemize}


%..................................................................................................
\subsubsection{Hewlett-Packard: V2500\label{s:HPV2500}}\index{Hewlett-Packard}\index{compiler!Hewlett-Packard}

The 12-processor machine ``zeipel'' from
\htmladdnormallinkfoot{Hewlett-Packard}{http://devresource.hp.com/devresource/Tools/lang.html}
is a ``V2500 PA 2.0'' system.
Now, there is a first success to force the compiler to accept the OpenMP
directives in CO5BOLD. Yet, when running on several processors, only some
routines (e.g.\ \verb|rhd_shortrad_dirsimple1|) in CO5BOLD can benefit while
others (\verb|rhd_shortrad_dirsimple2|, \verb|rhd_shortrad_dirsimple3|) are
significantly slower than on one processor.
In addition, the single-processor performance is not very good, partly because
the achievable optimization level is not very high.

Some macros, which seem to be necessary:

\begin{itemize}

\item \verb|+U77|: Link proper library to make the machine understand
  e.g.\ \verb|call flush(6)|.

\item \verb|+cpp=yes|: Switch on the C preprocessor. Note that all Fortran90 files have to
  end with ``.f90''. The ``.F90'' suffix does not seem to work.

\item \verb|+Oparallel +Oopenmp +Onoautopar|: Try to enable parallelization with
  OpenMP directives, disable auto-parallelization.

\item \verb|+Onoinline|: Disables inlining. This can simplify things. With a proper
  choice of routine versions inlining is not really necessary anymore.

\item \verb|+O3 +Olimit|: General optimization with limited resource usage
  during compilation. Some modules should only be compiled with \verb|+O2|, others
  compile even with \verb|+O3 +Onolimit|.

\end{itemize}

The UIO modules and the string handling module should be compiled in debug mode.
A proposed compiling sequence is (MSrad does not compile; all other modules are activated):

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
export F90_LHDRAD=1
export F90_MSRAD=0
export F90_SHORTRAD=1
export F90_DUST=1
export F90_MHD=1
export F90_PARALLEL=openmp

export F90_DEBUG=1
./configure
make UIO STR

export F90_DEBUG=0
./configure
make
\end{alltt}}}


%..................................................................................................
\subsubsection{Hewlett-Packard: Itanium 2}\index{Hewlett-Packard}\index{compiler!Hewlett-Packard}\index{Itanium}

The 2-processor system ``gunnar'' from Hewlett-Packard
is a dual Itanium~2 machine with two 900MHz ia64 CPU modules, 4GB of RAM and 70GB user 
diskspace.

The single-processor performance of CO5BOLD is very good.
On two processor the code runs even faster but just stops after a few time steps. The
number of time steps varies even for simulations with the very same start model
and parameter file. Therefore, OpenMP should not be activated currently.

The compiler settings are somewhat similar to the settings of the HP~V2500 system
in Section~\ref{s:HPV2500}:

\begin{itemize}

\item \verb|+U77|: Link proper library to make the machine understand
  e.g.\ \verb|call flush(6)|.

\item \verb|+cpp=yes|: Switch on the C preprocessor. Note that all Fortran90 files have to
  end with ``.f90''. The ``.F90'' suffix does not seem to work.

\item \verb|+Ofast|: High optimization level. and \verb|+Ofaster| is even higher.

\item \verb|+Oopenmp +Onoautopar|: Try to enable parallelization with
  OpenMP directives, disable auto-parallelization. The code compiles and runs fast
  but crashes after a few time steps.

\end{itemize}

A proposed compiling sequence is (LHDrad, DUST, MHD do not compile):

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
export F90_MSRAD=1
export F90_SHORTRAD=1
./configure
make
\end{alltt}}}


%..................................................................................................
\subsubsection{Hitachi~SR8000}\index{Hitachi}\index{compiler!Hitachi~SR8000}
\label{s:compopt:sr8k}

The appropriate machine dependent UIO module is \verb|uio_mac_hitachi_module.f90|.
The appropriate machine dependent RHD module is \verb|rhd_mac_hitachi_module.f90|.

\begin{itemize}

\item \verb|-conti199|: Up to 199 continuation lines can be interpreted
  (otherwise not more than 39 continuation lines are accepted).

\item \verb|-limit|: Limits the amount of time and memory for compilation.

\item \verb|-opt=ss|: use highest possible optimization level.

\item \verb|-nopredicate|: this option switches off a sub-option activated
  by opt=ss. It is necessary to disable the -predicate option because
  the code crashes otherwise (segmentation violation). The switch must
  appear \emph{after} setting \verb|-opt=ss|.

\item \verb|-pvfunc=2|: References the pseudo-vectorizing mathematical
  function and applies the temporary array to reference the pseudo-vectorizing
  mathematical function.
 
\item \verb|-omp -parallel=1|: parallelize based on
  OpenMP\index{OpenMP!on Hitachi} directives only.
 
 \item \verb|-procnum=8|: generated code for 8 processors on one node

\item \verb|-orphaned=1|: Checks if the regions sequentially executed
  contain orphaned directives during run-time when PROCNUM=8 is specified.
  If a sequentially executed region contains an orphaned directive, the
  system outputs a message and terminates the program.
 
\item \verb|-nestcheck=1|: Checks for nesting errors in parallel regions.
  If a parallel region is nested, the system returns an error and terminates
  the program. {\em Without this option, the code aborts with an error message,
  indicating illegal nesting. Compiler bug?}
 
\item \verb|-pmpar|: Collects the performance monitor information for each
parallelization unit.
 
\item \verb|-pmfunc|: Collects the performance monitor information for each
procedure.
 
\item \verb|-Drhd_hyd_roe1d_l01=1|: Optimization: Choose non-standard set of routines for
  Roe solver\index{Roe solver}.
  See Sect.~\ref{s:rhd_hyd_roe1d_l01}.
 
\item \verb|-DMSrad_raytas=0|: Optimization: choose default version
  of loop in \verb|SUBROUTINE raytas| in file \verb|MSrad3D.F90|.\index{MSrad}
  See Sect.~\ref{s:MSrad_raytas}.

\item {\bfseries Important note:}
  The UIO routines need in addition the compiler
  option \verb|-subchk|: Array bound checking. Without this checking
  option, some UIO routines are not working properly (compiler bug?).
 
\end{itemize}

A proposed compiling sequence is (only default modules activated):

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
export F90_PREFLAGS="-subchk"
./configure
make UIO

export F90_PREFLAGS=
./configure
make
\end{alltt}}}

\noindent\textbf{Performance tests on hwwsr8k}\\[2mm]

\begin{latexonly}
\begin{figure}[hbtp]
\centering
\includegraphics[width=16.2cm]{co5bold/cobold_perf_sr8k}
\caption[Performance tests on Hitachi~SR8000]{Performance tests on Hitachi~SR8000 at HLR~Stuttgart. 
For models with 128x128x192 and 252x252x188 grid cells different values for 
the hydrodynamics and viscosity chunk size parameters were used. 
See text for more details.
}
\label{f:sr8kperftest}
\end{figure}
\end{latexonly}

\begin{htmlonly}
\begin{figure}[hbtp]
\htmlimage{external,thumbnail=1.0,no_transparent}
\centering
\includegraphics[width=16.2cm]{co5bold/cobold_perf_sr8k.eps}
\caption[Performance tests on Hitachi~SR8000]{Performance tests on Hitachi~SR8000 at HLR~Stuttgart. 
For models with 128x128x192 and 252x252x188 grid cells different values for 
the hydrodynamics and viscosity chunk size parameters were used. 
See text for more details.
, \htmladdnormallink{Postscript version}{cobold_perf_sr8k.eps}
}
\label{f:sr8kperftest}
\end{figure}
\end{htmlonly}

Some tests have been performed on the machine hwwsr8k at HLR~Stuttgart in 
order to determine the optimum chunk sizes which are set by the parameters 
\verb|n_hydcellsperchunk| and \verb|n_viscellsperchunk| 
(see Sect.~\ref{s:par:n_hydcellsperchunk} and 
Sect.~\ref{s:par:n_viscellsperchunk}).
\index{rhd.par!integer nhydcellsperchunk@\verb/integer n_hydcellsperchunk/}
Two different models have been used, one consisting of 
128x128x192 grid cells, the other of 252x252x188, respectively. 
Grey radiative transfer has been performed with the MSrad module. 
Different values for the chunk size(s) have been assumed where the
hydrodynamics and the viscosity parameter were set equal.
In all cases three time steps have been computed.
The results are shown in Fig.~\ref{f:sr8kperftest}. 
The number of resulting chunks for step HYD1 (the values for HYD2, HYD3, and VIS are very similar), 
total memory, performance, and the wall clock duration of the hydrodynamics and the viscosity 
routines are shown as functions of the chunk size parameter(s). 
Clearly, the number of chunks decreases towards larger chunk sizes whereas the required
memory increases -- in particular for very large chunk size values. 
Moreover, performance and CPU time can be optimised by choosing the right parameter values. 
Interestingly, the optimum chunk size is different for hydrodynamics and viscosity. 
Based on these tests, a larger value seems to be preferable for the viscosity 
(\verb|n_viscellsperchunk|). 
In the case of the smaller model, 50000 seems to be fine for the hydrodynamics whereas the 
optimum viscosity chunk size is 200000. 
This difference explains the double-peaked structure of performance and CPU~time.
Note that the optimum values do not only depend on the architecture used but also on the 
dimensions of the model. 
We recommend to test some chunk size values since it might lead to a higher performance.


%..................................................................................................
\subsubsection{Linux: PGI Compiler}\index{Linux}\index{compiler!PGI}

So far, under Linux the compiler of the
\htmladdnormallinkfoot{Portland Group}{http://www.pgroup.com/}
has been used mostly to compile CO5BOLD.
It is called with \verb|pgf90|.

Important switches are:

\begin{itemize}

\item \verb|-byteswapio|: With this flag set, binary files in
  \verb|big_endian|\index{bigendian@\verb/big_endian/} format
  (the standard for UIO files)
  are automatically transformed to
  \verb|little_endian|\index{littleendian@\verb/little_endian/}
  and vice versa.

\item \verb|-fast|: General optimization flag to choose (close to)
  optimum optimization for local machine.

\item \verb|-Mvect=sse|: Optimization: Allow Pentium~III vector commands.

\item \verb|-Mcache_align|: Optimization: Align some data object
  on cache-line boundaries.

\item \verb|-fastsse|: From compiler version 4.0 on, this option can be used instead
  of the three previous ones. It contains and supersedes them.

\item \verb|-Minline=...|: Optimization: Routines that should be
  inlined\index{inlining!PGI compiler on Linux}: \\
 file \verb|rhd_hyd_module.F90|: \verb|rhd_hyd_avg|,
  \verb|rhd_hyd_upwind|,
  \verb|rhd_hyd_pred0|,
  \verb|rhd_hyd_predm|,
  \verb|rhd_hyd_predp|,
  \verb|rhd_hyd_alpha|,
  \verb|rhd_hyd_constanteq|,
  \verb|rhd_hyd_minmodeq|,
  \verb|rhd_hyd_minmod|,
  \verb|rhd_hyd_vanleereq|,
  \verb|rhd_hyd_vanleer|,
  \verb|rhd_hyd_superbeeeq|,
  \verb|rhd_hyd_superbee|,
  \verb|rhd_hyd_ppeq|,
  \verb|rhd_hyd_pp|,
  \verb|rhd_hyd_hdflux|, \\
 file \verb|rhd_lhdrad_module.F90|:
  \verb|rhd_rad3d_raylhd|,
  \verb|rhd_rad3d_solve|,
  \verb|rhd_rad3d_solveeq|, \\
 file \verb|rhd_shortrad_module.F90|:
  \verb|rhd_shortrad_operator|,
  \verb|rhd_shortrad_dtauop|.

\item \verb|-DMSrad_raytas=2|: Optimization: choose non-default version
  of loop in \verb|SUBROUTINE raytas| in file \verb|MSrad3D.F90|.\index{MSrad}
  See Sect.~\ref{s:MSrad_raytas}.

\item \verb|-Drhd_hyd_roe1d_l01=0|: Optimization: choose standard set of routines for
  Roe solver\index{Roe solver}.
  See Sect.~\ref{s:rhd_hyd_roe1d_l01}.
 
\item \verb|-Drhd_shortrad_operator_l02=1|: Optimization: use the ``manually inlined
  version'' of the short characteristics operator.\index{short characteristics}

\item \verb|-Drhd_shortrad_dtauop_l02=1|: Optimization: use the ``manually inlined
  version'' of the optical coupling operator.

\end{itemize}

Everything compiles. The MSrad radiation transport module does not work with OpenMP
activated. In this case it is recommended to use the Intel compiler instead
(see Sect.~\ref{s:Intelcompiler}).


%..................................................................................................
\subsubsection{Linux: Intel Compiler\label{s:Intelcompiler}}\index{Linux}\index{compiler!Intel}\index{Intel}

With Version 7.0 of the
\htmladdnormallinkfoot{Intel compiler}{http://www.intel.com/software/products/compilers/flin/index.htm}
CO5BOLD compiles.

The native format on Intel machines is
\verb|little_endian|.\index{littleendian@\verb/little_endian/}
With
{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
export F_UFMTENDIAN=big
\end{alltt}}}
(to be set at runtime after compilation before running CO5BOLD)
the default can be changed to
\verb|big_endian|.\index{bigendian@\verb/big_endian/}
The appropriate UIO modules are \verb|uio_mac_intel_module.f90| in the \verb|little_endian|
case and \verb|uio_mac_sun_module.f90| in the \verb|big_endian| case.
The compiler is called with \verb|ifc|.

Important switches are:

\begin{itemize}

\item \verb|-Vaxlib|: Link proper library to make the machine understand
  e.g.\ \verb|call flush(6)|.

\item \verb|fpp|: Activate the preprocessor (silently).

\item \verb|-O3|: General optimization flag.

\item \verb|-tpp6 -xK|: Optimization especially for Pentium~III
  (includes SSE vector commands).

\item \verb|-ip|: Optimization: activate interprocedural optimization within
  each source file. This enables inlining.\index{inlining!Intel compiler on Linux}

\item \verb|-DMSrad_raytas=2|: Optimization: choose non-default version
  of loop in \verb|SUBROUTINE raytas| in file \verb|MSrad3D.F90|.\index{MSrad}
  See Sect.~\ref{s:MSrad_raytas}.

\item \verb|-Drhd_shortrad_dir1_l01=1|: Optimization:
  Transpose arrays and use routine \verb|rhd_shortrad_dir3| for rays in x1 direction.
  See Sect.~\ref{s:rhd_shortrad_dir1_l01}.

\item \verb|-openmp|: Parallelization: OpenMP directive are activated. Note that the
  UIO routines should be compiled without OpenMP support (even if they do not contain
  any OpenMP directives themselves).

\end{itemize}

Using the Intel compiler there is a problem with the UIO modules when OpenMP is activated.
This a bit weird because the UIO modules do not contain any OpenMP directives.
However, this means that OpenMP can be safely deactivated for these modules.
A proposed compiling sequence is (all modules activated):

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
export F90_LHDRAD=1
export F90_MSRAD=1
export F90_SHORTRAD=1
export F90_DUST=1
export F90_MHD=1

export F90_PARALLEL=scalar
./configure
make UIO

export F90_PARALLEL=openmp
./configure
make
\end{alltt}}}


%..................................................................................................
\subsubsection{NEC SX-5}\index{NEC SX-5}\index{compiler!NEC SX-5}

First attempts to compile CO5BOLD on neSH at the Rechenzentrum~Kiel and 
on hwwsx5 at HLR~Stuttgart:

An environment variable has to be set to \verb|F_RECLUNIT=BYTE|
(before execution of a program) to enable UIO to compute proper
record lengths.
The cross compiler (on sunsrv or crossi) is called with \verb|sxf90|.
Thus, the environment variable \verb|F90_COMPILER=sx90| has to be set 
before running the configure script. 

No optimized version of CO5BOLD has been achieved yet.

Some maybe useful switches are

\begin{itemize}

\item \verb|sx5|: generate instructions for SX-5

\item \verb|C vopt|: normal optimization in vector mode

\item \verb|-Wf'-M noflunf -M noinv -M noinexact -M setall'|:
  suppress some exceptions

\item \verb|-P openmp|: parallelization with OpenMP\index{OpenMP}

\item \verb|-Ep|: call cpp preprocessor

\item \verb|-pi exp=...|: inlining

\item \verb|-dw -float0| (no special environment variable): use internally and
  in files the 4\,Byte \verb|big_endian| format\index{bigendian@\verb/big_endian/}

\end{itemize}

The compiler flags in the configure script are
\begin{verbatim}
  F90FLAGS="-C hopt -sx5 -dw -float0
  -Wf'-L nostdout -L fmtlist -L inclist -L mrgmsg -L transform -M noflunf
      -M noinv -M noinexact -M setall'
  -pi exp=rhd_shortrad_operator exp=rhd_shortrad_dtauop ${F90MODULES}
  ${F90TIME} -DMSrad_raytas=1"
\end{verbatim}


%..................................................................................................
\subsubsection{SGI: Origin}\index{SGI}\index{compiler!SGI}

CO5BOLD has been compiled and tested on up to 8 processors on the
SGI~2000 machine at TAC in Copenhagen and the
\htmladdnormallinkfoot{SGI~3800 machine at the NSC}{http://www.nsc.liu.se/systems/sgi3k/}
in Link{\"o}ping.
See e.g.\ the excellent
\htmladdnormallinkfoot{SGI Fortran90 manual}{http://techpubs.sgi.com/library/tpl/cgi-bin/init.cgi}
\begin{htmlonly}
\htmladdnormallink{(or here)}{http://techpubs.sgi.com:80/library/tpl/cgi-bin/browse.cgi?coll=0650\&db=bks\&cmd=toc\&pth=/SGI\_Developer/MPro7F90CD\_RM}
\end{htmlonly}.
Note, that recent versions of the code (or the configure script) have not been tested
on any SGI machine.

Important switches are:

\begin{itemize}

\item \verb|-macro_expand|: Enable macro expansion

\item \verb|-mp|: Enable parallelization with OpenMP directives\index{OpenMP!on SGI}

\item \verb|-INLINE:aggressive=ON -INLINE:list -INLINE:preempt=ON|: General keywords
  for inlining\index{inlining!SGI}

\item \verb|-INLINE:must=...|: Optimization: Routines that should be
  inlined: \\
 file \verb|rhd_hyd_module.F90|: \verb|rhd_hyd_avg|,
  \verb|rhd_hyd_upwind|,
  \verb|rhd_hyd_pred0|,
  \verb|rhd_hyd_predm|,
  \verb|rhd_hyd_predp|,
  \verb|rhd_hyd_alpha|,
  \verb|rhd_hyd_constanteq|,
  \verb|rhd_hyd_minmodeq|,
  \verb|rhd_hyd_minmod|,
  \verb|rhd_hyd_vanleereq|,
  \verb|rhd_hyd_vanleer|,
  \verb|rhd_hyd_superbeeeq|,
  \verb|rhd_hyd_superbee|,
  \verb|rhd_hyd_ppeq|,
  \verb|rhd_hyd_pp|,
  \verb|rhd_hyd_hdflux|, \\
 file \verb|rhd_lhdrad_module.F90|:
  \verb|rhd_rad3d_raylhd|,
  \verb|rhd_rad3d_solve|,
  \verb|rhd_rad3d_solveeq|, \\
 file \verb|rhd_shortrad_module.F90|:
  \verb|rhd_shortrad_operator|,
  \verb|rhd_shortrad_dtauop|.

\item \verb|-O3 -OPT:Olimit=0|: General optimization

\item \verb|-IPA:plimit=5500|: Even more optimization

\end{itemize}


%..................................................................................................
\subsubsection{SGI: Origin 2000/3800 at UKAFF}\index{UKAFF}\index{compiler!SGI!UKAFF}

CO5BOLD has been also compiled and tested on up to 22 processors on
the machines of the \htmladdnormallinkfoot{UK Astrophysical Fluids
Facility (UKAFF)}{http://www.ukaff.ac.uk/} in Leicester,
England. UKAFF operates two machines: an SGI Origin 3800 with 128
processors (named ``ukaff''), and an older SGI Origin 2000 with 22
processors (named ``grand'') which is mainly used for development and
test purposes. Both machines are binary compatible. At the time of
testing (April 2003) the SGI MIPSpro Compilers (Version 7.4) was
installed.

Most of the compiler switches given in the previous section were used,
except for the following modifications which either gave empirically a
better performance or were recommended by the UKAFF {\it Hints for
users\/}:
\begin{itemize}
\item \verb|-Ofast|: Replaces \verb|-O3|, gave better performance 
\item \verb|-LNO:cs1=32k:ls1=32:cs2=8M:ls2=128|: Explicit cache
  architecture added
\end{itemize}
These settings are now selected by the configure script for an SGI
machine with IP35 architecture. This is rather ad-hoc, and was added
in this fashion since the UKAFF machines have this architecture. It is
unclear whether the above switches are good for all SGI IP35
architectures.

A glitch in the system libraries made it necessary to add a
work-around to the source code (file \verb|rhd.F90|). A ``bus error''
occurred whenever the system routine ``flush'' was trying to flush an
empty file buffer. The work-around was simply to add a write statement
before every call of ``flush''. This made the log-file look less nice
but did the job.

The main goal was to investigate the scaling of the performance of
CO5BOLD with the number of processors. This was done only for the
MSrad module, considering local surface convection models. Two model
sizes were tested: a small one with 125x125x81 grid points employing
non-grey radiative transfer (4 frequency bands), and a large one with
315x315x81 grid points employing grey radiative transfer. Rather short
runs of 10 (small model) and 3 (large model) time steps were
performed. Even for the large model the memory demand was ca. 800Mb,
which is very modest considering that every sub-node of the machine
--- consisting of 4 processors --- has 2Gb of memory.

The results are summarized in the following three figures. The black
lines give the scaling of the total time, the green lines the scaling
of the time needed by the hydrodynamics routines, and the red lines
the scaling of the radiative transfer routines. The scaling is
presented as the increase of processing time per processors as the
problem is distributed among more and more processors. The times are
normalized to the time that is used in a scalar, i.e. single processor
setup. Ideally, one would like a constant behavior which stays close
to one.

\begin{figure}[hbtp]
\centering
\includegraphics[width=16.2cm]{co5bold/grand_small}
\end{figure}

\begin{figure}[hbtp]
\centering
\includegraphics[width=16.2cm]{co5bold/grand_large}
\end{figure}

\begin{figure}[hbtp]
\centering
\includegraphics[width=16.2cm]{co5bold/ukaff_large}
\end{figure}

The perhaps most interesting result is that the speedup on ``ukaff''
is about 11 for the large model on 16 processors. Perhaps not ideal,
but within the range of practical interest. In general, the
hydrodynamics routines scale more favorably than the radiation
routines. This is perhaps simply related to the fact that in explicit
hydrodynamics communication is restricted to neighboring grid
cells. 

For those wondering: the black curves do not lie between the red and
green curve since more components than just radiation and
hydrodynamics add up to the total time. Furthermore, the normalization
of the execution times given by CO5BOLD is not exact.

%..................................................................................................
\subsubsection{Sun: SunFire}\index{Sun}\index{compiler!Sun}

CO5BOLD has been used on the
SunFire machines``fire1'', ``fire2'', and  ``fire3'' in Uppsala with
compiler version ``Sun WorkShop 6 update 2 Fortran 95 6.2 2001/05/15'' and later.
An older version was not able to compile CO5BOLD properly.
Information about Fortran and the Sun compiler can be found on the
\htmladdnormallinkfoot{Sun Forte page}{http://www.sun.com/forte/fortran/}
under ``documentation''.
Important switches are:

\begin{itemize}

\item \verb|-openmp|: Enable OpenMP.\index{OpenMP!on Sun}

\item \verb|-fast -xvector=yes/no|: General optimization.
  On the Sun the \verb|-fast| option switches on more or less all optimization
  features of the compiler. That works reasonable well. However, during the
  compilation of \verb|gasinter_routines.f90| (and only there)
  the switch \verb|-xvector=no| is requiered! This is one automatically in the
  Makefile.

\item \verb|-inline=...|: Optimization: Routines that should be
  inlined\index{inlining!Sun}: \\
 file \verb|rhd_hyd_module.F90|: \verb|rhd_hyd_avg|,
  \verb|rhd_hyd_upwind|,
  \verb|rhd_hyd_pred0|,
  \verb|rhd_hyd_predm|,
  \verb|rhd_hyd_predp|,
  \verb|rhd_hyd_alpha|,
  \verb|rhd_hyd_constanteq|,
  \verb|rhd_hyd_minmodeq|,
  \verb|rhd_hyd_minmod|,
  \verb|rhd_hyd_vanleereq|,
  \verb|rhd_hyd_vanleer|,
  \verb|rhd_hyd_superbeeeq|,
  \verb|rhd_hyd_superbee|,
  \verb|rhd_hyd_ppeq|,
  \verb|rhd_hyd_pp|,
  \verb|rhd_hyd_hdflux|, \\
 file \verb|rhd_lhdrad_module.F90|:
  \verb|rhd_rad3d_raylhd|,
  \verb|rhd_rad3d_solve|,
  \verb|rhd_rad3d_solveeq|, \\
 file \verb|rhd_shortrad_module.F90|:
  \verb|rhd_shortrad_operator|,
  \verb|rhd_shortrad_dtauop|.

\item \verb|-DMSrad_raytas=2|: Optimization: choose non-default version
  of loop in \verb|SUBROUTINE raytas| in file \verb|MSrad3D.F90|.\index{MSrad}
  See Sect.~\ref{s:MSrad_raytas}.

\item \verb|-Drhd_shortrad_formal_l01=1|: Optimization:
  split loop for exp(-dtau) computation into two loops.
  See Sect.~\ref{s:rhd_shortrad_formal_l01}.

\item \verb|-Drhd_shortrad_dir1_l01=1|: Optimization:
  Transpose arrays and use routine \verb|rhd_shortrad_dir3| for rays in x1 direction.
  See Sect.~\ref{s:rhd_shortrad_dir1_l01}.

\item \verb|-Drhd_hyd_entropyfix_p01=1|: Optimization: version with masks (weights).
  See Sect.~\ref{s:rhd_hyd_entropyfix_p01}.

\end{itemize}

\index{compilation|)}


\clearpage
%==================================================================================================
\section{UIO Data Format\label{s:uio}}\index{UIO|(}\index{data format}

%--------------------------------------------------------------------------------------------------
\subsection{Quickstart: Introduction to UIO\label{s:quickstart_UIO}}

The UIO (``Universal Input Output'') routines are a set of routines in
Fortran90 and IDL to manage I/O of scalars, arrays and a certain table type.
Files can be formatted or unformatted.

The formatted (ASCII text) data representation is machine-independent and
appropriate for human reading.

The unformatted (binary) representation provides much faster I/O, gives
smaller files and the IEEE format is a quasi-standard among many
platforms/compilers.
On all platforms the native binary representation can be chosen.
On some machines additional
conversion types are offered (IEEE on most machines, CRAY format an CRAYs).

Files produced with UIO are not automatically readable on
all machines. But it is always possible to produce
(formatted) UIO files on a machine which are readable on all others.
And with some fiddling with compile options or the call of machine-specific
subroutines provided by the compiler vendor it was up to now always possible
to enable the access to binary UIO files on all machine tested.

Each file entry is a header-data-unit.
The header contains information on the one hand to identify the entry
and on the other hand to specify the format and size of the following data
block.
This data block usually consists of a scalar or an array. In some cases it
is empty (e.g.\ for labels) or it contains more complex information (for
tables).

The first version of UIO routines was written in FORTRAN77\index{Fortran}.
They still exist. But further development was done with the
Fortran90 versions.
Therefore, the use of the FORTRAN77 routines is not recommended anymore.
The current Fortran version of the UIO routines is a set of Fortran90 modules.

To allow a communication between Fortran and IDL\index{IDL} programs,
an IDL version of the UIO routines has been written.
The correspondence between Fortran and IDL routines
is rather close. But in detail, there are differences.
Currently, IDL Version~5.4 (sunos sparc) is used.
Amazingly, the UIO routines also used to work under {\em PV-WAVE\/} (Version~6.01
(sun4 solaris sparc)).
The UIO routines have been successfully compiled and used on
Cray, alpha, HP V2500, HP Itanium2, Hitachi, Linux (with PGI and Intel compiler), SGI, and Sun
machines.

So far, there exist three UNIX shell scripts
(calling Fortran routines) useful to quickly examine
data sets or to change the format or conversion type of files.


%--------------------------------------------------------------------------------------------------
\subsection{Example of UIO Data File\label{s:fileexample}}

To give a first impression about the data structure,
here follows a simple test file\index{UIO!example}, which contains
the header, a label, a couple of scalars, an array, and a short table:

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=formatted convert=native version=0.1.1997.11.29 &
date='29.11.1997 21:23:39.835' system=IRIX machine=atlas osrelease=6.3 &
osversion=12161207 hardware=IP32 language=Fortran90 program=uiotst

label testdata n='sample test data field' date='29.11.1997 21:23:39.835'

integer ia f=I3 b=4 n='This is the answer'
 42
complex ca f='''('',E13.6,'','',E13.6,'')''' b=8 n='This is a complex answer'
( 0.400000E+01, 0.200000E+01)
real da f=E23.15 b=8 n='precise answer'
  0.420000000000000E+02
real answer f=F4.0 b=4 n=answer u=1
 42.

real real2d d=(100:103,200:204) f=E13.6 p=4 b=4
 0.100000E+01 0.200000E+01 0.300000E+01 0.400000E+01
 0.500000E+01 0.600000E+01 0.700000E+01 0.800000E+01
 0.900000E+01 0.100000E+02 0.110000E+02 0.120000E+02
 0.130000E+02 0.140000E+02 0.150000E+02 0.160000E+02
 0.170000E+02 0.180000E+02 0.190000E+02 0.200000E+02

table f77table d=(1:5,1:7) f=1X b=1 n='test table to test the table routines'
integer   int1  f=I5    b=4  n='Integer: 1. Spalte'
real      real1 f=F5.1  b=4  n='Real: 2. Spalte'
character char1 f=A16   b=16 n='Char: 3. Spalte'
real      real2 f=E13.6 b=4  n='Real: 4. Spalte'
integer   int2  f=I5    b=4  n='Integer: 5. Spalte'
 int1 real1            char1         real2  int2
    1   2.0 a                 0.100000E+02     1
    2   4.0 ab                0.200000E+02     2
    3   6.0 abc               0.300000E+02     3
    4   8.0 abcd              0.400000E+02     4
    5  10.0 abcde             0.500000E+02     5
    6  12.0 abcdef            0.600000E+02     6
    7  14.0 abcdefg           0.700000E+02     7
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsection{Structure of UIO Files}


%--------------------------------------------------------------------------------------------------
\subsubsection{Data Representation: ASCII or Binary\label{s:UIO_data_representation}}

While opening a file for writing, the file format\index{UIO!format}
(``formatted''\index{formatted} or ``unformatted''\index{unformatted})
and the conversion type\index{UIO!conversion type} (``native'', e.g.\ ``ieee\_4'', \ldots)
have to be specified.

The {\em formatted\/} ASCII data representation allows I/O independent of platform or
compiler. It is useful for parameter files which can be read and edited
by hand, for the direct inspection of data, the transfer between very different
systems, or for the import of data which exist e.g.\ in a table format.
From the specified conversion type only the default output format for numbers
(e.g.\ ``E13.6'' for 4 byte reals) is determined.

The {\em unformatted\/} binary I/O is much faster and gives usually more compact
files with higher accuracy (ideally exact) in the numerical data representation.
But -- in principle -- the file format is machine dependent. 
Fortunately, the IEEE format turns out to become a quasi-standard among a
variety of machines. Most workstations work internally with this format.
Some CRAYS which have a different internal data representation allow the hidden
transformation between the internal and IEEE format during the I/O process.
The UIO routines support this feature of CRAY FORTRAN compilers by means of a
module (\verb|uio_mac_module|) individually designed for (two types of) CRAY
machines using certain CRAY specific system calls (CRAY FFIO assign logic).
Nevertheless, there is also a machine independent version of this module,
written completely in standard Fortran90 but providing less features
than the machine-dependent versions.

Besides the format the conversion type\index{UIO!conversion type} (see table~\ref{t:conversiontypes})
has to be specified.
The ``native'' conversion type is the internal binary data representation,
which is also standard for unformatted Fortran output. If this representation
happens to be conformal with the IEEE standard the conversion type
``ieee\_4'' should be used. It gives the same data format, but in the header
of the file the term ``convert=ieee\_4'' instead of ``convert=native''
describes the data format precisely -- in a way also understandable by other
machines.
On CRAY machines the native format is equal to the conversion type
``crayxmp\_8'', but also the conversion types ``ieee\_4'',
``ieee\_4\_limit'', and ``ieee\_8'' can be chosen.
The last three conversion types correspond to the CRAY internal types
``ieee\_32'', ``ieee\_dp'', and ``ieee\_64'', respectively.

On a machine with an internal data representation not within the list in
the existing \verb|uio_mac*_module.f90| files one could use the standard file
\verb|uio_mac_module.f90| and is restricted to the ``native'' conversion type.
But it is better to invent an appropriate name for the new data format and
to build a proper machine dependent UIO file, e.g.\ from
\verb|uio_mac_ieee_module.f90|.

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|lrrrl|} \hline
conversion type    & I & R & D & description \\ \hline
\verb|native|      & ? & ? & ? & internal data format on all machines \\
                   &   &   &   & (sometimes useful but not recommended) \\
\verb|ieee_4|      & 4 & 4 & 8 & standard IEEE \verb|big_endian| format (recommended)\index{bigendian@\verb/big_endian/} \\
\verb|ieeele_4|    & 4 & 4 & 8 & IEEE \verb|little_endian| format\index{littleendian@\verb/little_endian/} \\
\verb|ieee_8|      & 8 & 8 &16 & double precision IEEE \verb|big_endian| format \\
                   &   &   &   & (on some machines possible) \\
\verb|crayxmp_8|   & 8 & 8 &16 & CRAY internal data format \\
\verb|idl|         & 4 & 4 & 8 & IDL format (but IDL also supports \verb|ieee_4|) \\
\verb|xdr|         & 4 & 4 & 8 & format possible with IDL \\ \hline
\verb|ieee_4_limit|& 4 & 8 & 8 & standard IEEE format $\rightarrow$ \verb|ieee_4|\\
\verb|ieee|        & ? & ? & ? & IEEE format, unknown length (not recommended) \\ \hline
  \end{tabular}
\caption[UIO conversion types]{UIO conversion types with length of integers, single
precision reals, and double precision reals in bytes, and an explanation.
}\label{t:conversiontypes}
 \end{center}
\end{table}

Some attention has to be paid if weird compiler switches (as e.g.\ -r16 -i2)
are used to modify the accuracy and standard memory size of variables.

If an existing file is opened for reading, the file format and conversion type
are determined automatically from the file if the conversion type of the data
in the file is among the conversion types supported by the compiler.
If the file has a conversion type ``native'' but is created on a machine with
different internal data representation, the file header might be readable, but
an error will probably occur during the reading of a real variable.


%--------------------------------------------------------------------------------------------------
\subsubsection{Data File Structure}

The UIO routines only handle sequential files.
Each file consists of a list of entries. The first entry describes the file
format, conversion type, and the machine who is responsible for it. The
following entries contain data
(scalars and 1D \ldots 4D arrays of type integer, real (single \& double
precision), complex (single precision), character;
tables with columns of type integer, real (single precision), or character),
or structuring information (labels).

Each entry consists of the header and the (possibly empty) data block.

Each header is a list of at most 20 terms separated by blanks.
The first term is the entry type (see table~\ref{t:entrytypes}),
followed by an identifier. This identifier should follow the standard rules
for variables (small capital letters, numbers, underline; starting with letter),
a name as e.g.\ \verb|rho|, \verb|v_1|.
The rest of the terms come in the form ``keyword=value''.
See Tab.~\ref{t:headkeywords}.

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|ll|} \hline
entry type       & entry contents \\ \hline
\verb|fileform|  & file description (first entry) \\
\verb|integer|   & scalars, 1D \ldots 4D arrays \\
\verb|real|      & scalars, 1D \ldots 4D arrays, single \& double precision \\
\verb|complex|   & scalars, 1D \ldots 4D arrays, single precision \\
\verb|character| & scalars, 1D \ldots 4D arrays \\
\verb|table|     & table with integer, real, character columns \\
\verb|label|     & label entry for file structuring \\ \hline
  \end{tabular}
\caption[UIO entry types]{UIO entry types
}\label{t:entrytypes}
 \end{center}
\end{table}

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|llllll|} \hline
keyword  & description      & example       & descriptor&info.\ & necessary\\ \hline
b        & byte number      & 4             & format    &       & yes \\
d        & dimension        & (0:9)         & format    &       & yes (arrays) \\
ds       & dimension shift  & (1:1)         &           & yes   & \\
f        & Fortran format   & E13.6         & format    &       & yes \\
p        & values per line  & 4             & format    &       & yes (arrays) \\
t        & transformation   & log10         & format    &       & \\
n        & name             & density       &           & yes   & \\
u        & unit             & g/cm\verb|^|3 &           & yes   & \\
date     & date             & 1.1.98        &           & yes   & \\
c0\ldots9& comment          & Dichte        &           & yes   & \\ \hline
form     & file format      & formatted     & file      &       & yes (file header) \\
convert  & conversion       & ieee\_4       & file      &       & yes (file header) \\
version  & version          & 0.1.1997.11.29&           & yes   & \\
system   & system           & IRIX          &           & yes   & \\
machine  & machine name     & atlas         &           & yes   & \\
osrelease& OS release       & 6.3           &           & yes   & \\
osversion& OS version       & 12161207      &           & yes   & \\
hardware & machine hardware & IP32          &           & yes   & \\
language &program.\ language& Fortran90     &           & yes   & \\
program  & program          & uiotst        &           & yes   & \\ \hline
xyz\ldots&user defined      & source        &           & yes   & \\ \hline
  \end{tabular}
\caption[UIO header keywords]{Standard UIO entry header keywords:
The keyword is given with a short description and an example.
The fourth, fifth, and sixth column indicate if the keyword is a mandatory descriptor
(in the file header or for the format of an entry)
or if it gives only additional information and is optional and therefore not
necessary to specify.
}\label{t:headkeywords}
 \end{center}
\end{table}

A header line has a maximum length of 80~characters.
A continuation line is indicated by \verb*| &| at the end of the line.
A header consists of 20~lines at maximum.
It can be preceded by empty lines (except for the file header entry).
Example\index{UIO!example}:

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real time f=F9.2 b=4 n='Time' u=s c0='Simulation time in seconds' &
  c1='Time count starts at 0.0'
    12.34
\end{alltt}}}

The entry header is followed by the entry data block. This block is empty for
labels and the fileform entry but non-empty otherwise.

In an {\em unformatted\/} file each header line is an individual record
containing a string with exactly 80~characters.
The following data block (scalar or array) is one single record.

In a {\em formatted\/} file each header line is a string of at most 80~characters
delimited by a \verb|LINEFEED| of whatever the operating system decided to be
appropriate as \verb|EOL| character (sequence).
The following data block is written as sequence of lines.
The number of items per line is specified by the ``p=?'' keyword in the header.


%--------------------------------------------------------------------------------------------------
\subsubsection{Tables\label{s:uiotables}}

For a table the entry header is followed by a list of headers for the individual
table columns, a single table header line consisting of (abbreviations of)
the table entry identifiers and the table itself (see the example in
section~\ref{s:fileexample}).
The dimension keyword gives the number of columns and rows in the form
``d=(1:columns,1:rows)''.

The Holweger-M{\"u}ller-Atmosphere is chosen as the following
``real world'' example\index{UIO!example} for a file with a table in UIO format:

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=formatted convert=ieee_4 version=0.0.1996.10.29 &
  date='20-Feb-1997 18:40:45' system=SunOS machine=saturn osrelease=4.1.3 &
  osversion=3 hardware=sun4m language='IDL 4.0' program='by hand'

character description d=(0:3) f=A80 p=1 b=80 d='13-Nov-1996 18:29:48'
Holweger-Mueller-Atmosphere,
Hartmut Holweger & Edith Mueller (1974) Solar Physics 39, 19-30, table II,
empirical solar temperature stratification to fit solar spectral lines and
limb darkening

character history d=(0:3) f=A80 p=1 b=80 d='13-Nov-1996 18:29:52'
Holweger-Mueller-Atmosphere, from 1974
uio-form:              13-Nov-1996 18:29:52
conversion type added: 20-Feb-1997 18:21:01
xi -> vmicro:          20-Feb-1997 18:23:43

real teff f=F6.1 b=4 n='effective temperature' u=K texa='T_{\rm eff}'
5780.0

table atmosphere d=(1:7,1:29) f=X b=1 n=Holweger-Mueller-Atmosphere &
c0='Hartmut Holweger & Edith Mueller (1974) Solar Physics 39, 19-30, table II' &
  c1=Teff(Sun)=5780K
real tauross f=E9.2 b=4 n='optical depth (Rosseland)' u=1
real tau5000 f=F7.3 b=4 n='optical depth (lambda5000)' u=1 t=log10
real t       f=F7.0 b=4 n=temperature u=K
real pgas    f=F6.3 b=4 n='gas pressure' u=dyn/cm^2
real pel     f=F6.3 b=4 n='electron pressure' u=dyn/cm^2
real vmicro  f=F4.2 b=4 n=microturbulence u=km/s
real q       f=F8.5 b=4 n='Hopf function' u=1 c0='q=((T(tau)/Teff)^4)/0.75)-tau'
  tauross tau5000       t   pgas    pel vmic        q
 2.00E-07  -6.539   3900.  0.769 -3.140 0.00  0.27637
 2.50E-07  -6.279   3920.  1.171 -2.752 0.00  0.28208
 5.00E-07  -5.868   3970.  1.598 -2.342 0.00  0.29675
 1.00E-06  -5.588   4030.  1.842 -2.105 0.00  0.31510
 2.00E-06  -5.334   4080.  2.042 -1.910 0.00  0.33103
 5.00E-06  -5.001   4160.  2.279 -1.674 0.00  0.35776
 1.00E-05  -4.747   4210.  2.450 -1.508 0.00  0.37527
 2.00E-05  -4.486   4270.  2.618 -1.341 0.00  0.39712
 5.00E-05  -4.131   4340.  2.835 -1.128 0.00  0.42377
 1.00E-04  -3.856   4400.  2.999 -0.967 0.50  0.44765
 2.00E-04  -3.577   4460.  3.162 -0.804 0.50  0.47248
 5.00E-04  -3.200   4530.  3.377 -0.596 0.50  0.50256
 1.00E-03  -2.912   4590.  3.541 -0.437 0.50  0.52925
 2.00E-03  -2.621   4640.  3.704 -0.279 0.50  0.55173
 5.00E-03  -2.233   4720.  3.919 -0.070 0.50  0.58792
 1.00E-02  -1.939   4800.  4.083  0.094 0.50  0.62415
 2.00E-02  -1.645   4900.  4.245  0.266 0.65  0.66867
 5.00E-02  -1.256   5080.  4.460  0.504 0.85  0.74558
 1.00E-01  -0.961   5260.  4.622  0.705 1.00  0.81447
 2.50E-01  -0.571   5560.  4.830  1.002 1.25  0.89163
 4.00E-01  -0.371   5850.  4.926  1.251 1.40  0.99911
 7.00E-01  -0.133   6260.  5.022  1.613 1.50  1.13453
 1.00E+00   0.019   6570.  5.070  1.879 1.60  1.22581
 1.50E+00   0.191   6880.  5.114  2.140 1.70  1.17659
 2.00E+00   0.312   7160.  5.140  2.363 1.80  1.13964
 4.00E+00   0.597   7920.  5.191  2.889 1.80  0.70033
 6.00E+00   0.761   8250.  5.213  3.092 1.80 -0.46595
 8.00E+00   0.877   8420.  5.229  3.196 1.80 -1.99552
 1.00E+01   0.967   8500.  5.242  3.245 1.80 -3.76404
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsubsection{Recommendations for Standard File Structure}

The very first entry in an UIO file is always the \verb|fileform uio| entry,
containing information about the file format and conversion type.
Afterwards, entries can follow in any order.
But it is perhaps a good idea to start the file with three special entries
(\verb|file_id|, \verb|description|, \verb|history|) as in

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=formatted convert=ieee_4 ...             

character file_id f=A80 b=80 n='File identification'                            
uio-demofile

character description d=(1:2) f=A80 p=1 b=80 n='File description'               
This is a file to demonstrate the recommended start entries for all
UIO files.

character history d=(1:1) f=A80 p=1 b=80 n='File history'
UIO demo file: 22-Dec-1997 14:15:15
\end{alltt}}}

A recommended format for sets of multi-dimensional arrays (e.g.\ hydrodynamics:
x-axis, y-axis, z-axis, density, velocities, energy, \ldots) is shown in
Sect.~\ref{s:modelfiles}.


%--------------------------------------------------------------------------------------------------
\subsection{Files \& Directories \& Paths}

All UIO-routines are located in subdirectories of a common directory (called
e.g.\ \verb|uio|), which also contains a Readme file.
The subdirectories and their contents are \\
\verb|bin     |: shell scripts: \verb|uiolook|, \verb|uiocat|, \verb|uioinfo| \\
\verb|f90     |: Fortran90 source codes, object files, executables \\
\verb|idl     |: IDL routines \\
\verb|man/man1|: manual pages for shell scripts: \verb|uiolook|, \verb|uiocat|, \verb|uioinfo| \\
\verb|tex     |: old description files in \LaTeX, the most recent version is part of this document \\

To use the UNIX scripts and the makefile
you need a global system variable {\bf UIOPATH} pointing to this directory.
The path to the shell scripts and to the man-pages should be added to your
shell path variables e.g. in one of the login scripts:

\mbox{ }

\noindent C-shell (\verb|.cshrc|):

{\color{DEFcolor}{\small\color{SHcolor}\begin{alltt}
# --- uio ---
setenv UIOPATH "${HOME}/uio"
setenv PATH "${PATH}:${UIOPATH}/bin"
setenv MANPATH "${MANPATH}:${UIOPATH}/man"
# --- *** ---
\end{alltt}}}

\noindent Korn-shell (\verb|.kshrc|):

{\color{DEFcolor}{\small\color{SHcolor}\begin{alltt}
# --- uio ---
UIOPATH=$HOME/uio
export UIOPATH
PATH=$PATH:$UIOPATH/bin
export PATH
MANPATH=$MANPATH:$UIOPATH/man
export MANPATH
# --- *** ---
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsection{Fortran90}\index{UIO!Fortran}\index{Fortran}


%--------------------------------------------------------------------------------------------------
\subsubsection{Files}

The Fortran UIO package is a collection of Fortran90 modules and programs described in
Table~\ref{t:uiofortranfiles}.

\begin{table}[hbt]
 \begin{center}
  \begin{tabular}{|ll|} \hline
File                              & contents \\ \hline
\verb|uio_base_module.f90|        & Collection of basic modules \\
\verb|uio_mac_module.f90|         & (Possibly) machine dependent routines \\
                                  & Standard version (all machines) \\
\verb|uio_mac_ieee_module.f90|    & Machine dependent routines: IEEE format \\
\verb|uio_mac_sun_module.f90|     & Machine dependent routines: Sun, SGI, Linux, HP \\
\verb|uio_mac_intel_module.f90|   & Machine dependent routines: Linux Intel (\verb|little_endian|) \\
\verb|uio_mac_crayts_module.f90|  & Machine dependent routines: CRAY \\
\verb|uio_mac_crayxmp_module.f90| & Machine dependent routines: CRAY \\
\verb|uio_mac_decalpha_module.f90|& Machine dependent routines: alpha \\
\verb|uio_mac_hitachi_module.f90| & Machine dependent routines: Hitachi \\
\verb|uio_bulk_module.f90|        & Main part of UIO routines \\
\verb|uio_filedef_module.f90|     & Standard file descriptors and labels \\ \hline
\verb|uio_table_module.f90|       & Table manipulation routines \\ \hline
\verb|uio_var_module.f90|         & definition and handling of UIO flexible variable \\
\verb|uio_varfile_module.f90|     & definition and handling of file structure of \\
                                  & UIO flexible variables \\ \hline
\verb|uiocop.f90|                 & Program to copy and transform UIO files \\
\verb|uiolok.f90|                 & Program to look into UIO files \\
\verb|uioinf.f90|                 & Program to give information about conversion types \\
\verb|uiotst.f90|                 & Program to produce test UIO file \\ \hline
  \end{tabular}
\caption[UIO Fortran90 files]{UIO Fortran90 files
}\label{t:uiofortranfiles}
 \end{center}
\end{table}

The file \verb|uio_base_module.f90| contains the basic set of modules
(see Table~\ref{t:uiobasemodulef90}).

\begin{table}[hbt]
 \begin{center}
  \begin{tabular}{|ll|} \hline
module            & contents \\ \hline
uio\_cst\_module  & channel status information \\
uio\_cvl\_module  & convert type list of current machine \\
uio\_inf\_module  & information about environment \\
uio\_nam\_module  & definition of names \\
uio\_siz\_module  & string length, table size \\
uio\_base\_module & basic set of UIO-routines: string processing, \\
                  & header handling, I/O channel management \\ \hline
  \end{tabular}
\caption[Contents of uio\_base\_module.f90]{Contents of
uio\_base\_module.f90
}\label{t:uiobasemodulef90}
 \end{center}
\end{table}

The files \verb|uio_mac*_module.f90| (Tab.~\ref{t:uiofortranfiles})
contain machine dependent
routines collected in the module uio\_mac\_module\index{UIO!uiomacmodule@\verb/uio_mac_module/}
(see Tab.~\ref{t:uiomacmodule}).

\begin{table}[hbt]
 \begin{center}
  \begin{tabular}{|ll|} \hline
routine     & purpose \\ \hline
uio\_getenv & Get information about environment \\
uio\_mkcvls & Make list with possible conversion types \\
uio\_uopen  & Open file with special handling for conversion type \\
uio\_uclose & Close file with special handling for conversion type \\ \hline
  \end{tabular}
\caption[Contents of uio\_mac\_module]{Contents of
uio\_mac\_module
}\label{t:uiomacmodule}
 \end{center}
\end{table}

It comes in various flavors.
The machine-independent version is
\verb|uio_mac_module.f90|
which can be used for first tests but does not provide all possible features.
Therefore, it should be discarded afterwards and replaced by a version more
suitable for the platform in use.
The file
\verb|uio_mac_ieee_module.f90|
is appropriate for all machines with IEEE \verb|big_endian|\index{bigendian@\verb/big_endian/}
binary format.
Additionally there exist files containing calls of machine library routines \\
\verb|uio_mac_crayts_module.f90|,
\verb|uio_mac_crayxmp_module.f90|,
\verb|uio_mac_sun_module.f90|.
These make it possible to write information about the platform in use into the
file header. The CRAY versions allow unformatted I/O in the CRAY specific
format and additionally (via the FFIO ASSIGN logic) in IEEE format.
The file
\verb|uio_mac_intel_module.f90|
is appropriate for all machines with IEEE \verb|little_endian|\index{littleendian@\verb/little_endian/}
binary format (and no mechanism for automatic conversion).

The main set of routines is contained in \verb|uio_bulk_module.f90| in the
module uio\_bulk\_module.

The three files \verb|uio_base_module.f90|, \verb|uio_mac_module.f90|, and
\verb|uio_bulk_module.f90| comprise the standard set of UIO routines.

Additionally there exists a file \verb|uio_table_module.f90| with the single
module uio\_table\_module
which permits the I/O and manipulation of a certain table format (see the
example in section~\ref{s:fileexample}).

The latest extension comes within the modules
\verb|uio_var_module.f90| and \verb|uio_varfile_module.f90|.
The module \verb|uio_var_module.f90| contains a type definition for a variable
(``uio flexible variable'')
of general type (i.e.\ it may be a scalar integer value or a 1D character
array or a 3D real array\ldots) together with some routines for the
basic handling of the variables
(I/O in UIO format, construction and modification of variables\ldots).
The module \verb|uio_varfile_module.f90| contains a type definition for
a file built of UIO flexible variables together with routines for the handling
of these files.


%--------------------------------------------------------------------------------------------------
\subsubsection{Use of UIO Modules in Fortran90}

To make the UIO routines available in a Fortran program
the appropriate modules have to be specified in a \verb|USE| statement.

At maximum five modules play a role:
The \verb|uio_bulk_module| contains the main part of the UIO routines
(and also uses the relevant sub-modules). 
Instead of \verb|uio_bulk_module| the module \verb|uio_table_module| is used
if the UIO table routines are needed.
The modules \verb|uio_siz_module| and \verb|uio_nam_module| contain
specifications about the size of some arrays and the length of strings, and
the names of types and keywords, respectively.
The module \verb|uio_filedef_module| contains some definitions in addition to
the basic UIO standard as e.g.\ the label names which delimit a data set
(\verb|label dataset| and \verb|label enddataset|).

A typical case for the use of UIO modules is

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
use uio_bulk_module
use uio_siz_module
use uio_nam_module
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsubsection{Compiling and Makefiles}\index{makefile!UIO}\index{UIO!makefile}

There is a Makefile for the UIO routines.
For a certain platform it is necessary to change the name of the module
file with the machine dependent routines (\verb|uio_mac*_module.f90|).
For this purpose the environment variable \verb|UIOMAC| has to set to
name of the appropriate routine (see Sect.~\ref{s:directorystructure}).
Many compilers generate module information files with suffixes like
\verb|.M|, \verb|.mod|, or \verb|.kmo|. To clean up information files with
other suffixes, they have to be included in the cleaning step.

Calling examples:

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
make
make UIO
make UIO "F90FLAGS=-g"
make clean
make cleanall
make remove
make removeall
\end{alltt}}}

A section of a typical makefile using the UIO routines may be

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
...
# --- Compiler options ---
F90C=f90
F90FLAGS=
# --- Libraries ---
UIOMAC=uio_mac_sun_module
...
# --- Dependencies of exe-files on object files and libraries ---
test.exe: test.o
        $(F90C) $(F90FLAGS) -o ${@} \
          $(UIOPATH)/f90/uio_base_module.o $(UIOPATH)/f90/$(UIOMAC).o \
          $(UIOPATH)/f90/uio_bulk_module.o

test.o: $(UIOPATH)/f90/UIO test.f90
        $(F90C) -c $(F90FLAGS) \
          -M$(UIOPATH)/f90 \
        test.f90
...
# --- Dependencies on used modules ---
$(UIOPATH)/f90/UIO:
        cd ${UIOPATH}/f90 ; make UIO "F90FLAGS=${F90FLAGS}"
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsubsection{Sample Calls of Fortran UIO Routines}

The needed modules have to be declared by a \verb|use| statement like:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
use uio_bulk_module
\end{alltt}}}

In the initial phase of the program the UIO routine package has to
initialized by exactly one call of the \verb|uio_init| routine with the name
of the program as optional parameter:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
call uio_init(progrm='uiotst')
\end{alltt}}}

The internal list of logical I/O unit numbers may be changed with
calls of \verb|uio_chunit| and \verb|uio_chconv|.

A file can be opened for writing with

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
file='test.txt'
form='formatted'   ! or: 'unformatted'
conv='ieee_4'      ! or: 'native', 'crayxmp_8',...
call uio_openwr(ncout, file, form=form,conv=conv)
\end{alltt}}}

Header and data block are written together with one command as e.g.\ in:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
call uio_wr(ncout, time,       'time', name='time',    unit='s'     )
call uio_wr(ncout, rho(1:10),  'rho',  name='density', unit='g/cm^3')
\end{alltt}}}

There are two different routines to close a file after reading or writing.
A file opened for writing is closed by:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
call uio_closwr(ncout)
\end{alltt}}}


To open a file for reading, only the file name has to specified. File form
and conversion type are determined automatically:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
file='test.txt'
call uio_openrd(ncin, file)
\end{alltt}}}


In contrast to the writing of an entry by one routine call the reading is
performed in two separate sub-steps for the header and the data part.
After the reading of the header e.g.\ with

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
use uio_siz_module
use uio_nam_module
...
integer                                 :: ntt
character*(let)                         :: termt(2,nttmx)
...
call uio_rdhd(ncin, termt,ntt)
\end{alltt}}}

the identifier, type, and dimension (if any)
of the entry is contained in the character array \verb|termt| with \verb|ntt| entries
and special actions may be taken: The data part may be skipped with

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
uio_skipda(ncin, termt,ntt)
\end{alltt}}}

or it can be read with:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
call uio_rd(ncin, termt,ntt, time, ident)
\end{alltt}}}


If the entry is an array it may be necessary to allocate memory:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
call uio_exkeyw(termt,ntt,  dimna,dimstr)
call uio_st2dim(dimstr, ilow, iup, ndim=ndim)
allocate(rho(ilow(1):iup(1)))
call uio_rd(ncin, termt,ntt, rho, ident, ilb=ilow(1:1))
\end{alltt}}}

Alternatively, it is possible to search in the file for a special entry or
to search in a specially generated entry list with:

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
call uio_srhd(ncin, termt,ntt, type='real',ident='rho',outstr=outstr,ierr=ierr)
\end{alltt}}}

Additionally, the module \verb|uio_var_module| makes it possible to read any
entry into an UIO flexible variable,
and the module \verb|uio_varfile_module| allows the reading of a complete file
into a special file structure of UIO flexible variables.

To close file after reading use

{\color{DEFcolor}{\small\color{F90color}\begin{alltt}
uio_closrd(ncin)
\end{alltt}}}

There are several examples of programs with UIO routines like
\verb|uio_var_test.f90|,
\verb|uio_varfile_test.f90|,
\verb|uiotst.f90|,
(\verb|uio_demo.f90|).


%--------------------------------------------------------------------------------------------------
\subsection{UNIX Scripts\label{s:uioscripts}}\index{UIO!Unix scripts}

So far, there exist three UNIX shell scripts useful
to quickly examine data sets (\verb|uiolook|),
to change the format or conversion type of files (\verb|uiocat|),
or to print some information about the conversion types possible on the local
machine (\verb|uioinfo|).


%--------------------------------------------------------------------------------------------------
\subsubsection{Quick Examination of Files: uiolook\label{s:uiolook}}\index{uiolook@\verb/uiolook/}

The shell script \verb|uiolook| calls the Fortran program \verb|uiolok.f90|. The man-page:

{\color{DEFcolor}{\small\color{MANcolor}\begin{alltt}
UIOLOOK(1V)       Misc. Reference Manual Pages        UIOLOOK(1V)

NAME
     uiolook - print entry headers of file in uio form

SYNOPSIS
     uiolook [ -h ] [ -p ] [ filename ...  ]

AVAILABILITY

DESCRIPTION
     The routine uiolook reads each filename (file in  uio  form)
     in  sequence  and  displays  the  headers  of the entries in
     pretty form.

OPTIONS
     -h    Print usage of uiolook.

     -p    Entry header keywords in (long) pretty form

SunOS 5.5.1       Last change: 27 November 1996                 1
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsubsection{Transformation of Files: uiocat}\index{uiocat@\verb/uiocat/}

The shell script \verb|uiocat| calls the Fortran program \verb|uiocat.f90|. The man-page:

{\color{DEFcolor}{\small\color{MANcolor}\begin{alltt}
UIOCAT(1V)        Misc. Reference Manual Pages         UIOCAT(1V)

NAME
     uiocat - concatenate file(s) in uio form

SYNOPSIS
     uiocat [ -c conversion ] [ -f format ] [ -h ] [ -l  copylist
     ] [ -o outputfilename ] [ filename ...  ]

DESCRIPTION
     The routine uiocat reads each filename (file in uio form) in
     sequence  and  displays  its  contents formatted on standard
     output or writes it into a file.  In  the  latter  case  the
     format  change  from  'formatted'  to  'unformatted' or vice
     versa is possible.

OPTIONS
     -c    Conversion  type:  'native',  'ieee_4',  ...  (machine
          dependent),  its  specification is only relevant, if an
          output file is specified with the -o option and  output
          format='unformatted'.

     -f    Output  format:  'formatted'  or  'unformatted'.   Its
          specification  is  only  relevant, if an output file is
          specified with the -o option.

     -h    Help: print usage of uiocat.

     -l    List of entries to be copied. E.g.
            uiocat ... -l"real rho"
            uiocat ... -l"real rho,integer i"
            uiocat ... -l"label *,real rho,integer i"
            uiocat ... -l"label *,real rho,* i"
            Here, copylist is a list, separated by ",". Each item
          consists of exactly two items, separated by a blank. No
          additional blanks are allowed.  Use copylist with "" as
          above.

     -o    Output file name. If omitted, standard output is  used
          and "-c" and "-f" are meaningless.

SunOS 5.5.1       Last change: 12 January 1998                  1
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsubsection{Information about Conversion Types: uioinfo}\index{uioinfo@\verb/uioinfo/}

The shell script \verb|uioinfo| calls the Fortran program \verb|uioinf.f90|. The man-page:

{\color{DEFcolor}{\small\color{MANcolor}\begin{alltt}
uioinfo(1V)       Misc. Reference Manual Pages        uioinfo(1V)

NAME
     uioinfo - print machine dependent information

SYNOPSIS
     uioinfo

DESCRIPTION
     The routine uioinfo prints information about its environment
     and a list of possible conversion types.

OPTIONS

SunOS 5.5.1       Last change: 12 January 1998                  1
\end{alltt}}}


%--------------------------------------------------------------------------------------------------
\subsection{IDL UIO Routines\label{s:IDLUIOroutines}}\index{IDL!UIO routines}\index{UIO!IDL}

The UIO package in IDL comes as a list of routines with names quite similar to
the Fortran90 version. Instead of using global variables as in Fortran90
there are now common blocks in Include-files.

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
;******************************************************************************
; Routines, functions : uio_*.pro:
;               (!: most important, +: user-routine, -: comfortable, .:useful) 
; . adkey1:     Add one keyword to term table, keyword-value=' ', no link character
; . adkey2:     Add one keyword to term table with keyword-value
; . adkey3:     Add one keyword to term table with keyword-value or default
; . chconv:     Actualize list of conversion types for all channels
; + chpos:      Give current file position or jump to specified position
; . chunit:     Initialize, store and actualize a list of free and occupied unit
;               numbers
; + closrd:     Close file after reading
; + closwr:     Close file after writing
; - cpentr:     Copy entry from one file to another
; + d:          Read data from uio-file(s) in quasi direct access mode
; + data:       Handle uio-file(s) in quasi direct access mode
; ! dataset_rd: Read uio file and put data into anonymous structure
; ! uio_datasetlist_rd: Read data from list of files and put it into an. structure
;   deform:     Determine the default output format for numbers
;   dim2st:     Compose dimension string
; . exkeyw:     Extract value of keyword from table
;   ex1trm:     Extract one term from the input line
;   exmtrm:     Transform a list of items into its components
; . filcon:     Determine file contents: list of all entries with its positions
;   getenv:     Get information about environment
; ! init:       Initialization procedure for input/output routines
;   me1trm:     Merge the input term: 'keyword', 'value' -> 'keyword=value'
;   memtrm:     Merge a list of terms (keywords and their values) into a line table
;   mkcvls:     Make list with possible conversion types
; . nc2nt:      From column number or entry name find table entry number
; + openrd:     Open file for reading, read header
; + openwr:     Open file for writing, write header
; - pptrmt:     Print term table in pretty form
;   qmaadd:     Transform a string into a string with quotation marks if necessary
;   qmadel:     Parse string "inline" and remove quotation marks if necessary
; + rd:         Reading scalar and array data of all types
; . rdfifo:     Read file header
; + rdhdex:     Read header of variable and extract keywords
;   rdhead:     Read header
; + rdlabl:     Read label
; + rdtab:      Read table of integer, real, and/or character data from file
; + skipda:     Skip data block
; - slhdex:     Search header of variables given by list and extract keywords
; . st2dim:     Parse dimension string
; ! struct_rd:  Read uio file and put data into anonymous structure
; . tab0:       Create empty table structure
; + tabc:       Change and modify table contents: rearrange lines.
; + tabm:       Merge two tables in different ways
; + tabr:       Read 1d array from 2d table array (all types)
; + tabw:       Write 1d array into table (all types)
;   uclose:     Close file with special handling for conversion type
;   uopen:      Open file with special handling for conversion type
;   vnanrm:     Transform a string to give a correct name of a variable
;   wf2rf:      Produce from write format string corresponding read format string
; + wr:         Writing scalar and array data of all types
; . wrfifo:     Write file header
;   wrhdme:     Write header of variable, input: term table.
;   wrhead:     Write header of variable, input: line table.
; + wrlabl:     Write label
; + wrtab:      Write table of integer, real, and/or character data to file
;******************************************************************************
; Include-Files uio_*.pro:
;   filedefinc: 
;   uiocstinc:  channel status information (common uio_chainf)
;   uiocvlinc:  convert type list of current machine (common uio_cvlist)
;   uionaminc:  names of types, keywords, identifiers; default formats
;               (common uio_defnam)
;   uiosizinc:  length of strings, size of tables (trmtab, lintab)
;   uiotabinc:  empty table structure (common uio_taborg)
;******************************************************************************
\end{alltt}}}

Most of the routines are low-level ones and do not have to be worried about
because they rarely will be used directly.

For accessing data in UIO format within IDL
the initialization routine \verb|uio_init| (see Sect.~\ref{s:uio_init})
and the high-level reading routines (\verb|uio_struct_rd.pro|, \verb|uio_dataset_rd.pro|, and
\verb|uio_datasetlist_rd.pro|, see Sect.~\ref{s:uio_dataset_rd}).
might suffice.


%--------------------------------------------------------------------------------------------------
\subsubsection{Initialization of UIO Routines under IDL\label{s:uio_init}}\index{IDL!uioinit@\verb/uio_init/}\index{uioinit@\verb/uio_init/}

The directory containing the IDL UIO routines should be added to the
IDL variable !PATH.
This could be done by a program segment in the startup procedure, like:

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
; --- Try to determine language ---
if (n_elements(!X.TICKV) eq 150) then langua='WAVE' else langua='IDL'
;
; --- Add user IDL directory to search path ---
if (langua eq 'IDL') then begin &$
  addpath=expand_path('+$UIOPATH/idl') &$
endif else begin &$
  addpath='/home/supas024/uio/idl' + ':' + '/home/supas024/wave' &$
endelse
if strtrim(addpath,2) ne '' then !path=addpath+':'+!path
delvar, addpath
\end{alltt}}}

Alternatively, one might want to set the IDL path variable accordingly like

{\color{DEFcolor}{\small\color{SHcolor}\begin{alltt}
export IDL_PATH="+${UIOPATH}/idl"
\end{alltt}}}

\noindent for example in the \verb|.bashrc| file.

It is reasonable to include the UIO initialization in the startup procedure
as e.g.:

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
; --- Initialize uio-routines ---
uio_init, progrm='by hand'
\end{alltt}}}

IDL can handle the conversion types
\verb|native|, \verb|ieee_4|, \verb|ieeele_4|, \verb|ieee|, \verb|idl|, \verb|xdr|
(compare Tab.~\ref{t:conversiontypes} in Sect~\ref{s:UIO_data_representation}).
Here, \verb|ieee_4| is the default and should be used as a standard.

{\bf Attention}: The IDL type ``long'' corresponds to the standard Fortran type
``integer''. The IDL types ``byte'' and ``integer'' are not known in standard
Fortran and are therefore transformed to the IDL type ``long'' before writing
(in the IDL routine \verb|uio_wr|).

{\bf Be aware of}: The parsing and interpretation of the entry headers can only
be done by scalar operations which are comparatively slow in IDL.


%--------------------------------------------------------------------------------------------------
\subsubsection{Reading Data with uio\_data.pro}\index{IDL!uiodata@\verb/uio_data/}


The IDL routine \verb|uio_data| and the IDL function \verb|uio_d| were
the first set of ``high-level'' routines to read UIO data in IDL.
They were useful for the easy reading of not too complex data files.
By now, they are replaced by the routines \verb|uio_struct_rd|
and \verb|uio_dataset_rd| (see see next Section and Sect~\ref{s:IDL}).

The old routines allow the opening,

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  uio_data, mode='open', filename='model.dat'
  uio_data, mode='open', filename='model*.txt'
  uio_data, mode='open', filename='model.dat', family='mod1'
  uio_data, mode='open', filename='model*.txt', family='mod2'
\end{alltt}}}

\noindent examination,

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  uio_data, mode='content'
  uio_data, mode='files'
\end{alltt}}}

\noindent reading,

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  uio_data, mode='read', value=rho, 'rho'
  uio_data, value=temp, 'temp'
  uio_data, value=p, 'p', filename='model.dat'
  uio_data, value=p, 'p', family='mod1'
  plot_oi, uio_d('p'), uio_d('t')
\end{alltt}}}

\noindent and closing,

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  uio_data, mode='close', filename='model.dat'
  uio_data, mode='close', filename='model*.txt'
  uio_data, mode='close', family='mod2'
  uio_data, mode='allclose'
\end{alltt}}}

\noindent of UIO files.


%--------------------------------------------------------------------------------------------------
\subsubsection{Reading Data with uio\_dataset\_rd.pro or uio\_datasetlist\_rd.pro\label{s:uio_dataset_rd}}
  \index{IDL!uiodatasetrd@\verb/uio_dataset_rd/}

For a detailed description of how to handle UIO files in IDL see Sect~\ref{s:IDL}.

With the new IDL routines \verb|uio_struct_rd.pro|, \verb|uio_dataset_rd.pro|, and
\verb|uio_datasetlist_rd.pro|
files are not read entry by entry anymore but in larger blocks (or ``data sets'').

With \verb|uio_struct_rd|\index{uiostructrd@\verb/uio_struct_rd/}
all entries in a file are read and put into an
IDL structure variable. This is appropriate for the CO5BOLD parameter file\index{rhd.par!reading in IDL}
or for the UIO table file in Sect.~\ref{s:uiotables}, e.g.

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  par=uio_struct_rd('st35gm04n05_03.par')
  atm=uio_struct_rd('holmu.atm')
\end{alltt}}}

When groups of entries in an UIO file are properly marked with
\verb|label dataset| and \verb|label enddataset| delimiters
(confer the example in Sect.~\ref{s:modelfiles})
each group can be accessed with \verb|uio_dataset_rd|\index{uiodatasetrd@\verb/uio_dataset_rd/}.
The first block can be read with

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  ful=uio_dataset_rd('st35gm04n05_03.full')
\end{alltt}}}

\noindent or

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  ful=uio_dataset_rd('st35gm04n05_03.full', ndataset=0)
\end{alltt}}}

\noindent Dataset number \verb|i+1| (counting starts at zero) can be read with

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  ful=uio_dataset_rd('st35gm04n05_03.full', ndataset=i)
\end{alltt}}}

If a dataset with that number does not exist, an empty structure is returned.
In this case, when called with additional keywords like

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
  ful=uio_dataset_rd('st35gm04n05_03.full', ndataset=i, outstr=outstr,ierr=ierr)
\end{alltt}}}

\noindent an error message is returned in \verb|outstr| and \verb|ierr| is set to a value
larger than $0$.

To read all entries in a list of files in sequence the routine
\verb|uio_datasetlist_rd.pro|\index{IDL!uiodatasetlistrd@\verb/uio_datasetlist_rd/}\index{uiodatasetlistrd@\verb/uio_datasetlist_rd/}
is convenient, as in

{\color{DEFcolor}{\small\color{IDLcolor}\begin{alltt}
model='st33gm06n03' & modelident='_??' & parmodelident='_01'
modeldisk=getenv('HOME') + '/dat/rhd/d' + model + '/'
;
modelfile=modeldisk + model + modelident    + '.full'
parfile  =modeldisk + model + parmodelident + '.par'
;
; --- Read parameter file ---
par=uio_struct_rd(parfile)
;
; --- Open first dataset to get some information about array sizes ---
delvar, listdata
ful=uio_datasetlist_rd(modelfile, listdata=listdata, ierr=ierr)
uio_closrd, listdata.channel
delvar, listdata
;
nxc1=n_elements(ful.z.xc1)
nxc2=n_elements(ful.z.xc2)
nxc3=n_elements(ful.z.xc3)
;
n_timestep=1000  ; --- Some huge value to get everything. Reduce for tests! ---
ierr=0
i=0
;
; --- Loop over all datasets ---
while ((ierr eq 0) and (i lt n_timestep)) do begin &$
  ; --- Read the next dataset ---
  ful=uio_datasetlist_rd(modelfile, listdata=listdata, ierr=ierr) &$
  if (ierr eq 0) then begin &$
    print, '--- ', i, ful.z.itime, ful.z.time, format='(A,I4,I6,E15.8)' &$
    ;
    ; --- Now do the data handling (demo) ---
    print, 'Mean density: ', avg(ful.z.rho) &$
    ;
    i=i+1 &$
  endif &$
endwhile
\end{alltt}}}

\noindent Note that you can specify an entire group of files with \verb|modelident='_??'|.

\index{UIO|)}


\clearpage
%==================================================================================================
\section{Control and Data Files}

Table~\ref{t:allfiles} shows a list of all files necessary to run CO5BOLD.
Figure~\ref{f:prgscheme} gives similar information but is not quite up to date.
Executing the makefile produces an executable \verb|rhd.exe|.
Its name can of course be changed afterwards.
The names of the three control files \verb|rhd.par|, \verb|rhd.stop|, and \verb|rhd.cont|
and of the status file \verb|rhd.done|
cannot be changed (without modification of the source code).
The names of EOS, opacity, and CO5BOLD data files can be chosen freely in the
parameter file \verb|rhd.par|.\index{rhd.par}
Table~\ref{t:allfiles} only contains dummy names.

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|lccll|} \hline
File            & Sect.             & {\negsp}I/O\negsp & Type              & Description \\ \hline
\verb|rhd.exe|  & \ref{s:rhd.exe}   &     & executable              & main program \\ \hline
\verb|rhd.par|  & \ref{s:rhd.par}   &  I  & control/data: UIO\negsp\negsp & central control file \\
\verb|rhd.stop| & \ref{s:rhd.stop}  &  I  & control                 & file to force controlled stop of simulation \\
\verb|rhd.cont| & \ref{s:rhd.cont}  &  I  & control                 & file to force continuation after stop \\ \hline
\verb|data.eos| &                   &  I  & data: UIO               & tabulated equation of state \\
\verb|data.opta|\negsp &            &  I  & data                    & tabulated opacities         \\ \hline
\verb|rhd.sta|  &\ref{s:modelfiles} &  I  & data: UIO               & start model (e.g.\ end file of last run) \\
\verb|rhd.done| & \ref{s:rhd.done}  &  O  & status                  & exit status: written if run was successful \\
\verb|rhd.end|  &\ref{s:modelfiles} &  O  & data: UIO               & end model \\
\verb|rhd.full| &\ref{s:modelfiles} &  O  & data: UIO               & sequence of (2D or 3D) snapshots, large \\
\verb|rhd.mean| & \ref{s:meanfiles} &  O  & data: UIO               & derived data: mean flux, intensity \\
\verb|rhd.out|  & \ref{s:rhd.out}   &  O  & data: text              & human readable text output \\ \hline
  \end{tabular} 
  \caption[CO5BOLD control and data files]{List of all control and data files of CO5BOLD
     }\label{t:allfiles}
 \end{center}
\end{table}


%--------------------------------------------------------------------------------------------------
\subsection{Model Files: rhd.sta, rhd.end, rhd.full\label{s:modelfiles}}
  \index{output!full data sets}

If the UIO scripts (Sect.~\ref{s:uioscripts}) are properly installed,
you can view the contents (more precisely the headers of the data entries) of an UIO file
with \verb|uiolook filename|, e.g.\

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
uiolook st35gm04n05_03.end
\end{alltt}}}

\noindent gives the output (slightly edited)

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=unformatted convert=ieee_4 version=0.1.2000.11.26 &           
  date='02.01.2002 16:17:26.036' system=craSHi machine=craSHi osrelease=10.0.0.6 &
  osversion=UoK.4 hardware='CRAY SV1' language=Fortran90 program=RHD              

character file_id f=A8 b=8 n='File identification'                              
character description d=(1:1) f=A24 p=1 b=24 n='File description'               
character history d=(1:20) f=A80 p=1 b=80 n='File history'                      
character version f=A80 b=80 n='Program version'                                

label dataset n='RHD model' date='02.01.2002 16:17:26.043'                      
  character dataset_id f=A10 b=10 n='Type of box hierarchy'                       
  real modeltime f=E13.6 b=4 n=time u=s                                           
  integer modelitime f=I11 b=4 n='time step number' u=1                           
  real dtime f=E13.6 b=4 n='time step' u=s                                        
  real time_out_full_last f=E13.6 b=4 n='Time of last output of full model' u=s   
  real time_out_mean_last f=E13.6 b=4 n='Time of last output of averaged data' &  
    u=s                                                                             
  label box date='02.01.2002 16:17:26.049'                                        
    character box_id f=A80 b=80 n='Block identification'                            
    integer dimension d=(1:2,1:3) f=I7 p=6 b=4                                      
    real time f=E13.6 b=4 n=time u=s                                                
    integer itime f=I11 b=4 n='time step number' u=1                                
    real xc1 d=(-63:63,-63:-63,-63:-63) f=E13.6 p=4 b=4 &                           
    n='x1 coordinates of cell centers' u=cm ds=(0:0,0:1,0:1)                        
    real xc2 d=(-63:-63,-63:63,-63:-63) f=E13.6 p=4 b=4 &                           
      n='x2 coordinates of cell centers' u=cm ds=(0:1,0:0,0:1)                        
    real xc3 d=(-63:-63,-63:-63,-63:63) f=E13.6 p=4 b=4 &                           
      n='x3 coordinates of cell centers' u=cm ds=(0:1,0:1,0:0)                        
    real xb1 d=(-63:64,-63:-63,-63:-63) f=E13.6 p=4 b=4 &                           
      n='x1 coordinates of cell boundaries' u=cm ds=(0:1,0:1,0:1)                     
    real xb2 d=(-63:-63,-63:64,-63:-63) f=E13.6 p=4 b=4 &                           
      n='x2 coordinates of cell boundaries' u=cm ds=(0:1,0:1,0:1)                     
    real xb3 d=(-63:-63,-63:-63,-63:64) f=E13.6 p=4 b=4 &                           
      n='x3 coordinates of cell boundaries' u=cm ds=(0:1,0:1,0:1)                     
    real rho d=(-63:63,-63:63,-63:63) f=E13.6 p=4 b=4 n=Density u=g/cm^3            
    real ei d=(-63:63,-63:63,-63:63) f=E13.6 p=4 b=4 n='Internal energy' u=erg/g    
    real v1 d=(-63:63,-63:63,-63:63) f=E13.6 p=4 b=4 n='Velocity 1' u=cm/s          
    real v2 d=(-63:63,-63:63,-63:63) f=E13.6 p=4 b=4 n='Velocity 2' u=cm/s          
    real v3 d=(-63:63,-63:63,-63:63) f=E13.6 p=4 b=4 n='Velocity 3' u=cm/s          
  label endbox                                                                    
label enddataset date='02.01.2002 16:17:43.322'
\end{alltt}}}

The UIO format is described in some detail in Sect~\ref{s:uio}.
Each entry has a type (e.g.\ ``\verb|label|'', ``\verb|real|'', ``\verb|character|''),
an identifier (e.g.\ ``\verb|box|'', ``\verb|time|'', ``\verb|description|''),
and additional information about array size (e.g. ``\verb|d=(-63:63,-63:63,-63:63)|''),
data format (e.g.\ ``\verb|f=E13.6 p=4 b=4|''),
and properties of the quantity (e.g.\ ``\verb|n=Density u=g/cm^3|'').

Each start (``\verb|rhd.sta|'') or final (``\verb|rhd.end|'') model file has a structure
as shown above. The (``\verb|rhd.full|'') file usually contains a sequence of these
data sets, which of course can also be used as start model of a simulation.

The axes \verb|xc1|\index{xc1@\verb/xc1/},
\verb|xc2|\index{xc2@\verb/xc2/},
and \verb|xc3|\index{xc3@\verb/xc3/} describe the positions of the cell centers.
The axes \verb|xb1|\index{xb1@\verb/xb1/},
\verb|xb2|\index{xb2@\verb/xb2/},
and \verb|xb3|\index{xb3@\verb/xb3/} contain the positions of the cell boundaries:
they have one element more than the corresponding cell centered quantity.

Cell boundaries should be centered in the middle between cell centers for
the best representation of radiative fluxes with MSrad3D\index{MSrad!cell centering}.


%--------------------------------------------------------------------------------------------------
\subsection{File with Additional Data: rhd.mean\label{s:meanfiles}}
  \index{output!mean data}

A ``\verb|rhd.mean|'' file contains derived data (averaged fluxes\index{fluxes},
other averaged quantities, surface intensities)
in addition to the complete data sets in ``\verb|rhd.full|'' files. 
It has more entries than a full model file.
However, they are much smaller. Therefore, one can afford a higher output sampling rate.

Its format is usually Fortran ``unformatted'' (binary).


%--------------------------------------------------------------------------------------------------
\subsubsection{Organization of rhd.mean File}

A mean file usually consists of several datasets. The overall structure is

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=unformatted convert=ieee_4

character file_id f=A8 b=8 n='File identification'                              
character description d=(1:1) f=A14 p=2 b=14 n='File description'               
character history d=(1:20) f=A80 p=1 b=80 n='File history'                      
character version f=A80 b=80 n='Program version'                                

label dataset n='RHD model'
...
label enddataset

label dataset n='RHD model'
...
label enddataset
.
.
.
\end{alltt}}}

\noindent Each dataset has the following structure (for a supergiant simulation):

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
label dataset n='RHD model' date='25.05.2001 09:41:29.405'
...

label box date='25.05.2001 09:41:29.408'
character box_id f=A80 b=80 n='Block identification'
rad
...
label endbox

label box date='25.05.2001 09:41:29.983'
character box_id f=A2 b=2 n='Block identification'
z1
...
label endbox

label box date='25.05.2001 09:41:30.078'
character box_id f=A2 b=2 n='Block identification'
z2
...
label endbox

label box date='25.05.2001 09:41:30.170'
character box_id f=A2 b=2 n='Block identification'
z3
...
label endbox

label box date='25.05.2001 09:41:30.260'
character box_id f=A1 b=1 n='Block identification'
r
...
label endbox

label box date='25.05.2001 09:41:30.359'
character box_id f=A80 b=80 n='Block identification'
z
...
label endbox
label enddataset date='25.05.2001 09:41:30.489'
\end{alltt}}}

\noindent There a six sub-blocks delimited with \verb|box| and \verb|endbox| labels.
They contain
surface intensity and flux arrays (\verb|rad|),
averages in
the 23-plane (\verb|z1|),
the 13-plane (\verb|z2|),
the 12-plane (\verb|z3|),
and over spherical shells (\verb|r|),
and a 2D slice through the model (\verb|z|).


%--------------------------------------------------------------------------------------------------
\subsubsection{Contents of Individual rhd.mean File Entry}

An individual box inside a dataset entry in a mean file can have e.g.\ the
following contents describing horizontal averages in a plane-parallel model.
With

{\color{DEFcolor}{\color{SHcolor}\begin{alltt}
uiolook chro2D03co08_01.mean | less
\end{alltt}}}

\noindent you get this (and more):

{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
label box date='06.11.2002 17:58:05.533'
  character box_id f=A2 b=2 n='Block identification'
integer dimension d=(1:2,1:3) f=I7 p=6 b=4
real time f=E13.6 b=4                           n=time &
                                                u=s
integer itime f=I10 b=4                         n='time step number' &
                                                u=1
real xc1 d=(1:1,1:1,1:1) f=E13.6 p=4 b=4        n='x1 coordinates of cell centers' &
                                                u=cm &
        ds=(0:0,0:1,0:1)
real xc2 d=(1:1,1:1,1:1) f=E13.6 p=4 b=4        n='x2 coordinates of cell centers' &
                                                u=cm &
        ds=(0:1,0:0,0:1)
real xc3 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4      n='x3 coordinates of cell centers' &
                                                u=cm &
        ds=(0:1,0:1,0:0)
real xb1 d=(1:2,1:1,1:1) f=E13.6 p=4 b=4        n='x1 coordinates of cell boundaries' &
                                                u=cm &
        ds=(0:1,0:1,0:1)
real xb2 d=(1:1,1:2,1:1) f=E13.6 p=4 b=4        n='x2 coordinates of cell boundaries' &
                                                u=cm &
        ds=(0:1,0:1,0:1)
real xb3 d=(1:1,1:1,1:121) f=E13.6 p=4 b=4      n='x3 coordinates of cell boundaries' &
                                                u=cm &
        ds=(0:1,0:1,0:1)
real rho_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n=Density &
                                                u=g/cm^3
real v1_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Velocity x1' &
                                                u=cm/s
real v2_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Velocity x2' &
                                                u=cm/s
real v3_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Velocity x3' &
                                                u=cm/s
real v1_xmean2 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Velocity x1' &
                                                u=cm/s
real v2_xmean2 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Velocity x2' &
                                                u=cm/s
real v3_xmean2 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Velocity x3' &
                                                u=cm/s
real rhov1_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Mass Flux x1' &
                                                u=g/cm^2/s
real rhov2_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Mass Flux x2' &
                                                u=g/cm^2/s
real rhov3_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Mass Flux x3' &
                                                u=g/cm^2/s
real bc1_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Magnetic field 1' &
                                                u=G
real bc2_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Magnetic field 2' &
                                                u=G
real bc3_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Magnetic field 3' &
                                                u=G
real bc1_xmean2 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Magnetic field 1' &
                                                u=G
real bc2_xmean2 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Magnetic field 2' &
                                                u=G
real bc3_xmean2 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Magnetic field 3' &
                                                u=G
real ei_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 n='Internal energy' &
                                                u=erg/g
real rhoei_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Internal energy' &
                                                u=erg/cm^3
real rhoek_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Kinetic energy' &
                                                u=erg/cm^3
real rhoeg_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Gravitational energy' &
                                                u=erg/cm^3
real t_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4  n=Temperature &
                                                u=K
real t_xmean4 d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 n=Temperature &
                                                u=K
real t_xmeankapparho d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n=Temperature &
                                                u=K
real p_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4  n=Pressure &
                                                u=dyn/cm^2
real s_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4  n=Entropy &
                                                u=erg/K/g
real rhos_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n=Entropy &
                                                u=erg/K/cm^3
real gamma1_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='1st Adiabatic Coefficient' &
                                                u=1
real gamma3_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='3rd Adiabatic Coefficient' &
                                                u=1
real delta_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Expansion coefficient' &
                                                u=1
real kapparho_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Absorption Coefficient' &
                                                u=1/cm
real quc001_xmean d=(1:1,1:1,1:120) f=E13.6 p=4 b=4 &
                                                n='Number density of CO' &
                                                u=1/cm^3
rreal rhovb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Mass flux' &
                                                u=g/cm^ &
                ds=(0:0,0:0,0:1)
real frhov13b_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Momentum x1 flux x3 direction' &
                                                u=erg/cm^3 &
                   ds=(0:0,0:0,0:1)
real frhov23b_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Momentum x2 flux x3 direction' &
                                                u=erg/cm^3 &
                   ds=(0:0,0:0,0:1)
real frhov33b_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Momentum x3 flux x3 direction' &
                                                u=erg/cm^3 &
                   ds=(0:0,0:0,0:1)
real feipb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Enthalpy Flux' &
                                                u=erg/cm^2/s &
                ds=(0:0,0:0,0:1)
real fekb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Kinetic Energy Flux' &
                                                u=erg/cm^2/s &
               ds=(0:0,0:0,0:1)
real fegb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Gravitational Energy Flux' &
                                                u=erg/cm^2/s &
               ds=(0:0,0:0,0:1)
real fepb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Pressure Energy Flux' &
                                                u=erg/cm^2/s &
               ds=(0:0,0:0,0:1)
real fevb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Viscous Energy Flux' &
                                                u=erg/cm^2/s &
               ds=(0:0,0:0,0:1)
real ferb_xmean d=(1:1,1:1,1:121) f=E13.6 p=4 b=4 &
                                                n='Radiative Energy Flux' &
                                                u=erg/cm^2/s &
               ds=(0:0,0:0,0:1)
label endbox
\end{alltt}}}

\noindent The above list was slightly edited (by adding blanks) to improve readability.

The identifier of an entry together with the name (\verb|n|='\ldots')
and the unit (\verb|u|='\ldots')
should give a first hint about the meaning of the quantity.
The suffix '\verb|_xmean|' indicates a simple average.
The suffix '\verb|_xmean2|' indicates the root-mean-square average (note: the simple average is
not subtracted).

Some entries (e.g.\ \verb|ferb_xmean|) have a hidden \verb|b| in their name,
have one element more (e.g.\ 121 instead of 120) than most of the others,
and are characterized by the \verb|ds| keyword (see Table~\ref{t:headkeywords}).
These quantities are located at the cell
boundaries in contrast to the usual cell-centered quantities.
Clearly, there are also two sets of axes (e.g.\ \verb|xc3| and \verb|xb3|)
corresponding to the cell- or boundary-centered quantities.

\noindent Note: The total energy flux\index{total energy flux} can be written as sum
\begin{verbatim}
feb_total = feipkgvrb = feipb+fekb+fegb+fevb+ferb .
\end{verbatim}
The flux \verb|fepb| is already part of \verb|feipb|.


%--------------------------------------------------------------------------------------------------
\subsection{Parameter File: rhd.par\label{s:rhd.par}}\index{rhd.par|(}

The parameter file \verb|rhd.par| also has the UIO format.
But it will be usually Fortran ``formatted'' (ASCII).

It contains a list of parameter entries.
which are collected in groups to make it easier to find an entry.
Otherwise, the order is arbitrary (except for the very first \verb|fileform uio| entry).
If there are more than one entry with the same name, the first occurence
will be used by CO5BOLD.
But the doubling of entries is strongly discouraged because it will almost certainly
lead to confusion at some time. In addition, the IDL routine to read the parameter
file will fail with an error message.

Additional entries can be added if the names differ from the standard ones
described below.
Theses entries will be ignored by CO5BOLD but read by the IDL input routine.
They can be used to provide comments, additional information about the model,
or control parameters for further processing.


%--------------------------------------------------------------------------------------------------
\subsubsection{Quickstart: How to Make a Proper Parameter File\label{s:quickstart_parameterfile}}

You will never write a new parameter file from scratch.
Typically, you take an old file (e.g.\ the one controlling the
simulation which produced the model which is used to start the
new run) and edit it:

\begin{enumerate}

\item Take the parameter file corresponding to the model you want
  the new simulation to start with.

\item Most of the parameters should be already OK.
  E.g.\ most of the parameters controlling the boundaries do not have
  to be changed.

\item Write a brief description of the purpose of the planned simulation
  into the \verb|character description| array.
  You might but a remark about the parent file of the parameter file under construction
  and the current date
  into the \verb|character history| array (see Sect.~\ref{s:parheader}).

\item Check/modify the name of start model and output files:
  \verb|infile_start|, \verb|outfile_end|, \verb|outfile_full|, \verb|outfile_mean|.
  On a system with batch queue this has not to be done in the parameter
  file itself but in the external command file (see Sect.~\ref{s:parinputoutput}).

\item Check/modify the fundamental parameters including boundary condition specifiers
(see Sections~\ref{s:parfundamental} and \ref{s:parboundaries}, respectively)
 \begin{itemize}
  \item effective temperature control (\verb|s_inflow|, \verb|teff|,
     \verb|luminositypervolume|, \verb|C_radHtautop|)
  \item gravity (\verb|grav_mode|, \verb|grav|, \verb|mass_star|, \ldots)
  \item abundances (\verb|eosfile|, \verb|opafile|, check the paths!)
 \end{itemize}

\item If the gravity of the new model (and therefore the characteristic time scale)
  significantly deviates from the old one,
  the time specifications controlling the output frequency
    (\verb|dtime_out_full|, \verb|dtime_out_mean|),
  the total length of the simulation
    (if specified as stellar time: \verb|endtime|, \verb|plustime|), and
  absolute boundaries/specifications for the time step
    (\verb|dtime_min|, \verb|dtime_min_stop|, \verb|dtime_max|, \verb|dtime_start|)
  have to be scaled.
  Look for parameters with units \verb|u=s| (see Sections~\ref{s:partimestep} and
  \ref{s:parinputoutput}).

\item The rest of the parameters controls additional details.
  Most of the constants are specified in dimensionless form and keep
  their value in a class of related simulations.
  The previously used values will probably be reasonable for the new simulation, too.

\end{enumerate}

Of course, a complete control of CO5BOLD is only possible after studying of the meaning
of the parameters in detail (e.g.\ by reading the following pages) AND -- unfortunately --
an accompanying look into the source code itself.


%--------------------------------------------------------------------------------------------------
\subsubsection{Header\label{s:parheader}}\index{rhd.par!header}

The header of the parameter file contains information about the file format
and contents.
The \verb|description| array can be used to specify the goal
of the simulation, special model characteristics, or important parameter
changes compared to a previous or standard model.
The history array may contain the predecessor of the parameter file
to simplify a tracing of parameter changes.


\begin{itemize}

\item \verb|fileform uio|:
  \index{rhd.par!fileform uio@\verb/fileform uio/} \\
The header of the parameter file, e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=formatted convert=ieee_4  date='01.01.2002' &
  program='by hand'
\end{alltt}}}
can be abbreviated to
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
fileform uio form=formatted convert=ieee_4
\end{alltt}}}
which indicates that the file is in UIO form and Fortran ``formatted'' (ASCII).
The specification of the conversion type (``\verb|convert=ieee_4|'') is
more relevant for unformatted files.
These terms should not be changed.
But it can be of interest to append e.g.\ the date of the last
modification (e.g.\ ``\verb|date='01.01.2002'|'').

\item \verb|character file_id|:
  \index{rhd.par!character fileid@\verb/character file_id/} \\
The file identification string
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character file_id  f=A80 b=80  n='File identification'
rhd-parameter
\end{alltt}}}
indicates the intended use of the file as parameter file for the RHD code CO5BOLD.
Do not edit!

\item \verb|character description|:
  \index{rhd.par!character description@\verb/character description/} \\
The header of the file can (should) contain a short description
of the simulation, as in e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character description  d=(1:4) f=A80 p=1 b=80  n='File description'
Parameter file for RHD code:
Full size 3D Betelgeuse model: 5 M_Sun, 650 R_Sun
Start with st35gm04n03_09.end (127^3 -> 171^3)
Run with SHORTrad
\end{alltt}}}
This entry is optional (it can be omitted completely) but it is
recommended to put at least some relevant keywords into this array.
If you change the number of lines (between 1 and 20) you have to
adjust the size specification (``\verb|d=(1:4)|'' in the example above).


\item \verb|character history|:
  \index{rhd.par!character history@\verb/character history/} \\
The file history has a similar purpose as the previous entry.
It can be used to keep information about the ``parent'' parameter file, as in
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character history  d=(1:2) f=A80 p=1 b=80  n='File history'
Taken from st35gm04n03_09.par
Last Modification:           01.01.2002
\end{alltt}}}
Its use is optional.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Fundamental Model Parameters\label{s:parfundamental}}

\begin{itemize}

\item \verb|real teff|:
  \index{rhd.par!real teff@\verb/real teff/}\index{rhd.par!effective temperature} \\
The effective temperature is one of the basic model parameters and is
specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real teff  f=F13.3 b=4  n='Effective Temperature' u=K
 3500.0
\end{alltt}}}
(for a relatively cool star).
Note that the actual effective temperature can only be determined a posteriori
and that the entropy of the instreaming entropy (see below) is more important
than \verb|teff| itself. In fact, \verb|teff| is only used to control
material properties at the outer boundary. Its value should be close to
the expected effective temperature of the model.


\item \verb|character grav_mod|:
  \index{rhd.par!character gravmode@\verb/character grav_mode/}\index{rhd.par!gravity} \\
Gravity is another characteristic of a stellar atmosphere. The type (or geometry)
of the external gravity field has to be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character grav_mode  f=A80 b=80  n='Type of gravity field' &
  c0='constant/central'
central
\end{alltt}}}
Two values are possible so far:
\begin{itemize}
\item \verb|constant|: In the standard ``solar'' case the constant gravity specified with
  \verb|real grav| is directed downward in x3 direction.
\item \verb|central|: For the ``supergiant'' case a central potential is assumed with an origin
  at x=0. The stellar mass as well as inner and outer smoothing radius have to be specified.
\end{itemize}


\item \verb|real grav|:
  \index{rhd.par!real grav@\verb/real grav/} \\
In the case of a constant gravity the amount of the acceleration has to specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real grav  f=E15.8 b=4  n='Gravity' u=cm/s^2
27500.0
\end{alltt}}}
Setting this value to zero switches off gravity (oh wonder).


\item \verb|real mass_star|:
  \index{rhd.par!real massstar@\verb/real mass_star/} \\
In the case of a central the mass (in cgs units) of the star has to be specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real mass_star f=E15.8 b=4 n='Stellar Mass'              u=g
 9.94500e+33
\end{alltt}}}


\item \verb|real r0_grav|:
  \index{rhd.par!real r0grav@\verb/real r0_grav/} \\
To avoid the central singularity in a 1/r potential it is smoothed in
the center to give a central potential of 1/\verb|r0_grav|, specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real r0_grav   f=E15.8 b=4 n='Inner Smoothing Radius'    u=cm
 9.45833e+12
\end{alltt}}}
This parameter should always be non-zero for a central potential.


\item \verb|real r1_grav|:
  \index{rhd.par!real r1grav@\verb/real r1_grav/} \\
The density in an atmosphere in hydrostatic equilibrium can decline to very
low values. To artificial enlarge the pressure (and density) scale height
in the outer layers of the star (the corners of the box) the gravity can
be reduced by defining the potential at infinity to be
1/\verb|r1_grav|, specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real r1_grav   f=E15.8 b=4 n='Outer Smoothing Radius'    u=cm &
  c0='0.0: Not used'
 11.35000e+13
\end{alltt}}}
Setting this parameter to zero gives the usual 1/r behavior of the potential
in the outer layers but also chooses another smoothing formula in the central
part (where \verb|real r0_grav| is relevant).
But a value somewhat larger than the remotest corner of the box effectively
cancels this artificial smoothing in the outer layers without changing
the formula for the potential.


\item \verb|real r1_rad|:
  \index{rhd.par!real r1rad@\verb/real r1_rad/} \\
For a ``Star-in-a-Box'' and particularly when only ``simple'' ray directions are allowed
in the radiation tranport step the temperature in the outer corners of the box tends to
become very small. To artificially increase the effect of radiative heating the
parameter \verb|real r1_rad| can specify a radius beyond which only postive contributions
of the radiative energy transport to the energy budget are taken into account. This
ruins the conservativity of the code in these layers and should be applied only in very
remote corners which are then considered only as sort of extended boundary region but
not as part of the ``real'' model.
The parameter can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real r1_rad   f=E15.8 b=4 n='Outer radiation transport radius'    u=cm &
  c0='0.0: Not used'
  8.00000e+13
\end{alltt}}}
A value of \verb|0.0| (default) or below deactivates this feature.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Boundary Conditions\label{s:parboundaries}}
\index{rhd.par!boundary conditions}\index{boundary conditions}


The boundary conditions at the six sides of the computational box
cannot be specified independently.
For the naming convention of the boundaries a gravitational acceleration
in -x3 direction is assumed.
Accordingly, there is a bottom, a top, and four side boundaries.

\begin{itemize}


\item \verb|character side_bound|:
  \index{rhd.par!character sidebound@\verb/character side_bound/} \\
The boundary condition at all four sides is given by e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character side_bound   f=A80 b=80 n='side boundary conditions' &
  c0='closed, transmitting, periodic'
transmitting
\end{alltt}}}
Possible values are:
\begin{itemize}
\item \verb|reflective|: closed wall, no gravity, no radiation
\item \verb|constant|: open boundary with constant extrapolation of all values,
                       no gravity, no radiation
\item \verb|closed|, \verb|closedtop|: closed wall, can handle gravity, open for outward radiation
\item \verb|closedbottom|: closed wall, handles gravity, radiation in diffusion approximation
\item \verb|periodic|: periodic boundaries for hydrodynamics and radiation
\item \verb|transmitting|: transmitting boundary for hydro and outward radiation
\end{itemize}
Any of these values can be specified. But in fact, not all of them are recognized by all
modules. Therefore some parameters are for test purposes (e.g.\ shock calculations) only.
In simulations of a solar-like star with the \verb|MSrad| radiation transport module
the side boundaries {\em have\/} to be \verb|periodic|.
In simulations of a red supergiant all boundaries (including the sides) will typically
be \verb|transmitting|. As an alternative, \verb|closed| boundaries can be chosen in this case.


\item \verb|character top_bound|:
  \index{rhd.par!character topbound@\verb/character top_bound/} \\
The boundary condition at the top of the model is given by for instance
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character top_bound    f=A80 b=80 n='top boundary conditions'
transmitting
\end{alltt}}}
Possible values are:
\begin{itemize}
\item \verb|reflective|: closed wall, no gravity, no radiation
\item \verb|constant|: open boundary with constant extrapolation of all values,
                       no gravity, no radiation
\item \verb|closed|, \verb|closedtop|: closed wall, can handle gravity, open for outward radiation
\item \verb|periodic|: periodic boundaries for hydrodynamics and radiation
\item \verb|transmitting|: transmitting boundary for hydro and outward radiation
\end{itemize}
In almost every simulation of stellar convection a \verb|transmitting| top
boundary will be selected, the \verb|closed| one is an alternative.
The \verb|periodic| condition is only recognized by the hydrodynamics routines
and not by any radiation transport routine.


\item \verb|character bottom_bound|:
  \index{rhd.par!character bottombound@\verb/character bottom_bound/} \\
The boundary condition at the bottom of the model is given for instance by
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character bottom_bound f=A80 b=80 n='bottom boundary conditions' &
  c0=closedbottom
transmitting
\end{alltt}}}
Possible values are:
\begin{itemize}
\item \verb|reflective|: closed wall, no gravity, no radiation
\item \verb|constant|: open boundary with constant extrapolation of all values,
                       no gravity, no radiation
\item \verb|closed|, \verb|closedtop|: closed wall, can handle gravity, open for outward radiation
\item \verb|closedbottom|: closed wall, handles gravity, radiation in diffusion approximation
\item \verb|periodic|: periodic boundaries for hydrodynamics and radiation
\item \verb|transmitting|: transmitting boundary for hydro and outward radiation.
                           The parameters \verb|real c_tchange|, \verb|real c_tsurf|, and
                           \verb|real c_hptopfactor| have to be specified.
\item \verb|inoutflow|: "classical" open lower boundary for deep convection,
                        gravity and radiation possible.
                        The parameters \verb|real s_inflow|, \verb|real c_schange|, and
                        \verb|real c_pchange| have to be specified.
\end{itemize}
In simulations of a solar-like star with the \verb|MSrad| radiation transport module
the bottom boundary is typically of type ``\verb|inoutflow|''.
A supergiant simulation will have a \verb|transmitting| lower boundary.


\item \verb|real luminositypervolume|:
  \index{rhd.par!real luminositypervolume@\verb/real luminositypervolume/} \\
The luminosity of a ``Star-in-a-Box'' can be set with this parameter.
To avoid numbers that do not fit into a 4~Byte real the luminosity per volume
has to be specified as e.g.\ in
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real luminositypervolume f=E15.8 b=4 n='Luminosity per core volume' &
  u='erg/cm^3/s'
4.5E-02
\end{alltt}}}
Reference volume is $4/3 \pi r0_{\rm grav}^3$.
If this parameter is set to a value of \verb|0.0| or below the entropy of the
material within the core (defined by as all cells within radius \verb|r0_grav|)
is adjusted instead.


\item \verb|real s_inflow|:
  \index{rhd.par!real sinflow@\verb/real s_inflow/} \\
The entropy of the material streaming through an open boundary of type ``\verb|inoutflow|''
into the model can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real s_inflow f=E15.8 b=4 n='Entropy of core material' &
  u=erg/K/g
3.25E+09
\end{alltt}}}
In the case of a \verb|central| potential the entropy in a sphere with radius
\verb|r0_grav| is adjusted towards this entropy value.
In both geometry (supergiant as well as solar) this value is very important as
it finally (but indirectly) determines the luminosity\index{rhd.par!luminosity} and
effective temperature\index{rhd.par!effective temperature} of the star.
A value of \verb|0.0| (default) or below disables this energy input.


\item \verb|real c_schange|:
  \index{rhd.par!real cschange@\verb/real c_schange/} \\
The entropy \verb|s_inflow| of the material in the bottom layer
(solar case, \verb|inoutflow| boundary condition)
or the central region of the model (supergiant case) is not just
set to the specified but adjusted towards it. The adjustment rate can be
controlled with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_schange f=E15.8 b=4 &
  n='Rate of entropy change for open lower boundary' u=1
 0.3
\end{alltt}}}
Guide values are
\begin{itemize}
  \item \verb|1.0|: fast adjustment
  \item \verb|0.3|: typical value
  \item \verb|0.1|: slow adjustment
  \item \verb|<=0.0|: not allowed
\end{itemize}


\item \verb|real c_pchange|:
  \index{rhd.par!real cpchange@\verb/real c_pchange/} \\
The \verb|inoutflow| boundary condition not only controls entropy and velocity
but also the pressure in the bottom layers:
It is locally adjusted towards the global average to damp out possible
instabilities.
The adjustment rate can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_pchange f=E15.8 b=4 &
  n='Rate of pressure change for open lower boundary' u=1
 1.0
\end{alltt}}}


\item \verb|real c_tchange|:
  \index{rhd.par!real ctchange@\verb/real c_tchange/} \\
In the case of a \verb|transmitting| upper or outer boundary
the temperature of the material streaming into the model
is adjusted with a rate given e.g.\ by
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_tchange f=E15.8 b=4 &
  n='Rate of temperature change for open upper boundary' u=1
 0.3
\end{alltt}}}


\item \verb|real c_tsurf|:
  \index{rhd.par!real ctsurf@\verb/real c_tsurf/} \\
In the case of a \verb|transmitting| upper or outer boundary
the temperature of the material streaming into the model
is adjusted towards a temperature \verb|teff|*\verb|c_tsurf|.
This temperature can be specified as fraction of the effective temperature
e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_tsurf f=E15.8 b=4 n='Temperature factor for open upper boundary' u=1
 0.62
\end{alltt}}}
The value depends on where the outer boundary is located relative to
the photosphere:
If the boundary lies at a point where the solar photospheric minimum temperature
is located, it can be fairly small.
If the boundary is far away from the photosphere of a red supergiant,
the value can be even smaller.
On the other hand, if the boundary lies somewhere within the solar chromosphere
even values above 1.0 might be reasonable.


\item \verb|real c_hptopfactor|:
  \index{rhd.par!real chptopfactor@\verb/real c_hptopfactor/} \\
In the case of a \verb|transmitting| upper or outer boundary
the density stratification outside the model has to be extrapolated properly.
Assumptions about this density affects the amount of mass flowing
into the model.
For the extrapolation it is assumed that the density scale $H_{\rho}$ scales
with the pressure scale height $H_p$ as
  $H_{\rho}$=$H_p$/\verb|c_hptopfactor|.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_hptopfactor f=E15.8 b=4 &
  n='Correction factor for surface pressure scale height' u=1
0.8
\end{alltt}}}
Possible values are
\begin{itemize}
\item C $<$    \verb|0.0|: No effect (actually, a value of \verb|1.0| is chosen).
\item \verb|0.0| $\leq$ C $<$ \verb|1.0|: The density scale height is enlarged to account for
                                          possible effects of turbulent pressure on the scale height:
                                          The density decays less rapidly with height than in
                                          an (isothermal) hydrostatic stratification.
\item C $=$    \verb|1.0|: Density scale height is pressure scale height.
\item C $\geq$ \verb|1.0|: Density scale height is smaller than pressure scale height.
                           Not really useful.
\end{itemize}


\item \verb|real c_radhtautop|:
  \label{s:c_radhtautop}
  \index{rhd.par!real cradhtautop@\verb/real c_radhtautop/} \\
The \verb|MSrad|\index{MSrad} radiation transport module needs the specification
of the scale height of the optical depth at the upper boundary, e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radhtautop f=E15.8 b=4 n='Scale height of optical depth at top' u=cm
60.0E+05
\end{alltt}}}


\item \verb|real rho_min|:
  \index{rhd.par!real rhomin@\verb/real rho_min/} \\
During long periods of matter infall the density at an open outer boundary can
become very low. To limit the decrease of the density a lower limit in the extrapolated
ghost cells can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real rho_min f=E15.8 b=4 n='Minimum boundary density' u=g/cm^3
1.0E-25
\end{alltt}}}
The density within the model will typically not fall much below this value.
A value of \verb|0.0| (default) or below deactivates this feature.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Equation of State}\index{equation of state}\index{EOS}\index{rhd.par!equation of state}

\begin{itemize}

\item \verb|character eosfile|:
  \index{rhd.par!character eosfile@\verb/character eosfile/} \\
The equation of state\index{equation of state}\index{EOS} file
together with the opacity file implicitly determine the
chemical composition\index{chemical composition}.
The EOS file can be specified for instance with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character eosfile f=A80 b=80 n='EOS file name' &
  c0=eos_gamma140.eos/eos_mm20_l.eos
eos_mm00_l3.eos
\end{alltt}}}
So far, there exists only a relatively small number of files:
\begin{itemize}
\item \verb|eos_mm00_l3.eos|: Standard EOS file for solar composition with extra large
                              density range (towards low densities).
                              There exist two other files for the same composition but
                              smaller density range (\verb|eos_mm00.eos|, \verb|eos_mm00_l.eos|)
\item \verb|eos_mm20_l.eos|: Standard EOS file for metal-poor star ([M/H]=-2.0) with
                             extended range in internal energy and density (towards lower values).
                             The older file (\verb|eos_mm20.eos|) did not reach far enough.
\item \verb|eos_gamma140.eos|: EOS table for simple gas with constant $\Gamma$=1.4.
                               In this case all quantities could be faster computed than
                               by interpolation in a table.
                               Nevertheless, for compatibility reasons (to be able to use the
                               existing EOS Fortran routines), the table is provided.
\item \verb|eos_gamma166.eos|: EOS table for simple gas with constant $\Gamma$=5/3.
\end{itemize}


\item \verb|character eospath|:
  \index{rhd.par!character eospath@\verb/character eospath/} \\
The equation of state file does not have to be in the working directory.
Instead, its path can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character eospath f=A80 b=80 n='path of EOS file' &
  c0=/astro/b/bf/for/eos/dat
/home/a_bf/for/eos/dat
\end{alltt}}}

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Opacities}\index{opacities}\index{rhd.par!opacities}

\begin{itemize}

\item \verb|character opafile|:
  \index{rhd.par!character opafile@\verb/character opafile/} \\
The opacity file can be specified with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character opafile f=A80 b=80 n='opacity file name' &
  c0=g2va.opta/big_grey.opta &
  c1='empty -> no radiation transport'
phoenix_opal_grey.opta
\end{alltt}}}
So far, there exist already a couple of files:
\begin{itemize}
\item \verb|davmf.opta|:
\item \verb|f5v.opta|:
\item \verb|g2va.opta|:
\item \verb|g2v_lowhe.opta|:
\item \verb|g2v_m20.opta|:
\item \verb|g2v.opta|:
\item \verb|hmin_p00.opta|:
\item \verb|opal_lowhe.opta|:
\item \verb|opal_m05.opta|:
\item \verb|opal_m10.opta|:
\item \verb|opal_m20.opta|:
\item \verb|phoenix_dust_grey.opta|:
\item \verb|phoenix_dust_ob4.opta|:
\item \verb|phoenix_opal_grey.opta|:
\item \verb|ross_m05.opta|:
\item \verb|ross_m10.opta|:
\item \verb|ross_m20.opta|:
\item \verb|sunur1.opta|:
\item \verb|sunur2.opta|:
\item \verb|t5000g44mm20.opta|:
\item \verb|t5000g47mm20.opta|:
\item \verb|t6300g40mm20.opta|:
\item \verb|t6500g44mm20.opta|:
\item \verb|zzceti1g.opta|:
\item \verb|zzceti1.opta|:
\end{itemize}

\item \verb|character opapath|:\index{rhd.par!character opapath@\verb/character opapath/} \\
The opacity file does not have to be in the working directory.
Instead, its path can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character opapath f=A80 b=80 n='path of opacity file' &
  c0=/astro/b/bf/for/opa/dat
/home/a_bf/for/opa/dat
\end{alltt}}}

\end{itemize}



%--------------------------------------------------------------------------------------------------
\subsubsection{Hydrodynamics Control}\index{hydrodynamics}\index{rhd.par!hydrodynamics}

\begin{itemize}

  \label{s:par:hdscheme}
  \index{rhd.par!character hdscheme@\verb/character hdscheme/}
\item \verb|character hdscheme|: \\
With this parameter the type of the hydrodynamics scheme can be specified as in
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character hdscheme f=A80 b=80 n='Hydrodynamics scheme' &
  c0='Roe (approximate Riemann solver of Roe type)' &
  c1='RoeMagKin (Roe solver + kinetic magnetic field transport)' &
  c2='None (skip hydrodynamics step entirely)'
Roe
\end{alltt}}}
Possible values are
\begin{itemize}
\item \verb|None|: The hydrodynamics step is skipped entirely (for test purposes). Note that in this
                   case some initializations necessary for the generation of the mean file are omitted, too.
\item \verb|Roe|: (default) The standard Riemann solver of Roe type is activated.
                  This value will in almost every case be chosen.
\item \verb|RoeMagKin|: The standard Roe solver is extended to transport passively a magnetic field.
                        This is a test implementation to check if the general magnetic field handling
                        works.
\end{itemize}


  \label{s:par:reconstruction}
  \index{rhd.par!character reconstruction@\verb/character reconstruction/}
\item \verb|character reconstruction|: \\
This parameter determines the order and ``aggressiveness'' of the reconstruction scheme with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character reconstruction f=A80 b=80 n='Reconstruction method' &
  c0=Constant c1=Minmod/VanLeer/Superbee c2=PP
Minmod
\end{alltt}}}
Possible values are
\begin{itemize}
\item \verb|Constant|: The run of the partial waves inside the cells is assumed to be constant.
                       A highly dissipative first order scheme results.
                       This values will usually only be used for test (or comparison) purposes.
\item \verb|Minmod|: Chooses the smallest slope which still results in a second order scheme.
                     It is the most diffusive (and most stable) one in this class.
\item \verb|VanLeer|: (default) The recommended second order scheme.
\item \verb|Superbee|: The ``most aggressive'' stable 2nd order scheme.
                       It results in the steepest shocks, which works well in some test cases
                       but might be to difficult for the radiation transport module to handle.
\item \verb|PP|: Chooses the piecewise parabolic reconstruction of the PPM scheme
                 (``Piecewise Parabolic Method'', Colella \& Woodward 1984).
                 Results in 3rd order accuracy for the advection.
\end{itemize}
Usually, the \verb|VanLeer| reconstruction is a good choice.
If a more stable (and diffusive) scheme is needed, take \verb|Minmod|.
The \verb|PP| reconstruction gives the highest accuracy.


  \label{s:par:c_slopered}
  \index{rhd.par!real cslopered@\verb/real c_slopered/}
\item \verb|real c_slopered|: \\
When \verb|-Drhd_roe1d_slope_l01=2| is set (see Sect.~\ref{s:sw:rhd_roe1d_slope_l01}),
a new extra stabilization mechanism can be activated:
If one of the reconstruction methods \verb|VanLeer|, \verb|Superbee|, or \verb|PP|
(see Sect.~\ref{s:par:reconstruction}) is activated, the slope can be reduced
(by averaging with the results from a \verb|MinMod| reconstruction) by setting
\verb|c_slopered| to a positive non-zero value.
This value can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_slopered f=E15.8 b=4 &
    n='Slope reduction parameter in case of strong density contrast' u=1 &
    c0='0.00: off (default), 0.02: reasonable value, 0.10: large value'
0.02
\end{alltt}}}
Typical choices are
\begin{itemize}
\item \verb|0.0|: Slope reduction switched off.
                  Original reconstruction is used.
\item \verb|0.02|: Moderate slope reduction in case of large density jumps.
\item \verb|0.10|: More pronounced slope reduction in case of strong density contrast.
\end{itemize}


  \label{s:par:n_hydcellsperchunk}
  \index{rhd.par!integer nhydcellsperchunk@\verb/integer n_hydcellsperchunk/}
\item \verb|integer n_hydcellsperchunk|: \\
In every directional sub-step neighboring 1D columns are independent from each other.
They can be grouped and computed in chunks of arbitrary size.
The approximate number of grid cells per chunk can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_hydcellsperchunk f=I9 b=4 &
  n='Number of cells per hydro chunk' &
  c0='0 => one 2D slice at a time' &
  c0='1 => minimum chunk size (inefficient)' &
  c0='2500: reasonable value' &
  c0='1000000000: maximum chunk size (inefficient and memory intensive)'
20000
\end{alltt}}}
The exact number is determined at run time to get (approximately) equal sizes of the individual
chunks.
The choice of this parameter does not affect the result of the computation but
the memory usage and performance:
Smaller (and more) chunks may result in an optimum cache usage and need the smallest
amount of memory, but result in additional overhead due to frequent subroutine calls.
Bigger (and less) chunks are to be preferred for vector machines and processors
with large caches.
Very rough guide values may be
\begin{itemize}
\item \verb|2500|: Pentium III processor
\item \verb|20000|: RISC processor
\item \verb|100000|: Vector machine
\end{itemize}
Note: For simulations with activated OpenMP\index{OpenMP!chunk size}
on a parallel machine the chunk size has to be made small enough to
allow at least as many chunks as processors available. This is
particularly important for models with a small number of grid points
(e.g.\ 2D models).
An example is given for the Hitachi~SR8000 in Sect.~\ref{s:compopt:sr8k}.


  \index{rhd.par!real cvisdrag@\verb/real c_visdrag/}
\item \verb|real c_visdrag|: \\
This viscosity parameter controls the drag force which is (if requested)
applied inside the hydrodynamics routines themselves.
It does not act on velocity gradients as usual viscosity but applies a force proportional to the
velocity itself (but with the opposite sign).
The amount can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_visdrag f=E15.8 b=4 &
    n='Drag viscosity parameter' u=1
0.001
\end{alltt}}}
The value gives the fraction the velocity is reduced per time step.
Therefore, reasonable values lie between \verb|0.0| and \verb|1.0|.
In almost every case the drag forces will be switched off (\verb|c_visdrag|=\verb|0.0|).
If e.g.\ strong pulsation have to be damped in the initial phase of a simulation
a value around \verb|0.001-0.01| seems appropriate.


  \index{rhd.par!real cvisbound@\verb/real c_visbound/}
\item \verb|real c_visbound|: \\
An additional drag force can be added locally in inflow cells in the outer layer
when the \verb|transmitting| boundary condition is chosen. The value can be
set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_visbound f=E15.8 b=4 &
    n='Boundary drag viscosity parameter' u=1
0.001
\end{alltt}}}
This extra drag force is usually not necessary and should be switched off
(with \verb|c_visbound|=\verb|0.0|).

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Tensor Viscosity Control\label{s:tensorviscosity}}
  \index{tensor viscosity}\index{rhd.par!tensor viscosity}

In many test problems it is not necessary to activate the 2D/3D tensor viscosity.
But when strong slow shock fronts are aligned with the grid the Roe solver
runs into problems and at least some additional 2D or 3D viscosity is necessary.
And even if the Roe solver can handle sharp shocks by its own, the
radiation transport algorithm might cause trouble because of the enormous
opacity variations across a shock front. Here the tensor viscosity is useful, too.

\begin{itemize}

\item \verb|real c_vissmagorinsky|:
  \index{rhd.par!real cvissmagorinsky@\verb/real c_vissmagorinsky/} \\
A turbulent viscosity of Smagorinsky type can be activated e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_vissmagorinsky f=E15.8 b=4 &
    n='Turbulent eddy viscosity parameter (Smagorinsky type)'     u=1
1.2
\end{alltt}}}
In many cases values around \verb|0.5| are sufficient to stabilize the code.
Larger values (\verb|1.2| in the example above) are only necessary for some
nasty under-resolved supergiant models.
Setting \verb|c_vissmagorinsky| = \verb|c_visartificial| = \verb|0.0| skips
the tensor viscosity step entirely.


\item \verb|real c_visartificial|:
  \index{rhd.par!real cvisartificial@\verb/real c_visartificial/} \\
A standard artificial viscosity can be activated e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_visartificial f=E15.8 b=4 &
    n='Artificial viscosity tensor parameter'                     u=1
1.2
\end{alltt}}}
In many cases values around \verb|0.5| are sufficient to stabilize the code.
Larger values (\verb|1.2| in the example above) are only necessary for some
nasty under-resolved supergiant models.
Setting \verb|c_vissmagorinsky| = \verb|c_visartificial| = \verb|0.0| skips
the tensor viscosity step entirely.


\item \verb|real c_visprturb|:
  \index{rhd.par!real cvisprturb@\verb/real c_visprturb/} \\
The Prandtl number for turbulent mixing can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_visprturb f=E15.8 b=4 &
    n='Turbulent Prandtl number'                                  u=1
8.0
\end{alltt}}}
Values between \verb|1.0| and \verb|10.0| appear reasonable.
Note that larger values lead to smaller amounts of turbulent mixing!
A value of \verb|0.0| switches off the turbulent mixing terms
(but not the entire tensor viscosity).


\item \verb|real c_vistensordiag|:
  \index{rhd.par!real cvistensordiag@\verb/real c_vistensordiag/} \\
The factor in the stress tensor in front of of the diagonal terms
can be set with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_vistensordiag f=E15.8 b=4 &
    n='Diagonal factor for viscous stress tensor'                 u=1 &
    c0='typically 1.0
1.0
\end{alltt}}}
This is not really parameter one would try to adjust.
The total amount of viscosity should be controlled with 
\verb|real c_vissmagorinsky| and \verb|real c_visartificial|.
But the parameter can be used to tentatively switch off the diagonal terms completely
or to change its importance compared to the other terms.


\item \verb|real c_vistensoroff|:
  \index{rhd.par!real cvistensoroff@\verb/real c_vistensoroff/} \\
The factor in the stress tensor in front of of the off-diagonal terms
can be set with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_vistensoroff f=E15.8 b=4 &
    n='Off-diagonal factor for viscous stress tensor'             u=1 &
    c0='typically 0.5
0.5
\end{alltt}}}
This is not really parameter one would try to adjust.
The total amount of viscosity should be controlled with 
\verb|real c_vissmagorinsky| and \verb|real c_visartificial|.
But the parameter can be used to tentatively switch off the off-diagonal terms completely
or to change its importance compared to the other terms.


\item \verb|real c_vistensordiv|:
  \index{rhd.par!real cvistensordiv@\verb/real c_vistensordiv/} \\
The factor in the stress tensor in front of of the divergence terms (also on the diagonal)
can be set with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_vistensordiv f=E15.8 b=4 &
    n='Divergence factor for viscous stress tensor'               u=1 &
    c0='typically -1./3.
0.0
\end{alltt}}}
This is not really parameter one would try to adjust.
The total amount of viscosity should be controlled with 
\verb|real c_vissmagorinsky| and \verb|real c_visartificial|.
But the parameter can be used to switch off the divergence terms completely
or to change its importance compared to the other terms.
These divergence terms can be used to reduce the effect of
the tensor viscosity in the case of isotropic compression.
But this reduction
(\verb|c_vistensordiv| = \verb|-0.333333| in 3D,
 \verb|c_vistensordiv| = \verb|-0.5| in 2D)
is usually switched off.

\label{s:par:n_viscellsperchunk}
\item \verb|integer n_viscellsperchunk|:
  \index{rhd.par!integer nviscellsperchunk@\verb/integer n_viscellsperchunk/} \\
The number of cells per box (or ``chunk'')
treated by the tensor viscosity scheme at one call (and by one thread)
can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_viscellsperchunk f=I9 b=4 &
  n='Number of cells per viscosity chunk' &
  c0='0 => old chopping' &
  c0='12000: reasonable value'
20000
\end{alltt}}}
It can be adjusted to improve cache efficiency and to
modify the work load distribution onto the threads
(in case of parallel runs with OpenMP).
Due to the special handling of boundary cells the overhead per call increases
significantly for small chunks.
Typically larger chunk sizes (compared the the hydrodynamics chunk sizes set with
\verb|integer n_hydcellsperchunk|, see Sect.~\ref{s:par:n_hydcellsperchunk})
are adequate.
On the other hand they should not be too large to limit the usage of temporary
memory and to allow parallelization (the distribution of chunks to threads):
For simulations with activated OpenMP\index{OpenMP!chunk size} on a parallel machine the
chunk size has to be made small enough to allow at least as many chunks as processors available.
This is particularly important for models with a small number of grid points (e.g.\ 2D models).
An example is given for the Hitachi~SR8000 in Sect.~\ref{s:compopt:sr8k}.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Dust/Molecules \label{s:dust}}
  \index{dust}\index{rhd.par!dust}

CO5BOLD can now handle a number of additional density arrays. They can be used to describe
e.g.\ the mass density of dust distribution moments or number densities of molecules.
These species are properly advected with the gas density.
There is also already a small number of dust/molecule formation models available.
These models have to be improved in the future and the influence on the radiation
field (opacities, radiation pressure on dust) has to be taken into account.

\begin{itemize}

\item \verb|character dustscheme|:
  \index{rhd.par!character dustscheme@\verb/character dustscheme/} \\
A scheme for dust or molecule formation and transport can be selected e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character dustscheme f=A80 b=80 n='Dust model' &
  c0='none (default), nosource, dust_simple_01, co_component01_01' &
  c1='dust_k3mon_01, dust_k3mon_02'
dust_k3mon_01
\end{alltt}}}
Possible values are (the list is hopefully expanded in the near future):
\begin{itemize}
\item \verb|none|, \verb|None|: No handling of any dust/molecule density at all.
\item \verb|nosource|: Skip source term step for dust/molecules entirely, but do the transport.
\item \verb|dust_simple_01|: Simple and unrealistic 'dust' formation model (only for testing of
                             the numerics).
\item \verb|co_component01_01|: Simple CO formation (from Matthias Steffen)
                                with one component only but realistic time scales.
\item \verb|dust_k3mon_01|: Simple C-rich dust formation (from Susanne H\"{o}fner)
                            with one component only but realistic time scales.
\item \verb|dust_k3mon_02|: Simple C-rich dust formation (from Susanne H\"{o}fner)
                            with two components for dust density and free carbon density.
\end{itemize}


\item \verb|real c_dust0X|:
      \index{rhd.par!real cdust0X@\verb/real c_dust0X/} \\
There are five parameters ( \verb|real c_dust01| to  \verb|real c_dust05|)
to control each dust formation scheme in detail. A parameter can be given as in
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_dust01 f=E15.8 b=4 n='Dust parameter 1'
0.0
\end{alltt}}}
The meaning (and unit) can vary from scheme to scheme.
The default value is \verb|0.0| in each case.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Radiation Transport Control\label{s:radiationtransport}}
  \index{radiation transport}\index{rhd.par!radiation transport}

In this part of the parameter file the radiation transport module has to be selected.
Depending on this selection a couple of additional parameters have to be specified.
Table~\ref{t:radparameters} gives a list of the parameters and the modules they apply to.
The standard routines are now in the MSrad\index{MSrad} module for local models and
the SHORTrad\index{SHORTrad} module for global ``Star-in-a-Box'' models.
The LHDrad\index{LHDrad} module is not maintained very much anymore.

\begin{table}[htb]
 \begin{center}
  \begin{tabular}{|llccc|} \hline
Parameter             &  Section                   & LHDrad & MSrad & SHORTrad \\ \hline
\verb|radscheme|      &  \ref{s:radscheme}         &   *    &   *   &    *     \\
\verb|n_radminiter|   &  \ref{s:n_radminiter}      &   *    &   *   &    *     \\
\verb|n_raditer|      &  \ref{s:n_raditer}         &   *    &   *   &    *     \\
\verb|n_radmaxiter|   &  \ref{s:n_radmaxiter}      &   *    &   *   &    *     \\
\verb|radraybase|     &  \ref{s:radraybase}        &   *    &       &    *     \\
\verb|radraystar|     &  \ref{s:radraystar}        &   *    &       &    *     \\
\verb|n_radtheta|     &  \ref{s:n_radtheta}        &        &   *   &          \\
\verb|n_radphi|       &  \ref{s:n_radphi}          &        &   *   &          \\
\verb|n_radsubray|    &  \ref{s:n_radsubray}       &        &   *   &          \\
\verb|n_radthinpoint| &                            &   *    &       &          \\
\verb|n_radthickpoint|&  \ref{s:n_radthickpoint}   &   *    &   *   &          \\
\verb|n_radtaurefine| &  \ref{s:n_radtaurefine}    &   *    &   *   &          \\
\verb|n_radband|      &  \ref{s:n_radband}         &        &   *   &          \\
\verb|c_radimplicitmu|&  \ref{s:c_radimplicitmu}   &   *    &       &    *     \\
\verb|c_raditereps|   &  \ref{s:c_raditereps}      &   *    &       &    *     \\
\verb|c_raditerstep|  &  \ref{s:c_raditerstep}     &   *    &       &    *     \\
\verb|c_radtvisdtau|  &  \ref{s:c_radtvisdtau}     &   *    &       &          \\
\verb|c_radtvis|      &  \ref{s:c_radtvis}         &   *    &       &          \\
\verb|c_radhtautop|   &  \ref{s:c_radhtautop}      &        &   *   &          \\
\verb|c_radcourant|   &  \ref{s:c_radcourant}      &   *    &   *   &    *     \\
\verb|c_radcourantmax|&  \ref{s:c_radcourantmax}   &   *    &   *   &    *     \\
\verb|c_radmaxeichange|& \ref{s:c_radmaxeichange}  &   *    &   *   &    *     \\ \hline
%\verb||   &  \ref{s:}         &   *    &   *   &    *     \\
  \end{tabular}
  \caption[Radiation transport parameters]{List of radiation transport control parameters
     and the modules they are relevant for.
     }\label{t:radparameters}
 \end{center}
\end{table}


\begin{itemize}

\item \verb|character radscheme|:
  \label{s:radscheme}
  \index{rhd.par!character radscheme@\verb/character radscheme/} \\
So far, there exist three different radiation transport modules. The active on
can be selected e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character radscheme f=A80 b=80 n='Radiation transport scheme' &
  c0='LHDrad/MSrad/SHORTrad' &
  c1='None (skip radiation transport step entirely)'
SHORTrad
\end{alltt}}}
Possible values are
\begin{itemize}
\item \verb|None|: Skip radiation transport entirely.
\item \verb|LHDrad|:\index{LHDrad}
  (old ``supergiant module'')
  It uses long characteristics and is restricted to an equidistant grid and
  open boundaries at all surfaces.
  Note that the switch \verb|-Drhd_r01=1| has to be set during compilation
  (see Sect.~\ref{s:rhd_r01}).
\item \verb|MSrad|:\index{MSrad}
  (``solar module'')
  It uses long characteristics. The lateral boundaries have to be periodic.
  Top and bottom can be closed or open.
  Note that the switch \verb|-Drhd_r02=1| has to be set during compilation
  (see Sect.~\ref{s:rhd_r02}).
\item \verb|SHORTrad|:\index{SHORTrad}
  (new ``supergiant module'')
  It uses short characteristics and is restricted to an equidistant grid and
  open boundaries at all surfaces.
  Note that the switch \verb|-Drhd_r03=1| has to be set during compilation
  (see Sect.~\ref{s:rhd_r03}).
\end{itemize}


\item \verb|integer n_radminiter|:
  \label{s:n_radminiter}
  \index{rhd.par!integer nradminiter@\verb/integer n_radminiter/} \\
Usually the stability considerations dictate a radiative time step\index{time step}
smaller than the hydrodynamics or tensor viscosity time step.
To remedy this situation it is possible to allow several radiation transport steps
per global time step.
Hitherto, all three radiation transport modules support this iteration.
The minimum number of iterations (radiative sub-steps) can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radminiter f=I4 b=4 &
  n='Minimum number of radiation transport iterations' c0=8
1
\end{alltt}}}
If less iterations are needed the time step limit for the next step is increased.
This value will in almost any case (for explicit radiation transport) be set to \verb|1|.
In the implicit case it is set to a higher value (typically \verb|5|).


\item \verb|integer n_raditer|:
  \label{s:n_raditer}
  \index{rhd.par!integer nraditer@\verb/integer n_raditer/} \\
After each complete radiative time step the recommendation for the next time step
will be chosen so that \verb|n_raditer| iterations will (probably) needed.
The parameter can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_raditer f=I4 b=4 &
    n='Number of radiation transport iterations' c0=10
8
\end{alltt}}}
For a simulation of a solar-type star (with comparatively long radiative time scales)
it will typically be set to \verb|1|.
For starts with shorter radiative time scales values around \verb|10| may be considered.
All three radiation transport modules understand this parameter.


\item \verb|integer n_radmaxiter|:
  \label{s:n_radmaxiter}
  \index{rhd.par!integer nradmaxiter@\verb/integer n_radmaxiter/} \\
The absolute maximum number of iterations can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radmaxiter f=I4 b=4 &
    n='Maximum number of rad. transport iterations' c0=30
0
\end{alltt}}}
If more iterations are needed the computation for the current
time step is stopped and resumed with a smaller one (which means that the hydrodynamics
and the tensor viscosity step have to be done again).
Usually, \verb|n_radmaxiter| will either be set to a values somewhat larger
than the recommended number of iterations (\verb|n_raditer|)
or to \verb|0| which disable the check for too many iterations completely.
This can be safely allowed in many cases and has the advantage that there is
no need to save the initial model before calling the radiation transport module,
which saves some memory.
To disable the iteration of the radiation transport sub-step set
\verb|n_radminiter|=\verb|n_raditer|=\verb|n_radmaxiter|=\verb|1|.
All three radiation transport modules understand this parameter.


\item \verb|character radraybase|:
  \label{s:radraybase}
  \index{rhd.par!character radraybase@\verb/character radraybase/} \\
Using the modules \verb|LHDrad| or \verb|SHORTrad| the orientation of the base axis system
can be selected e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character radraybase f=A80 b=80 n='Base axis system' &
  c0='unity/random/randomgroup'
random
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|unity|: (default) During all time steps and radiative sub-steps
                    the direction of the rays stays the same.
\item \verb|random|: At each time step (and radiative sub-step) a new base axis system is
                     chosen at random
\item \verb|randomgroup|: At each new time step a new base axis system is
                          chosen at random. It is kept for all radiative sub-steps.
\end{itemize}
Because typically only a relatively small number of rays is chosen per time step
(with \verb|radraystar|) it is advisable to vary the directions of the rays
(by choosing  \verb|radraybase|=\verb|random| or \verb|randomgroup|) to cover
the entire sphere at least over a longer time.


\item \verb|character radraystar|:
  \label{s:radraystar}
  \index{rhd.par!character radraystar@\verb/character radraystar/} \\
Using the modules \verb|LHDrad| or \verb|SHORTrad|
the list of ray directions (i.e.\ the number of rays and their coordinates)
relative to the base axis system can be specified with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character radraystar f=A80 b=80 n='List of relative ray directions' &
  c0='x1(1)/x2(1)/x3(1)/oktaeder(3)/tetraeder(4)/cube(4)' &
  c1='ikosaeder(6)/dodekaeder(10)'
oktaeder
\end{alltt}}}
Examples for allowed values are
\begin{itemize}
\item \verb|x1|: (N=1) one single ray along x1 axis (not enough to specify fluxes in all directions)
\item \verb|x2|: (N=1) one single ray along x2 axis (not enough to specify fluxes in all directions)
\item \verb|x3|: (N=1) one single ray along x3 axis (not enough to specify fluxes in all directions)
\item \verb|oktaeder|: (N=3, default) octahedron
\item \verb|tetraeder|: (N=4) tetrahedron
\item \verb|cube|: (N=4)
\item \verb|ikosaeder|: (N=6) icosahedron
\item \verb|dodekaeder|: (N=10) dodecahedron
\item \verb|list-01|, \verb|list-01(3)|: Choose ray systems from a list (oktahedrons, tetrahedrons).
                                         If \verb|character radraybase| is set to \verb|unity| the rays
                                         will only be aligned to the axes or diagonals and thus avoid the
                                         time-consuming interpolation step of the short-characteristics method.
\end{itemize}
Several other choices are possible, which are meant for test purposes only.
Choosing one of the five Platonic solids (Ops! ``German-Greek'' names only, so far)
means that the 3 to 10 rays are equally distributed over the solid angle
(from the center to each {\em corner\/} of the respective solid).



\item \verb|integer n_radtheta|:
  \label{s:n_radtheta}
  \index{rhd.par!integer nradtheta@\verb/integer n_radtheta/} \\
Using the \verb|MSrad| module the ray directions have to specified in a different way:
The number of ray sets in theta direction can be chosen with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radtheta f=I4 b=4 &
    n='NTHETA: Number of ray sets in theta direction' c0=2
2
\end{alltt}}}


\item \verb|integer n_radphi|:
  \label{s:n_radphi}
  \index{rhd.par!integer nradphi@\verb/integer n_radphi/} \\
Using the \verb|MSrad| module
the number of ray sets in phi direction can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radphi f=I4 b=4 &
    n='NPHI: Number of ray sets in phi direction' c0=2
2
\end{alltt}}}


\item \verb|integer n_radsubray|:
  \label{s:n_radsubray}
  \index{rhd.par!integer nradsubray@\verb/integer n_radsubray/} \\
Using the \verb|MSrad| module
the number of rays per cell (with the same direction)
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radsubray f=I4 b=4 n='KPHI: Number of rays per cell' c0=2
2
\end{alltt}}}


\item \verb|integer n_radthickpoint|:
  \label{s:n_radthickpoint}
  \index{rhd.par!integer nradthickpoint@\verb/integer n_radthickpoint/} \\
With the \verb|MSrad| module the lower part of the model can be computed in diffusion approximation.
The number of points in diffusion approximation can be set with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radthickpoint f=I4 b=4 &
  n='Number of grid points with optically thick (diff.) approximation' &
  c0='0: no diffusion approximation'
0
\end{alltt}}}
Setting this value to \verb|0| means that the diffusion approximation is not used
in any part of the model.


\item \verb|integer n_radtaurefine|:
  \label{s:n_radtaurefine}
  \index{rhd.par!integer nradtaurefine@\verb/integer n_radtaurefine/} \\
With the \verb|LHDrad| and the \verb|MSrad| module the number of points on the rays
can be finer than the number of points in the basic numerical grid.
The refinement can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radtaurefine f=I4 b=4 &
  n='Refinement factor'
0
\end{alltt}}}


\item \verb|integer n_radband|:
  \label{s:n_radband}
  \index{rhd.par!integer nradband@\verb/integer n_radband/} \\
It can be specified whether the grey opacity table or the binned frequency-dependent
part of the opacity table is used during the computation.
The grey part contains only one bin. The other (possibly non-grey) contains one or more
bins depending on the table chosen.
The parameter is specified with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer n_radband f=I4 b=4 n='Number of frequency bins' &
  c0='1: grey opacities' &
  c1='2: non-grey opacities (if available from table)'
1
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|1|: Use the grey part of the table
\item \verb|2|: Use the other (possibly non-grey, frequency-dependent) part of the table
\end{itemize}
Only the \verb|MSrad| module so far can handle non-grey tables.


\item \verb|real c_radimplicitmu|:
  \label{s:c_radimplicitmu}
  \index{rhd.par!real cradimplicitmu@\verb/real c_radimplicitmu/} \\
So far only the \verb|LHDrad| and the \verb|SHORTrad| module (tentatively) support
implicit radiation transport.
It can be activated with the parameter
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radimplicitmu f=E15.8 b=4 &
    n='Implicitness parameter for radiation transport'            u=1 &
    c0='0.0: explicit / 0.5: time centered / 1.0: fully implicit'
0.0
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|0.0|: Fully explicit radiation transport
                  (possible with all modules)
\item \verb|0.0| $<$ C $<$ \verb|1.0|: Partly implicit radiation transport
\item \verb|0.5|: Radiation transport time-centered
\item \verb|1.0|: Fully implicit radiation transport
\end{itemize}
Values outside this range do not have much meaning.
The implicit transport does not work efficiently yet: It does not yield significantly larger
time steps than possible with a sequence of purely explicit sub time steps. Additionally, it
turns out that the hydrodynamics runs into trouble if a too large time step (still well
within the Courant condition) is requested.


\item \verb|real c_raditereps|:
  \label{s:c_raditereps}
  \index{rhd.par!real craditereps@\verb/real c_raditereps/} \\
With activated implicit radiation transport (\verb|LHDrad| module only)
the requested convergence accuracy of the iteration can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_raditereps f=E15.8 b=4 &
    n='Relative accuracy for radiation iteration'                 u=1 &
    c0='Typical value: 1.0E-03'
2.0E-03
\end{alltt}}}


\item \verb|real c_raditerstep|:
  \label{s:c_raditerstep}
  \index{rhd.par!real craditerstep@\verb/real c_raditerstep/} \\
With activated implicit radiation transport (\verb|LHDrad| module only)
the step size of the iteration can be restricted with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_raditerstep f=E15.8 b=4 &
    n='Step size of radiation iteration'                          u=1 &
    c0='Typical values: 0.7,0.81'
1.0
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|0.0| $<$ \verb|1.0|: Restricted step size
\item \verb|1.0|: No restriction, standard step size
\item $>$ \verb|1.0|: Extra large steps
\end{itemize}
This value has to be chosen carefully to get optimal performance.
Is the step size too small the convergence is safe but too slow.
A too large step size inhibits convergence and leads to a decrease in
the time step, which results in a bad performance, too.


\item \verb|real c_radtvisdtau|:
  \label{s:c_radtvisdtau}
  \index{rhd.par!real cradtvisdtau@\verb/real c_radtvisdtau/} \\
Using the \verb|LHDrad| module 
the limit in delta optical depth (rho*kappa*dx) below which the
``radiative temperature viscosity'' (=temperature smoothing) is to be applied
can be set with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radtvisdtau f=E15.8 b=4 &
  n='Optical depth limit for temperature viscosity' u=1
0.1
\end{alltt}}}
The introduction of this ``temperature diffusion'' is a somewhat desperate and
inelegant attempt to improve the behavior of the Greens function (hot cells should
be cooled, cool cells should be heated).
This diffusion is necessary for not well resolved models.
It is switched off with \verb|c_radtvisdtau| $\leq$ \verb|0.0|.


\item \verb|real c_radtvis|:
  \label{s:c_radtvis}
  \index{rhd.par!real cradtvis@\verb/real c_radtvis/} \\
Using the \verb|LHDrad| module
the amount of the ``radiative temperature viscosity'' (=temperature smoothing)
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radtvis f=E15.8 b=4 n='Temperature viscosity' u=1
1.6
\end{alltt}}}
For well resolved models it should be
switched off (with \verb|c_radtvis| $\leq$ \verb|0.0|).
But often its use is necessary.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Process Time Management}\index{rhd.par!process management}

In this group several parameters can be set which control the
start of the time counting during a simulation
and the total length of a job.
If either one of the halt conditions below is met, CO5BOLD finishes the current
step, writes a final model (plus some final information to other files),
and stops execution.

For example on a CRAY\index{Cray} one typically wants to use most of the CPU time
given for an individual batch job. In this case one can set e.g.\
\verb|real cputime_remainlimit|=\verb|2000.0|
and the values for the other halt conditions to \verb|-1.0| or \verb|-1|.

\begin{itemize}

\item \verb|real starttime|:
  \index{rhd.par!real starttime@\verb/real starttime/} \\
The start time of a simulation is usually taken from the start model file.
But sometimes is simulation is to be started with the final model of
a previous run but should start at time=0.0.
This can be achieved by setting the start time with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real starttime f=E15.8 b=4 n='Start time'                              u=s
0.0
\end{alltt}}}
Allowed values are
\begin{itemize}
\item $\geq$ \verb|0.0|: Set the initial time of the simulation to this value
                         and override value from start model.
\item $<$ \verb|0.0|: (default) Take the initial time from start model.
\end{itemize}

\item \verb|integer starttimestep|:
  \index{rhd.par!integer starttimestep@\verb/integer starttimestep/} \\
The start time step count of a simulation is usually taken from the start model file.
But sometimes is simulation is to be started with the final model of
a previous run but should start at time step=0.
This can be achieved by setting the start time step count with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer starttimestep f=I11 b=4 n='Start time step number'             u=1
0
\end{alltt}}}
Allowed values are
\begin{itemize}
\item $\geq$ \verb|0|: Set the initial time step of the simulation to this value
                       and override value from start model.
\item $<$ \verb|0|: (default) Take the initial time step count from start model.
\end{itemize}


\item \verb|real cputime|:
  \index{rhd.par!real cputime@\verb/real cputime/} \\
Because of the long simulation time usually CO5BOLD will run in some sort of
batch mode which might impose limits on the execution time per run.
On a CRAY\index{Cray} the CPU time that is left can be accessed with a
special subroutine (in \verb|call tremain| in \verb|rhd_mac_cray_module.f90|).
On other machines it is possible to specify the allowed total time
for the job e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real cputime f=E15.8 b=4 n='CPU time'                                  u=s
1000000.0
\end{alltt}}}
During the run of CO5BOLD the leftover CPU time is computed
by subtracting the used CPU time
(which is given by \verb|e_time=etime(tarray)| in \verb|rhd_mac_sun_module.f90|)
from the specified total CPU time for the job.

\item \verb|real cputime_remainlimit|:
  \index{rhd.par!real cputimeremainlimit@\verb/real cputime_remainlimit/} \\
Because CO5BOLD needs some time to finish the last time step
it should start exiting well before all CPU time is used up.
This amount of buffer CPU time can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real cputime_remainlimit f=E15.8 b=4 n='maximum remaining CPU time'    u=s
2000.0
\end{alltt}}}
Its value depends on the size of the model and the speed of the machine
(more precisely the maximum CPU time per time step).


\item \verb|real endtime|:
  \index{rhd.par!real endtime@\verb/real endtime/} \\
If the simulation should run up to a certain (stellar) time, its values
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real endtime f=E15.8 b=4 n='total simulation time limit'               u=s
10000.0
\end{alltt}}}
A value $<$ \verb|0.0| deactivates this halt condition: it is not checked at all.
If this parameter is set to a non-negative value a follow-up simulation
should not use the same parameter file: it would stop immediately.


\item \verb|real plustime|:
  \index{rhd.par!real plustime@\verb/real plustime/} \\
If the initial model should be advanced by a certain (stellar) time span,
this value can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real plustime f=E15.8 b=4 n='simulation advance time'                  u=s
5.0E+07
\end{alltt}}}
A value $<$ \verb|0.0| cancels this halt condition: it is not checked at all.
This condition assures (if it is the only one) that all individual
simulation runs cover (approximately) the same stellar time.


\item \verb|integer endtimestep|:
  \index{rhd.par!integer endtimestep@\verb/integer endtimestep/} \\
If the simulation should run up to a certain time step, its values
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer endtimestep f=I11 b=4 n='total simulation time step number'    u=1
1234
\end{alltt}}}
This might be useful to advance the simulation up to a point shortly before
a previous simulation crashed.
A value $<$ \verb|0| cancels this halt condition: it is not checked at all.


\item \verb|integer plustimestep|:
  \index{rhd.par!integer plustimestep@\verb/integer plustimestep/} \\
If the initial model should be advanced by a certain number of time steps
their number can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer plustimestep f=I11 b=4 n='simulation advance time step number' u=1
2000
\end{alltt}}}
A value $<$ \verb|0| deactivates this halt condition: it is not checked at all.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Time Step Control\label{s:partimestep}}\index{rhd.par!time step}

In this group parameters to control the time step restrictions can be set.

They are important because decide about performance and stability of CO5BOLD.
They should be tested and adjusted for a simulation of a new type of object.
But all the dimensionless parameters can stay unchanged for a group of similar
simulations. Only the parameters with an explicit time dimension should
be checked in all cases (they scale with characteristic timescales and
depend particularly on gravity).

\begin{itemize}

\item \verb|real dtime_start|:
  \index{rhd.par!real dtimestart@\verb/real dtime_start/} \\
The initial time step recommendation of a simulation is usually taken from the start model file.
It can be overwritten e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_start f=E15.8 b=4 n='Start time step'                     u=s
1.0E+03
\end{alltt}}}
A value $<$ \verb|0.0| means that the original value from the start model is used.


\item \verb|real dtime_min|:
  \index{rhd.par!real dtimemin@\verb/real dtime_min/} \\
In some rare cases it might be useful to specify explicitly the minimum time step
with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_min f=E15.8 b=4 n='Minimum time step'                     u=s &
  c0='dtime_min=0.0 => no restriction'
1.0
\end{alltt}}}
This value is used even if restrictions from the Courant condition try to
enforce a smaller value.
A fixed time step can be prescribed by setting
\verb|dtime_min| = \verb|dtime_max| to some positive value.
A value \verb|dtime_min| $\leq$ 0.0 means that this time step restriction
is completely ignored, which is the case that should usually be chosen.


\item \verb|real dtime_max|:
  \index{rhd.par!real dtimemax@\verb/real dtime_max/} \\
It is possible to explicitly specify the maximum time step too,
e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_max f=E15.8 b=4 n='Maximum time step'                     u=s &
  c0='dtime_max=0.0 => no restriction'
1.0E+05
\end{alltt}}}
A fixed time step can be prescribed by setting
\verb|dtime_min| = \verb|dtime_max| to some positive value.
A value \verb|dtime_max| $\leq$ 0.0 means that this time step restriction
is completely ignored, which is the case that should usually be chosen.


\item \verb|real dtime_min_stop|:
  \index{rhd.par!real dtimeminstop@\verb/real dtime_min_stop/} \\
Sometimes a simulation can run into a pathological state where the time step
decreases rapidly without recovering.
To prevent a simulation in such a case from running forever (or until some other
process time restriction applies) without actually advancing significantly in
time, it is possible to specify an absolute minimum time step, e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_min_stop f=E15.8 b=4 n='Minimum time step'                u=s &
  c0='dtime_min_stop=0.0 => no restriction' &
  c1='dtime < dtime_min_stop => program stop'
1.0
\end{alltt}}}
If the actual time step falls below this value, the simulation finishes gracefully.
This values has to specified as absolute time and has to be chosen carefully for
each individual model (or each group of models).
This time step restriction can be switched off by setting
\verb|real dtime_min_stop|=\verb|0.0|.
But in general, one should keep it activated and try to find a proper positive value.


\item \verb|real dtime_incmax|:
  \index{rhd.par!real dtimeincmax@\verb/real dtime_incmax/} \\
Sometimes a time step restriction can lead to a sudden drastic drop in the time step.
To prevent unwanted oscillations in the size of the time step
its increase can be restricted e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_incmax f=E15.8 b=4 n='Maximum time step increment factor' u=1 &
  c0='dtime_max<1.0 => no restriction' c1='typically 1.1'
1.2
\end{alltt}}}
This value specifies the maximum factor by which the time step can be increased
from step to step (even if the new Courant condition etc.\ would allow more).
A value value $<$ \verb|0.0| deactivates this restriction.


\item \verb|real c_courant|:
  \index{rhd.par!real ccourant@\verb/real c_courant/} \\
A typical Courant factor for each 1D hydrodynamics step can be specified with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_courant f=E15.8 b=4 n='HD Courant factor'                     u=1 &
  c0='range: 0.0 < C_Courant <= 1.0, typically: 0.5'
 0.5
\end{alltt}}}
From the minimum cell crossing time of a partial wave and this factor
a recommendation for the {\em next\/} time step is computed.
A value of \verb|1.0| is the upper limit which guarantees stability
for some simple linear test problems.
Values around \verb|0.5| are recommended for fully non-linear simulations.


\item \verb|real c_courantmax|:
  \index{rhd.par!real ccourantmax@\verb/real c_courantmax/} \\
A typical Courant factor for each 1D hydrodynamics step can be specified with e.g.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_courantmax f=E15.8 b=4 n='maximum HD Courant factor'          u=1 &
  c0='range: C_Courant < C_Courantmax <= 1.0, typically: 0.9'
 0.8
\end{alltt}}}
From the minimum cell crossing time of a partial wave and this factor
an upper limit for the {\em current\/} time step is computed.
If this limit is exceeded the computation is interrupted and resumed with a smaller
time step (based on \verb|c_courant|).
Usually this parameter should be restricted by
\verb|c_courant| $<$ \verb|c_courantmax| $\leq$ \verb|1.0|.
A value around \verb|0.8| appears to be a good choice.


\item \verb|real c_maxeichange|:
  \index{rhd.par!real cmaxeichange@\verb/real c_maxeichange/} \\
The relative change in internal during a single 1D hydrodynamics step
can be used to restrict the time step by specifying
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_maxeichange f=E15.8 b=4 n='maximum hydro energy change'       u=1 &
  c0='range: 0.1 - 1.0, typically 0.5, off:0.0'
 0.5
\end{alltt}}}
The default is \verb|0.9|.
Nevertheless, since the Roe solver is constructed to handle shocks and
rapid changes in density and energy, this check is usually not needed.
It can be switched off by setting \verb|c_maxeichange|=\verb|0.0|.


\item \verb|real c_radcourant|:
  \label{s:c_radcourant}
  \index{rhd.par!real cradcourant@\verb/real c_radcourant/} \\
The radiation transport routines are subject so time step restrictions, too.
And in typical scenarios, its the radiative timescale are the shortest one and
poses the tightest restriction.
Contrary to the hydrodynamics routines the timescale relevant for the stability
of the radiation transport scheme can only be estimated
using the characteristic timescale of a small sinusoidal temperature disturbance
with a wavelength of the grid size in a homogeneous background and grey radiative
energy exchange.
The ``radiative Courant'' factor can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radcourant f=E15.8 b=4 n='RAD Courant factor'                 u=1 &
  c0='range: 0.0 < C_radCourant, typically: 1.0'
 2.5
\end{alltt}}}
If the estimate of the timescale would be correct a value of \verb|2.0|
would cause the temperature fluctuation on the shortest scale to flip its sign,
setting the absolute stability limit.
A value of \verb|1.0| would lead to a damping of theses fluctuations within one
time step.
But in practice, even higher values (for example \verb|2.5|) show a reasonable
behavior.
This might be due to the effect that the shortest radiative timescale only occurs
at single points (or in 2D layers) but that already the immediate neighbors have
longer timescales and can damp the ``most sensitive points''.
Based on \verb|real c_radcourant| the recommended typical radiative time step is
computed.

\item \verb|real c_radcourantmax|:
  \label{s:c_radcourantmax}
  \index{rhd.par!real cradcourantmax@\verb/real c_radcourantmax/} \\
With this parameter the maximum allowed radiative time step is prescribed as e.g.\ in
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radcourantmax f=E15.8 b=4 n='maximum RAD Courant factor'      u=1 &
  c0='range: C_radCourant <= C_radCourantmax, typically: 2.0'
 3.0
\end{alltt}}}
This value will typically be somewhat larger than \verb|real c_radcourant|.


\item \verb|real c_radmaxeichange|:
  \label{s:c_radmaxeichange}
  \index{rhd.par!real cradmaxeichange@\verb/real c_radmaxeichange/} \\
The relative energy change per radiative sub step can be restricted e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radmaxeichange f=E15.8 b=4 n='maximum radiative energy change' &
  u=1 c0='range: 0.01 - 1.0'
 0.25
\end{alltt}}}
The default is \verb|0.5|.
Values between \verb|0.1| and \verb|0.5| seem reasonable.
A value $\leq$~\verb|0.0| deactivates this time step check.
However, the check of the radiative energy change should usually be performed.
A way to maximize the radiative time step (and therefore the performance of the entire code)
can be to first set \verb|real c_radmaxeichange| to a proper value (say \verb|0.25|).
Then, \verb|real c_radcourant| (and \verb|real c_radcourantmax|) are adjusted
(by trial and error) in a way that the radiative time step is almost always
restricted by the ``Courant'' condition and only sometimes in extreme cases by
the maximum energy change restriction.
The computed output intensity should be checked for the size of its fluctuations
due to a possibly too large value of \verb|c_radmaxeichange|.


\item \verb|real c_radthintimefac|:
  \label{s:c_radthintimefac}
  \index{rhd.par!real cradthintimefac@\verb/real c_radthintimefac/} \\
In the \verb|LHDrad| module only the radiative time step restriction due to energy changes
can be relaxed further in the optically thin by specifying e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radthintimefac f=E15.8 b=4 &
  n='time scale reduction in optically thin'                         u=1 &
  c0='range: 0.1 - 1.0, typically: 0.5'
 0.60
\end{alltt}}}
A value $\leq$ \verb|0.0| or \verb|real c_radtvisdtau| $\leq$ \verb|0.0| switches off this
relaxation.


\item \verb|real c_viscourant|:
  \index{rhd.par!real cviscourant@\verb/real c_viscourant/} \\
The tensor viscosity routines have their own time step restriction.
The recommended typical viscous time step can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_viscourant f=E15.8 b=4 n='viscous Courant factor'             u=1 &
  c0='range: 0.0 < C_visCourant, typically: 0.5-1.0, better 0.25'
 0.5
\end{alltt}}}
As the corresponding viscous timescale is typically longer than the radiative one
(and even the Courant timescale from the Roe hydrodynamics routines)
this factor is often irrelevant.
The absolute upper stability limit is located at \verb|c_viscourant|=\verb|2.0|.
Values around \verb|0.5| to \verb|1.0| are more typical.
In some extreme cases in simulations of the solar chromosphere it has turned out
that an even lower value (\verb|0.2|) is necessary to prevent some spikes
in the neighborhood of strong colliding shocks.

\item \verb|real c_viscourantmax|:
  \index{rhd.par!real cviscourantmax@\verb/real c_viscourantmax/} \\
The absolute upper limit for the viscous time scale can be set with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_viscourantmax f=E15.8 b=4 n='maximum viscous Courant factor'  u=1 &
  c0='range: C_visCourant <= C_visCourantmax, typically smaller than 2.0'
 1.0
\end{alltt}}}
Its value should be slightly above \verb|c_viscourant| and below \verb|2.0|.

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Input/Output Control\label{s:parinputoutput}}\index{rhd.par!input/output}

With this group of parameters
the start model and the type and amount of output can be specified.
Parameters with the suffix ``\verb|_start|'' describe the initial model,
these with suffix ``\verb|_end|'' the corresponding final model.
Additional data can be written
into the file described by the parameters with suffix ``\verb|_full|''
(full 2D/3D model dumps, huge, see Sect.~\ref{s:modelfiles})
or
into the file described by the parameters with suffix ``\verb|_mean|''
(additional information, see Sect.~\ref{s:meanfiles}).

\begin{itemize}

\item \verb|real dtime_out_full|:
  \index{rhd.par!real dtimeoutfull@\verb/real dtime_out_full/} \\
The interval between datasets in the \verb|full| file can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_out_full f=E15.8 b=4 n='Output time step'                 u=s &
  c0='dtime_out_full < 0.0 => no output' &
  c1='dtime_out_full = 0.0 => output every time step'
 2.0E+06
\end{alltt}}}
Allowed values are
\begin{itemize}
\item $<$ \verb|0.0|: No output to this file
\item $=$ \verb|0.0|: Output at every time step. Attention: This can produce HUGE files in no time.
\item $>$ \verb|0.0|: Output to \verb|full| file approximately every \verb|dtime_out_full| seconds.
\end{itemize}
Some examples: The ``classical'' value for this output for simulations of solar granulation
is 20\,sec.
To save memory this can be increased to 30\,sec.
But in this case chromospheric shocks are very badly resolved.
To cover them properly, a sampling rate of 10\,sec or below is needed.


\item \verb|real dtime_out_mean|:
  \index{rhd.par!real dtimeoutmean@\verb/real dtime_out_mean/} \\
The interval between datasets in the \verb|mean| file can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real dtime_out_mean f=E15.8 b=4 n='Output time step'                 u=s &
  c0='dtime_out_mean<0.0 => no output'
 0.5E+06
\end{alltt}}}
Allowed values are
\begin{itemize}
\item $<$ \verb|0.0|: No output to this file
\item $=$ \verb|0.0|: Output at every time step.
\item $>$ \verb|0.0|: Output to \verb|mean| file approximately every \verb|dtime_out_mean| seconds.
\end{itemize}
Because the size of one \verb|mean| dataset is much smaller than one \verb|full| dataset,
it is possible to request a higher sampling rate without using too much disk space.


\item \verb|character infile_start|:
  \index{rhd.par!character infilestart@\verb/character infile_start/} \\
The filename of the initial model is specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character infile_start f=A80 b=80 n='File name of start model'
rhd.sta
\end{alltt}}}
Default is \verb|rhd.sta| (for a parameter file used within a batch system).
Typical filenames are \verb|st35gm04n01_01.sta| or \verb|gt57g44n20dz.end|.


\item \verb|character outfile_end|:
  \index{rhd.par!character outfileend@\verb/character outfile_end/} \\
The file name for the final model can be specified with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outfile_end f=A80 b=80 n='Output file name'
rhd.end
\end{alltt}}}
The default is \verb|rhd.end|.
Leaving it empty means that no final model is written. This of course inhibits
follow-up simulations but can be useful to save time and disk space for some tests.


\item \verb|character outfile_full|:
  \index{rhd.par!character outfilefull@\verb/character outfile_full/} \\
The name of the file for the output of additional full models at regular intervals
(see Sect.~\ref{s:modelfiles}) can be given with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outfile_full f=A80 b=80 n='Output file name'
rhd.full
\end{alltt}}}
Leaving it empty means that no file of this type is written.

\item \verb|character outfile_mean|:
  \index{rhd.par!character outfilemean@\verb/character outfile_mean/} \\
The name of the file for the output of additional information (average stratification,
mean fluxes, surface intensities) at regular intervals (see Sect.~\ref{s:meanfiles})
can be specified with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outfile_mean f=A80 b=80 n='Output file name'
rhd.mean
\end{alltt}}}
Leaving it empty means that no file of this type is written.


\item \verb|character outform_end|:
  \index{rhd.par!character outformend@\verb/character outform_end/} \\
The format (see Sect.~\ref{s:UIO_data_representation}) of the final model files
can be chosen e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outform_end f=A80 b=80 n='Output file format' &
  c0='formatted/unformatted'
unformatted
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|unformatted|: (default) fast compact (possibly machine-dependent) output:
                          strongly recommended
\item \verb|formatted|: slow (machine-independent) output, big files
\end{itemize}


\item \verb|character outconv_end|:
  \index{rhd.par!character outconvend@\verb/character outconv_end/} \\
The conversion type (see Sect.~\ref{s:UIO_data_representation}) of the final model files
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outconv_end f=A80 b=80 n='Output file conversion' &
  c0='ieee_4/ieee_8/crayxmp_8/native'
ieee_4
\end{alltt}}}
The allowed values depend on the machine.
Leaving this field empty means that the default is chosen that is build into the local UIO module.
If the type \verb|ieee_4| is supported (which is always the case, so far) it should be chosen.


\item \verb|character outform_full|:
  \index{rhd.par!character outformfull@\verb/character outform_full/} \\
The format (see Sect.~\ref{s:UIO_data_representation}) of the \verb|full| model files
can be chosen e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outform_full f=A80 b=80 n='Output file format' &
  c0='formatted/unformatted'
unformatted
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|unformatted|: (default) fast compact (possibly machine-dependent) output:
                          strongly recommended
\item \verb|formatted|: slow (machine-independent) output, big files
\end{itemize}

\item \verb|character outconv_full|:
  \index{rhd.par!character outconvfull@\verb/character outconv_full/} \\
The conversion type (see Sect.~\ref{s:UIO_data_representation}) of the  \verb|full| model files
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outconv_full f=A80 b=80 n='Output file conversion' &
  c0='ieee_4/ieee_8/crayxmp_8/native'
ieee_4
\end{alltt}}}
The allowed values depend on the machine.
Leaving this field empty means that the default is chosen that is build into the local UIO module.
If the type \verb|ieee_4| is supported (which is always the case, so far) it should be chosen.


\item \verb|character outform_mean|:
  \index{rhd.par!character outformmean@\verb/character outform_mean/} \\
The format (see Sect.~\ref{s:UIO_data_representation}) of the additional data files
can be chosen e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outform_mean f=A80 b=80 n='Output file format' &
  c0='formatted/unformatted'
unformatted
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|unformatted|: (default) fast compact (possibly machine-dependent) output:
                          strongly recommended
\item \verb|formatted|: slow (machine-independent) output, big files
\end{itemize}


\item \verb|character outconv_mean|:
  \index{rhd.par!character outconvmean@\verb/character outconv_mean/} \\
The conversion type (see Sect.~\ref{s:UIO_data_representation}) of the additional data files
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outconv_mean f=A80 b=80 n='Output file conversion' &
  c0='ieee_4/ieee_8/crayxmp_8/native'
ieee_4
\end{alltt}}}
The allowed values depend on the machine.
Leaving this field empty means that the default is chosen that is build into the local UIO module.
If the type \verb|ieee_4| is supported (which is always the case, so far) it should be chosen.


%\item \verb||:\index{rhd.par!@\verb//} \\
%{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
%\end{alltt}}}
%Allowed values are
%\begin{itemize}
%\item \verb||:
%\end{itemize}

\end{itemize}


%--------------------------------------------------------------------------------------------------
\subsubsection{Additional Information, Obsolete and Test Parameters}

\begin{itemize}

\item \verb|real abux|:\index{rhd.par!real abux@\verb/real abux/} \\
This optional information parameter can be specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real abux f=E15.8 b=4 n='hydrogen abundance (number fraction)' u=1 &
              c0='standard solar mixture'
 0.90851003E+00
\end{alltt}}}
It has no practical consequences because the actually used
chemical composition is determined by the files for equation of state and opacity.

\item \verb|real abuy|:\index{rhd.par!real abuy@\verb/real abuy/} \\
This optional information parameter can be specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real abuy f=E15.8 b=4 n='helium abundance (number fraction)'   u=1 &
          c0='standard solar mixture'
 0.90850003E-01
\end{alltt}}}
It has no practical consequences because the actually used
chemical composition is determined by the files for equation of state and opacity.

\item \verb|real qmol|:\index{rhd.par!real qmol@\verb/real qmol/} \\
This optional information parameter can be specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real qmol f=E15.8 b=4 n='mean molecular weight'                u=u &
          c0='standard solar mixture'
 0.13018000E+01
\end{alltt}}}
It has no practical consequences because the actually used
chemical composition is determined by the files for equation of state and opacity.

\item \verb|real gamma|:\index{rhd.par!real gamma@\verb/real gamma/} \\
This optional information parameter can be specified with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real gamma f=E15.8 b=4 n='Adiabatic coefficient'               u=1 &
          c0='0.0/1.6666666666666/1.4'
 0.0
\end{alltt}}}
It has no practical consequences because the actually used
chemical composition is determined by the files for equation of state and opacity.


\item \verb|real c_visneu1|:\index{rhd.par!real cvisneu1@\verb/real c_visneu1/} \\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_visneu1 f=E15.8 b=4 &
    n='Linear viscosity parameter (von Neumann-Richtmyer type)'   u=1
0.0
\end{alltt}}}

\item \verb|real c_visneu2|:\index{rhd.par!real cvisneu2@\verb/real c_visneu2/} \\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_visneu2 f=E15.8 b=4 &
    n='Quadratic viscosity parameter (von Neumann-Richtmyer type)' u=1
0.0
\end{alltt}}}


\item \verb|real c_radkappasmooth|:\index{rhd.par!real c_radkappasmooth@\verb/real c_radkappasmooth/} \\
In the \verb|LHDrad| module the opacity along each ray can be smoothed.
The amount of smoothing can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radkappasmooth f=E15.8 b=4 n='Opacity smoothing parameter' u=1 &
    c0='0.0: no smoothing, 0.25: light smoothing, 0.666: strong smoothing'
0.0
\end{alltt}}}
The smoothing can perhaps reduce the noise in the intensity images somewhat but
has no general beneficial effect and should usually not be used.

\item \verb|real c_radtsmooth|:\index{rhd.par!real cradtsmooth@\verb/real c_radtsmooth/} \\
In the \verb|LHDrad| module the 3D temperature array can be smoothed.
The amount of smoothing can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radtsmooth f=E15.8 b=4 n='Temperature smoothing parameter' u=1 &
    c0='0.0: no smoothing, 0.5: reasonable smoothing, 1.0: max. smoothing'
0.0
\end{alltt}}}
The smoothing can sometimes reduce the noise in the intensity images
but causes/amplifies some anomalies of the radiative Greens function:
Some cool cell just above the sharp sub-photospheric temperature drop are not heated but cool
further down. Negative temperature spikes may result.
This smoothing should not be used anymore.


\item \verb|character radpressure|:\index{rhd.par!character radpressure@\verb/character radpressure/} \\
In the \verb|LHDrad| module
there exists a simple prescription for the radiative pressure
(reasonable in the optically thin)
which can be activated with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character radpressure f=A80 b=80 n='Radiation pressure mode' &
  c0='on/off'
on
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|on|: Radiation pressure on.
\item \verb|off|: Radiation pressure off.
\end{itemize}
The scheme is pretty slow and wrong in the optically thick.
Do not use!


\item \verb|real c_radtintminfac|:\index{rhd.par!real cradtintminfac@\verb/real c_radtintminfac/} \\
In the \verb|LHDrad| module:
The fraction the interpolated temperature (at a point on the ray)
may exceed the minimum temperature at its four neighbors on the HD grid
can be set e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
real c_radtintminfac f=E15.8 b=4 &
  n='Temperature interpolation parameter' u=1 &
  c0='<1.0: only bilinear, 1.1: reasonable weighting between min. und bil.'
0.0
\end{alltt}}}
The introduction of this parameter was an attempt to reduce the negative (cooling)
effect of a single hot cell on its cool neighbors.
It should be switched off e.g.\ by setting it to \verb|0.0|.


\item \verb|integer dtimestep_out_fine|:\index{rhd.par!integer dtimestepoutfine@\verb/integer dtimestep_out_fine/} \\
This parameter can be specified but there is no corresponding output file in CO5BOLD yet.
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
integer dtimestep_out_fine f=I4 b=4 n='Output time step number'       u=1 &
  c0='dtimestep_out_fine<0 => no output'
-1
\end{alltt}}}

\item \verb|character outfile_fine|:\index{rhd.par!character outfilefine@\verb/character outfile_fine/} \\
The name of the file for the output of additional information
at regular (small) intervals
can be specified with e.g.\
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outfile_fine f=A80 b=80 n='Output file name'
rhd.fine
\end{alltt}}}
Leaving it empty means that no file of this type is written.
Specifying it means the same (yet).

\item \verb|character outform_fine|:\index{rhd.par!character outformfine@\verb/character outform_fine/} \\
The format (see Sect.~\ref{s:UIO_data_representation}) of the files with frequent output
can be chosen e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outform_fine f=A80 b=80 n='Output file format' &
  c0='formatted/unformatted'
unformatted
\end{alltt}}}
Allowed values are
\begin{itemize}
\item \verb|unformatted|: (default) fast compact (possibly machine-dependent) output:
                          strongly recommended
\item \verb|formatted|: slow (machine-independent) output, big files
\end{itemize}
This parameter can be specified but there is no corresponding output file in CO5BOLD yet.

\item \verb|character outconv_fine|:\index{rhd.par!character outconvfine@\verb/character outconv_fine/} \\
The conversion type (see Sect.~\ref{s:UIO_data_representation}) of the files with frequent output
can be specified e.g.\ with
{\color{DEFcolor}{\small\color{UIOcolor}\begin{alltt}
character outconv_fine f=A80 b=80 n='Output file conversion' &
  c0='ieee_4/ieee_8/crayxmp_8/native'
ieee_4
\end{alltt}}}
The allowed values depend on the machine.
Leaving this field empty means that the default is chosen that is build into the local UIO module.
If the type \verb|ieee_4| is supported (which is always the case, so far) it should be chosen.
This parameter can be specified but there is no corresponding output file in CO5BOLD yet.

\end{itemize}

\index{rhd.par|)}


%--------------------------------------------------------------------------------------------------
\subsection{Additional Control and Status Files: rhd.stop, rhd.cont, and
            rhd.done}
  \index{rhd.cont}\index{rhd.stop}\index{rhd.done}\index{output!rhd.done}
  \label{s:rhd.cont}\label{s:rhd.stop}\label{s:rhd.done}

Before each time step CO5BOLD checks in the working directory
whether the file \verb|rhd.stop| exists.
If it has been generated (e.g.\ with \verb|touch rhd.stop|),
the code exits gracefully, i.e.\ it produces a
proper final model, which can be used to restart the code.
This method of stopping a simulation is to be preferred over
a simple \verb|kill| or \verb|qdel| command because it allows
to analyze the state of the model just at the end of the simulation
and a smooth restart.

Before the restart the \verb|rhd.stop| file has to be deleted!
The simulation can be continued by just initiating a new run.
If the file \verb|rhd.cont| exists at the beginning of a
simulation, the code tries to resume an interrupted computation:
The initial model will not be taken from the start model file
(\verb|infile_start|) but from the final model (\verb|outfile_end|).
The data for the full and the mean file is not written into new files
but will be appended to the existing ones.

In this way a simulation can be interrupted and continued in a fairly
safe way. It is possible to analyze the final model and to changes
values in the parameter file.
Keep in mind that after a restart with \verb|rhd.cont| the specifications
about the length of the job (e.g.\ the number of time steps) will be
counted from the restart point and not from the beginning of the original
simulation.

To interrupt a job with \verb|rhd.stop| can be very handy.
The continuation with \verb|rhd.cont| and the old parameter file
is not to be preferred over an ordinary restart with a new parameter file.

If a run was successful i.e.\ it was completed because one of the
regular termination conditions was fulfilled (e.g.\ the requested number
of time steps was performed) the exit status file \verb|rhd.done| is produced.
Currently, it contains the date and time of its generation.
The existence of this file can be checked within a script to determine
if the simulation was successful (and should be continued).
Note: the existence of an \verb|rhd.end| file
only indicates that CO5BOLD managed to exit gracefully -- due to an error or
in a regular way.


%--------------------------------------------------------------------------------------------------
\subsection{Text Output: rhd.out\label{s:rhd.out}}\index{rhd.out}\index{output!rhd.out}

During execution -- expecially during the initialization phase -- CO5BOLD writes lots of
information to standard output:

After the header its with a block ``Compiler call'', e.g.

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
pgf90 -byteswapio -fast -Mvect=sse -Mcache_align -Minfo=inline -Minline=rhd_hyd_a
  vg,rhd_hyd_upwind,rhd_hyd_pred0,rhd_hyd_predm,rhd_hyd_predp,rhd_hyd_alpha,rhd_h
  yd_constanteq,rhd_hyd_minmodeq,rhd_hyd_minmod,rhd_hyd_vanleereq,rhd_hyd_vanleer
  ,rhd_hyd_superbeeeq,rhd_hyd_superbee,rhd_hyd_ppeq,rhd_hyd_pp,rhd_hyd_hdflux,rhd
  _hyd_entropyfix -Minline=rhd_rad3d_raylhd,rhd_rad3d_solve,rhd_rad3d_solveeq,rhd
  _shortrad_operator,rhd_shortrad_dtauop -Drhd_hyd_roe1d_l01=0 -Drhd_r02 -Drhd_r0
  3 -DMSrad_raytas1 -Drhd_hyd_entropyfix_p01=1 -Drhd_roe1d_step_t01 -Drhd_roe1d_f
  lux_t01 -Drhd_vis_t01 -Drhd_bound_t01 -Drhd_shortrad_step_t01 -Drhd_shortrad_fo
  rmal_t01 -Drhd_shortrad_lambda_t01
\end{alltt}}}

These lines were produced by the configure script\index{configure script}
(see Sect.~\ref{s:configure}) and written into the file

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
  compiler_flags.info
\end{alltt}}}

\noindent which is accessed from \verb|rhd.F90| via \verb|include| during compilation.

Various modules now have a routine ``\verb|XXX_switchinfo|'' that prints the values
of the compiler switches used during the compilation of that particular module.
The output can look e.g.\ like

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
Compiler switches: rhd_hyd_module .........................
  IDF:                             0
  rhd_hyd_gravcorr_p01:            5
  rhd_hyd_entropyfix_p01:          1
  rhd_hyd_upwind_p01:              0
  rhd_hyd_roe1d_l01:               0
  rhd_roe1d_step_l01:              0
  rhd_roe1d_slope_l01:             0
  rhd_roe1d_flux_l01:      undefined
  rhd_bound_t01:             defined
  rhd_roe1d_flux_t01:        defined
  rhd_roe1d_step_t01:        defined
\end{alltt}}}

\noindent See Sect.~\ref{s:compiler_macros} for more information about the meaning of the values.

The reading of the parameter file starts with

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Read parameter file <<<<<<<<
\end{alltt}}}

\noindent After a parameter is read, its value is printed (see Sect.~\ref{s:rhd.par})

The line

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Load EOS data <<<<<<<<
\end{alltt}}}

\noindent indicates the start of the reading of the equation of state data.
It is followed by some information about the EOS table in use.

Similarly, the line

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Load opacity tables <<<<<<<<
\end{alltt}}}

\noindent indicates the start of the reading of the opacity data.
The information that follows is taken directly from the header of
the opacity table.

Currently, the last file to be read is the start model, which is announced by

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Read start model <<<<<<<<
\end{alltt}}}

\noindent and followed by some information about the start model, e.g.\ the number of
grid points and a new section showing the quantities actually read, e.g.

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
Properties of start model:
  time       "time"                                     [s]
  xc1        "x1 coordinates of cell centers"           [cm]
  xc2        "x2 coordinates of cell centers"           [cm]
  xc3        "x3 coordinates of cell centers"           [cm]
  xb1        "x1 coordinates of cell boundaries"        [cm]
  xb2        "x2 coordinates of cell boundaries"        [cm]
  xb3        "x3 coordinates of cell boundaries"        [cm]
  rho        "Density"                                  [g/cm^3]
  ei         "Internal energy"                          [erg/g]
  v1         "Velocity 1"                               [cm/s]
  v2         "Velocity 2"                               [cm/s]
  v3         "Velocity 3"                               [cm/s]
  quc001     "Number density of CO"                     [1/cm^3]     advect(1)
  bb1        "Magnetic field 1"                         [G]
  bb2        "Magnetic field 2"                         [G]
  bb3        "Magnetic field 3"                         [G]
\end{alltt}}}

It might follow

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Initialize MS radiation transport routines <<<<<<<<
\end{alltt}}}

And finally

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Open output files <<<<<<<<
\end{alltt}}}

\noindent which indicates that the \verb|rhd.full| file (see Sect~\ref{s:modelfiles})) and
the \verb|rhd.mean| file (see Sect~\ref{s:meanfiles})) have been opened and now contain
a header.


The end of the initialization phase and the beginning of the proper simulation is
marked by e.g.

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
================================ Start Computation =================================
=== Time step number: itime=    47050  time=  2.5821813E+08  t_job= 8.510000E+00 ===
\end{alltt}}}

The output for a typical simulation time step can look like (for a supergiant model
with SHORTrad radiation transport)

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
--- Time step number: itime=    49048  time=  2.6822680E+08  t_job= 1.272180E+06 ---
dtime= 5.3047E+03 HD= 1.4838E+04 RAD= 5.3047E+03 VIS= 1.0723E+05
Luminosity per core volume:  4.49999049E-02
HYD 1: N_cellsperchunk, n_chunks:      10000  1410
HYD 2: N_cellsperchunk, n_chunks:      10000  1410
HYD 3: N_cellsperchunk, n_chunks:      10000  1410
VIS3D: N_cellsperchunk, n_chunks:      10000  1360

=== Start of rhd_shortrad_step ===
n_subdtime:    1
minmax(T)        1.111651E+03 1.630733E+05
Main ( 1/ 3) ray direction 2:   0.000000  1.000000  0.000000 -----------------------
Main ( 2/ 3) ray direction 3:   0.707105  0.000000  0.707109 -----------------------
Main ( 3/ 3) ray direction 3:  -0.707105  0.000000  0.707109 -----------------------
Time step ratio: dtime/dtime_rad:   1.750409E+01
dtime_:rad,drhoei,limit_this,all:  6.667E+02 2.510E+03 6.276E+02 0.000E+00
n_subdtime:    2
minmax(T)        1.116348E+03 1.630658E+05
Main ( 1/ 3) ray direction 1:   1.000000  0.000000  0.000000 -----------------------
Main ( 2/ 3) ray direction 3:   0.000000  0.707105  0.707109 -----------------------
Main ( 3/ 3) ray direction 3:   0.000000 -0.707105  0.707109 -----------------------
Time step ratio: dtime/dtime_rad:   1.836970E+01
dtime_:rad,drhoei,limit_this,all:  6.353E+02 3.188E+03 7.971E+02 6.276E+02
...
n_subdtime:    8
minmax(T)        1.118540E+03 1.630164E+05
Main ( 1/ 3) ray direction 2:  -0.707105  0.707109  0.000000 -----------------------
Main ( 2/ 3) ray direction 2:   0.707105  0.707109  0.000000 -----------------------
Main ( 3/ 3) ray direction 3:   0.000000  0.000000  1.000000 -----------------------
Time step ratio: dtime/dtime_rad:   1.791384E+01
dtime_:rad,drhoei,limit_this,all:  6.515E+02 3.894E+03 8.884E+02 4.814E+03
=== End of rhd_shortrad_step =====
\end{alltt}}}


A simulation ends with e.g.

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
=== Time step number: itime=    49050  time=  2.6823742E+08  t_job= 1.273407E+06 ===
================================ End Computation ===================================
\end{alltt}}}

\noindent A proper exit is indicated by

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
------------------------------------------------------------------------------------
Exit information: Requested number of time steps done
Exit status:        0
------------------------------------------------------------------------------------
\end{alltt}}}

\noindent In this case a file \verb|rhd.done| (see Sect.~\ref{s:rhd.done}) is produced.
A messages like

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
************************************************************************************
Severe error: SHORTRAD: Time step below absolute limit
Error index:      100
Interrupt computation
************************************************************************************
\end{alltt}}}

\noindent marks an exit with an error and without \verb|rhd.done| file.
A message about the final model like
{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
ACTION: Write final model <<<<<<<<
Model file 'rhd.end' opened on channel  12
====================================================================================
\end{alltt}}}

\noindent is followed by some timing information\index{timing statistics} like e.g.

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
Timing statistics (rate x factor=   1000000 x     10000)
========================================================

Process                           Samples     Total time      Mean time
                                                   [sec]          [sec]
-------------------------------------------------------------------------------
RHD code                                1     410.830017     410.830017
uio output routines                    27      37.469997       1.387778
HYD: bound_3Dcenter                  2000       3.540000       0.001770
Hydrodynamics routines               2000   48944.660156      24.472330
HYD: 1                               2000   16350.610352       8.175305
HYD: 2                               2000   16052.459961       8.026230
HYD: 3                               2000   16520.798828       8.260400
Viscosity routines 3D                2000   25446.400391      12.723200
VIS: make_box(modelvis)              2000       0.010000       0.000005
VIS: copy_box(modelvis)              2000    1750.960083       0.875480
VIS: delete_box(modelvis)            2000       0.000000       0.000000
Radiation transport routines         2000  243729.000000     121.864502
SHC: step                            2020  244064.515625     120.824020
SHC: step: dtime: init: EOS         16024   49312.738281       3.077430
SHC: step: dtime: explicit          16024  174542.343750      10.892558
SHC: formal                         16024  170085.437500      10.614418
SHC: formal: init                   16024   35591.378906       2.221129
SHC: formal: dirloop                16024  133010.687500       8.300717
SHC: formal: exp                    28014    9014.280273       0.321778
SHC: formal: exp: expl2t            28014    3950.409912       0.141016
SHC: formal: dir3                   36083   63222.242188       1.752134
SHC: time: dir3                     36083   19676.009766       0.545299
SHC: formal: limitei                16024    1306.419922       0.081529
SHC: step: dtime: final             16024   12730.129883       0.794441
SHC: formal: dir2                   11959   22205.000000       1.856761
SHC: time: dir2                     11959    5731.149902       0.479233
SHC: formal: dir1                    4044   10674.429688       2.639572
SHC: time: dir1                      4044    1893.760010       0.468289
SHC: step: dtime: final(output)       181    8620.870117      47.629116
Radiation trans.: output only          20     335.929993      16.796499
\end{alltt}}}

\noindent In this example the value for the overall time (``rhd code 410.830017 sec'') is not
useful because of an overflow in the counter.
However, it is evident that the radiation transport consumes most of the time (243729.000000 sec),
followd by the hydrodynamics routines (48944.660156 sec)
and the tensor viscosity routines (25446.400391 sec).
Some of these values are split further.


\clearpage
%==================================================================================================
\section{Running a Simulation}

%--------------------------------------------------------------------------------------------------
\subsection{Quickstart: How to Run CO5BOLD\label{s:quickstart_runCO5BOLD}}

The generation of a start file and the modification of the parameter file is a somewhat
complex process. In short, the following steps have to be performed.

\begin{enumerate}

\item Produce an executable \verb|rhd.exe| (see Sect.~\ref{s:quickstart_compile})
   and put it into your working directory.

\item Choose a start model (e.g.\ the final model of an earlier simulation
  or a model produced with an IDL routine).

\item Edit the parameter file \verb|rhd.par|:
  typically, you will start with an existing file and edit it.
  You should check that the paths and names of EOS, opacity, and start file are set correctly
  (Watch the username!).
  For details about the parameter file see Sect.~\ref{s:quickstart_parameterfile}.

\item Start the simulation with \\
\verb|nice nohup rhd.exe > rhd.out &|

\item You can see how the simulation proceeds with \\
\verb|tail -f rhd.out|

\item The other data files usually are in a binary format (this can be changed to ASCII ``formatted''
in \verb|rhd.par|).
Their contents can be read and analyzed with IDL routines (see Sect.~\ref{s:uio_dataset_rd}).

\end{enumerate}

For machines with batch queue (CRAYs in Kiel, SUN1 in Uppsala) there is a script,
which can handle an entire sequence of simulations
(see Sect.~\ref{s:batchsystem}).


\clearpage
%--------------------------------------------------------------------------------------------------
\subsection{Running CO5BOLD on a Machine with Batch System\label{s:batchsystem}}\index{batch queue}

For longer simulations it is inconvenient to restart the individual jobs by hand.
This task is done by a script
originally from Hans-G\"{u}nter Ludwig.
Its basic function is sketched in Fig.~\ref{f:prgscheme}.

\begin{latexonly}
\begin{figure}[hbtp]
\centering
\includegraphics[width=16.2cm]{co5bold/coboldscheme}
\caption[Program scheme]{Program scheme}
\label{f:prgscheme}
\end{figure}
\end{latexonly}

\begin{htmlonly}
\begin{figure}[hbtp]
\htmlimage{external,thumbnail=1.0,no_transparent}
\centering
\includegraphics[width=16.2cm]{co5bold/coboldscheme.eps}
\caption[Program scheme]{Program scheme
, \htmladdnormallink{Postscript version}{coboldscheme.eps}
}
\label{f:prgscheme}
\end{figure}
\end{htmlonly}

Here comes an example of the script (\verb|rhd1.job|)
for a system without dedicated batch system.
The submission of a job is done via \verb|nohup rhd1.job|:
{\color{DEFcolor}{\small\color{SHcolor}\begin{verbatim}
#!/bin/sh
#--- PBS -N rhd1
#--- PBS -l walltime=72:00:00 
#--- PBS -l nodes=1:ppn=4
#
# --- Job file for the execution of RHD on gunnar (Itanium 2, Uppsala) ---
# --- Source: rhd1.job, original from HGL                              ---
# --- Last modification: 2002-12-13                                    ---
#
#set -xv
#
BASEDIR=/users/bf/dat/job/j1
STADIR=${BASEDIR}/sta      # Start directory: contains *.par, rhd1.cmd, rhd1.job
WRKDIR=${BASEDIR}/wrk      # Work directory
BAKDIR=${BASEDIR}/bak      # Backup and output directory
RHDEXE=$STADIR/rhd.exe     # RHD program to be executed
#
#export NCPUS=4
#echo $NCPUS
export OMP_NUM_THREADS=1
#
# --- Jump into work directory ---
cd $WRKDIR
#
# --- Loop: execute RHD code (possibly) several times in one job --------------
for IRUN in 1
do
  echo
  echo 'CO5BOLD Run #' $IRUN
  date
  #
  # --- Clear up work directory ---
  #set +e
  rm *
  #set -e
  #
  ##############################################################################
  #
  #   --- Get old command file, select actual command line ---
  #   --- and read variables from command line             ---
  #
  cp -p $STADIR/rhd1.cmd rhd1.cmd
  #
  awk \
  '      /#/   { print; next}
        /\*/   { print; next}
        /\+/   { print; next}
   DONE!="T"   { print >"cmdline"; printf "%-77s*\n", $0; DONE="T"; next}
               { print} ' rhd1.cmd | cat > dummy_nrhd.cmd
  #
  read INFILE OUTFILE PARFILE ACT < cmdline
  mv dummy_nrhd.cmd ${OUTFILE}_nrhd.cmd
  echo ${INFILE}
  echo ${OUTFILE}
  echo ${PARFILE}
  echo ${ACT}
  #
  ##############################################################################
  #
  if [ "${ACT}" != dum ]
  then
    ############################################################################
    #
    #   --- RHD execution ---
    #
    # --- Copy parameter file ---
    cp -p ${STADIR}/${PARFILE} rhd.par
    #
    # --- Copy start file ---
    if test -s ${BAKDIR}/${INFILE}
    then
      cp -p ${BAKDIR}/${INFILE} rhd.sta
    else
      cp -p ${STADIR}/${INFILE} rhd.sta
      cp -p rhd.sta ${BAKDIR}/${INFILE}
    fi
    # --- Copy executable ---
    cp -p ${RHDEXE} rhd.exe
    #
    # --- Execute RHD ---
    ./rhd.exe > rhd.out
    RHD_EXIT=$?
    #
    if [ "$RHD_EXIT" != 0 ] || [ ! -s rhd.done ]
    then
      # --- Exit status not zero, ---
      # --- error may have occurred during execution of rhd.exe ---
      if [ "$RHD_EXIT" != 0 ]
      then
        echo 'Non-zero exit status ' $RHD_EXIT ' occurred during execution of RHD!'
      else
        echo 'No rhd.done file found: assume error during execution of RHD!'
      fi
      echo 'Execution of job chain terminated!'
      # --- Modify nrhd.cmd, set termination character "+" ---
      awk \
      '      /#/   { print; next}
            /\*/   { print; next}
            /\+/   { print; next}
       DONE!="T"   { printf "%-77s+\n", $0; DONE="T"; next}
                   { print} ' rhd1.cmd | cat > nrhd.cmd
      # --- Terminate chain by simulating ${ACT} = eoc ... ---
      ACT=eoc
    else
      # --- Modify command file: add '*' in appropriate column to indicate ---
      # --- proper execution                                               ---    
      awk \
      '      /#/   { print; next}
            /\*/   { print; next}
            /\+/   { print; next}
       DONE!="T"   { print >"cmdline"; printf "%-77s*\n", $0; DONE="T"; next}
                   { print} ' rhd1.cmd | cat > nrhd.cmd
    fi
    #
    ls -l
    #
    # --- Move data into backup directory ---
    cp -p rhd.par  ${BAKDIR}/${PARFILE}
    mv rhd.out  ${BAKDIR}/${OUTFILE}.out
    mv rhd.par  ${BAKDIR}/${OUTFILE}.par
    #mv rhd.sta  ${BAKDIR}/${OUTFILE}.sta
    mv rhd.end  ${BAKDIR}/${OUTFILE}.end
    mv rhd.full ${BAKDIR}/${OUTFILE}.full
    mv rhd.mean ${BAKDIR}/${OUTFILE}.mean
    chmod go+r ${BAKDIR}/${PARFILE} ${BAKDIR}/${OUTFILE}.*
    chmod go-w ${BAKDIR}/${PARFILE} ${BAKDIR}/${OUTFILE}.*
    #
    ############################################################################
  fi
  #
  #
  ##############################################################################
  #
  # --- Dispose modified command file for next job ---
  cp -p nrhd.cmd $STADIR/rhd1.cmd
  #
  # --- Exit loop if end of chain reached ---
  if test ${ACT} = eoc
  then
    break
  fi
  #
  # --- End of loop ------------------------------------------------------------
done
#
# --- Submit next job if not end of chain reached---
if test ${ACT} != eoc
then
  cd $STADIR
  echo "Resubmit job"
#  /usr/local/bin/qsub rhd1.job
#  qsub rhd1.job
#  nice nohup rhd1.job &
  nohup rhd1.job &
else
  echo "End of job chain"
fi
#
################################################################################
\end{verbatim}}}

Basic informations about the batch system of the
\htmladdnormallinkfoot{{\AA}ngstr\"{o}m Sun cluster}{http://www.fysik4.fysik.uu.se/sunkluster/}
are available.

A more detailed description of the script will come sometimes in the future
(e.g.\ from Sven's manual\ldots).


\clearpage
%==================================================================================================
\section{Data Analysis with IDL\label{s:IDL}}\index{IDL}


In this section some basic commands for handling CO5BOLD data in IDL
are described. See also Sect.~\ref{s:IDLUIOroutines}


{\bf NOTE: Before using IDL the environment variables for the
  CO5BOLD paths should have been set. Use setarcdeppaths.sh (or .ksh,
  .csh) for this purpose. Important is \verb|${UIOPATH}| which specifies where to
  find the IDL routines for the UIO handling.}


%--------------------------------------------------------------------------------
\subsection{Preparations}

We recommend to create an initialisation file (e.g. named \ttfamily
start.pro\normalfont\,) which should be called after starting IDL
(e.g. \ttfamily @start\normalfont\,). 
This is necessary to define relevant paths of IDL subroutines and to
provide the UIO package. 
Thus, the file should contain the following: \\
\ \\
\ttfamily
; --- Add user IDL directory to search path ---\\
addpath=expand\_path('+\$UIOPATH/idl') \\
addpath=addpath+':'+expand\_path('+\$HOME/HYDRO/IDL/rhdpro') \\
if strtrim(addpath,2) ne '' then !path=addpath+':'+!path\\
delvar, addpath\\
; --- Initialize uio-routines ---\\
uio\_init, progrm='by hand'\\
\normalfont
\ \\
Alternatively, one might want to set the IDL path variable accordingly like
\begin{verbatim}
  export IDL_PATH="+${UIOPATH}/idl"
\end{verbatim}
for example in the \verb|.bashrc| file.


%--------------------------------------------------------------------------------
\subsection{CO5BOLD Data in IDL}

Important to know is that all operations can be performed in the
command line of IDL. This allows an interactive processing of CO5BOLD
data. 
Moreover, there are already prepared IDL scripts for this purpose but
most of them are rather complex and still have to be edited (e.g.
changing file names). 
For the beginning it is more clear to use single commands.  
We give a short overview of some essential commands.


%----------------------------------------
\subsubsection{Loading the Parameter File}

\ttfamily
IDL> parfile='mymodel.par'\\
IDL> par=uio\_struct\_rd(parfile)\\
\normalfont
\ \\
All control parameters are provided in the structure \ttfamily
PAR\normalfont.


%----------------------------------------
\subsubsection{Loading CO5BOLD Data (.full, .sta, .end)}

\ttfamily
IDL> modelfile='/home/user/mymodel.full' \& n=0\\
IDL> ful=uio\_dataset\_rd(modelfile,n=n)\\
\ \\
\normalfont
First the name and full path (if not in the actual directory) of the
model file and the wanted time step should be defined. Here, time
step means the consecutive number of the model snapshot in the file. 
Declaring a time step number greater than the number of snapshots
contained in the file will cause an error.\\ 
Otherwise all data of the particular time step \ttfamily
n\normalfont\, will be provided in the structure 
\ttfamily FUL\normalfont.\\
Loading more than one timestep from the same file could be achieved as 
follows: \\
\ \\
\ttfamily
IDL> uio\_openrd, nc, modelfile, outstr, ierr \\
IDL> for i=0,ntime-1 do begin \&\$\\ 
IDL>   ful=uio\_dataset\_rd(modelfile, channel=nc,ierr=ierr, outstr=err\_msg) \&\$\\ 
IDL> endfor \&\$ \\
IDL> uio\_closrd, nc \\
\normalfont

Again, this operation would cause an error if the wanted time step is
not contained in the file. 
Via checking the error flag \ttfamily ierr\normalfont\, of the routine \ttfamily
uio\_dataset\_rd\normalfont\,  such errors can be avoided.  
This way it is unnecessary to know exactly of how many time steps the
model file consists. \\
\ \\
\ttfamily
IDL> uio\_openrd, nc, modelfile, outstr, ierr \\
IDL> i=0 \\
IDL> repeat begin \&\$ \\
IDL> \quad ful=uio\_dataset\_rd(modelfile, channel=nc,ierr=ierr, outstr=err\_msg)  \&\$\\ 
IDL> \quad if (ierr eq 0) then begin \&\$ \\
IDL> \quad \quad ;--- hier Daten bearbeiten oder in anderer Variable speichern ---\\
IDL> \quad \quad i=i+1 \&\$ \\
IDL> \quad endif else begin \&\$\\ 
IDL> \quad \quad print,'IDL> Reached EOF.' \&\$\\ 
IDL> \quad endelse \&\$ \\
IDL> endrep until (ierr ne 0) or (EOF(nc)) \\ 
IDL> uio\_closrd, nc  
\normalfont

To read a number of entries from a list of files in sequence the routine
\verb|uio_datasetlist_rd.pro| (see Sect.~\ref{s:uio_dataset_rd}) is appropriate.


%----------------------------------------
\subsubsection{Loading the Equation of State}
\label{sec.loadeos}

\ttfamily
     IDL> eosfile='../eos/dat/'+par.eosfile\\
     IDL> tabinter\_rdcoeff,eosfile, eos \\
\normalfont
\ \\
The table for the equation of state is provided in the structure
\ttfamily EOS\normalfont. \\
{\bf NOTE:  Always check file name and path!}


%----------------------------------------
\subsubsection{Loading the Opacity Table}
\label{sec.loadopa}

\ttfamily
     IDL> opafile='../opa/dat/'+par.opafile\\
     IDL> dfopta,opafile\\
\normalfont
\ \\
The opacity table will be stored as common block \ttfamily
OPTA\_COMMON\normalfont. \\
{\bf NOTE:  Always check file name and path!}


%----------------------------------------
\subsubsection{Computation of Deduced Quantities}
\label{sec.eosbox}

After having read the model data (\ttfamily FUL\normalfont) 
and the tables for the equation of state (\ttfamily EOS\normalfont)
and opacity (\ttfamily OPTA\_COMMON\normalfont) (see \ref{sec.loadeos},
\ref{sec.loadopa}), more quantities can be calculated: \\
\ \\
\ttfamily
IDL> eosbox, ful, eos=eos , /opa ,ierror=ierror \\
\normalfont
This operation adds the tags 
\ttfamily EOS \normalfont 
and \ttfamily OPA \normalfont to the data structure \ttfamily
FUL\normalfont\, which contain more quantities like e.g. the
temperature (see Sect.\ref{sec.idldatastruct}).


%--------------------------------------------------------------------------------
\subsection{IDL Data Structure\label{sec.idldatastruct}}

The data structure \verb|FUL| contains the following
variables and substructures.
Use \verb|help,/str,ful|, to get this information.
See also the short description of the contents of a model file 
in Sect.~\ref{s:modelfiles}
and particularly the man-page of the script \verb|uiolook| in Sect.~\ref{s:uiolook}
which gives you even more detailed information directly from the file:

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
** Structure <8287a0c>, 9 tags, length=78404128, refs=1:
   TYPE               STRING    'uio'
   HEAD               STRUCT    -> <Anonymous> Array[1]
   DATASET_ID         STRING    'single_box'
   MODELTIME          FLOAT           10050.1
   MODELITIME         LONG            64088
   DTIME              FLOAT               0.176381
   TIME_OUT_FULL_LAST FLOAT           10050.1
   TIME_OUT_MEAN_LAST FLOAT           10040.0
   Z                  STRUCT    -> <Anonymous> Array[1]
\end{alltt}}}

If the command in Sect.\ref{sec.eosbox} has been performed, the
following substructures are present:

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
   EOS                STRUCT    -> <Anonymous> Array[1]
   OPA                STRUCT    -> <Anonymous> Array[1]
\end{alltt}}}

The substructure \verb|FUL.Z| contains the original
data arrays from the model file like the spatial axes, density
\verb|rho|,
internal energy \verb|ei|, and the three spatial
components of the velocity (\verb|v1|, \verb|v2|, \verb|v3|):

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
** Structure <8274184>, 16 tags, length=78403900, refs=2:
   TYPE               STRING    'uio'
   BOX_ID             STRING    'z'
   DIMENSION          LONG      Array[2, 3]
   TIME               FLOAT           10050.1
   ITIME              LONG            64088
   XC1                FLOAT     Array[140, 1  , 1  ]
   XC2                FLOAT     Array[1  , 140, 1  ]
   XC3                FLOAT     Array[1  , 1  , 200]
   XB1                FLOAT     Array[141, 1  , 1  ]
   XB2                FLOAT     Array[1  , 141, 1  ]
   XB3                FLOAT     Array[1  , 1  , 201]
   RHO                FLOAT     Array[140, 140, 200]
   EI                 FLOAT     Array[140, 140, 200]
   V1                 FLOAT     Array[140, 140, 200]
   V2                 FLOAT     Array[140, 140, 200]
   V3                 FLOAT     Array[140, 140, 200]
\end{alltt}}}

Spatial axes:
\ttfamily XC1\normalfont,
\ttfamily XC2\normalfont,
\ttfamily XC3\normalfont,
\ttfamily XB1\normalfont,
\ttfamily XB2\normalfont,
\ttfamily XB3\normalfont: 

The indices stand for
\ttfamily1\normalfont:x,
\ttfamily2\normalfont:y, 
\ttfamily3\normalfont:z.
\ttfamily C \normalfont for the grid cell centre,
\ttfamily B \normalfont for the boundaries. 
Most of the quantities are defined for the cell centres. 
In case of doubt, this can be found out by checking the array
dimensions.

The substructure \verb|FUL.EOS| contains important
quantities like the temperature \verb|T|, 
gas pressure \verb|P|, entropy \verb|S|:

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
** Structure <826a03c>, 6 tags, length=109760000, refs=2:
   P                  FLOAT     Array[140, 140, 200]
   DPDRHO             FLOAT     Array[140, 140, 200]
   DPDEI              FLOAT     Array[140, 140, 200]
   T                  FLOAT     Array[140, 140, 200]
   DTDEI              FLOAT     Array[140, 140, 200]
   S                  FLOAT     Array[140, 140, 200]
\end{alltt}}}

The substructure \verb|FUL.OPA| only contains the opacity \verb|KAPPA|:

{\color{DEFcolor}{\small\color{TXTcolor}\begin{alltt}
** Structure <826a5b4>, 1 tags, length=15680000, refs=2:
   KAPPA              FLOAT     Array[140, 140, 200]
\end{alltt}}}


%--------------------------------------------------------------------------------
\subsection{More IDL routines}

In the directory \ttfamily IDL/rhdpro \normalfont a lot of useful
routines can be found which can be used for further processing and
visualisation of CO5BOLD data. 
For the visualisation of 2-D models or 2-D data slices in general we
recommend \ttfamily plotfield.pro\normalfont. With \ttfamily combox.pro
\normalfont (unfortunately not commented yet) 
further quantities can be calculated.\\ 
Furthermore, we currently develop a widget-based analysis tool called 
{\bf COBOLD~AT} (abbrev.: CAT) which will help to work with CO5BOLD
data without having to write and edit own IDL code. 
The routines are stored (if available) in the directory \ttfamily
IDL/COBOLDAT \normalfont and have to be started with \ttfamily
@cat\normalfont. A more detailed documentation is planned. 
%


\clearpage
%==================================================================================================
\section{Glossary\label{s:glossary}}

\begin{itemize}

\item {\bf CO5BOLD}\index{CO5BOLD} or {\bf COBOLD} is the short form of
``COnservative COde for the COmputation of COmpressible COnvection
in a BOx of L Dimensions with l=2,3''.

\item {\bf EOS}: ``Equation Of State''

\item {\bf RHD}: ``Radiation HydroDynamics''

\item {\bf UIO}: the ``Universal Input Output'' format.
  It is used in CO5BOLD for parameter, model, mean, and EOS files.

\end{itemize}


%==================================================================================================
\printindex

\end{document}
