\section{THE MPI MODULES}\label{sect:MPIModuleInput}

DRAGON contains two modules that enables MPI capabilities. These modules are also available to any code built
around the Ganlib kernel and can be called from CLE-2000.\cite{ganlib5,cle2000} MPI capabilities must be
activited using the {\tt mpi=1} option of the makefiles.

\subsection{The DRVMPI: module}\label{sect:DRVMPIData}

This module is a utility module related to MPI. It is mostly used to know the rank of the node running the current script. The calling specifications are:

\begin{DataStructure}{Structure \dstr{DRVMPI:}}
$[$ \dusa{NAME} \moc{:=} $]$ \moc{DRVMPI:} \moc{::} $[$ \moc{EDIT} \dusa{iprint} $]$ $[$ \moc{WORLD-SIZE} $>>$\dusa{ncpu}$<<~]$ $[~$\moc{MY-ID} $>>$\dusa{rank}$<<~]$ \\ $[[$ \moc{SETLOOP} $\{$ \moc{B0} $|$ \moc{B1} $\}$ \dusa{len} $>>$\dusa{beg}$<<$ $>>$\dusa{end}$<<$ $]]$ \\ $[$ \moc{ALLREDUCE} $\{$ \moc{SUM} $|$ \moc{PROD} $|$ \moc{MAX} $|$ \moc{MIN} $\}$ \dusa{operand} $>>$\dusa{result}$<<$ $]$ \\ $[$ \moc{TIME} $>>$\dusa{dTime}$<<~]$ $[$ \moc{BARRIER} $]$ \moc{;} \\
\end{DataStructure}

\begin{ListeDeDescription}{mmmmmmmm}

\item[\dusa{NAME}] {\tt character*12} name of a dummy data
structure to be possibly used as \dusa{NAME2} in the SNDMPI: module. It can be a linked list or an XSM file.

\item[\moc{EDIT}] keyword used to modify the print level \dusa{iprint}.

\item[\dusa{iprint}] index used to control the printing of this module. The
amount of output produced by this tracking module will vary substantially
depending on the print level specified.

\item[\moc{WORLD-SIZE}] keyword used to recover \dusa{ncpu}.

\item[\dusa{ncpu}] total number of nodes in the MPI environment.

\item[\moc{MY-ID}] keyword used to recover \dusa{rank}.

\item[\dusa{rank}] rank of the node that is running the script.

\item[\moc{SETLOOP}] keyword used to partition the set $\{0\cdots$\dusa{len}$-1\}$ or $\{1\cdots$\dusa{len}$\}$ equitably over the nodes. The result $\{$\dusa{beg}$\cdots$\dusa{end}$\}$ is different for each node.

\item[\moc{B0}] keyword used to set the intial position to 0.

\item[\moc{B1}] keyword used to set the intial position to 1.

\item[\dusa{len}] set length.

\item[\dusa{beg}] beginning of the set for the current script. Must be an integer variable.

\item[\dusa{end}] end of the set for the current script. Must be an integer variable.

\item[\moc{ALLREDUCE}] keyword used to make a computation over all the \dusa{operand} and to store the result in \dusa{result}. Problems can be encountered in the 64-bits version.

\item[\moc{SUM}] keyword used to make \moc{ALLREDUCE} perform a summation.

\item[\moc{PROD}] keyword used to make \moc{ALLREDUCE} perform a multiplication.

\item[\moc{MAX}] keyword used to make \moc{ALLREDUCE} find the maximum over all \dusa{operand}.

\item[\moc{MIN}] keyword used to make \moc{ALLREDUCE} find the maximum over all \dusa{operand}.

\item[\dusa{operand}] operand in the \moc{ALLREDUCE} calculation. Cannot be a string or a logical value.

\item[\dusa{result}] result of the \moc{ALLREDUCE} calculation. Must be a variable of the same type as \dusa{operand}.

\item[\moc{TIME}] keyword used to recover \dusa{dTime}.

\item[\dusa{dTime}] time in seconds since an arbitrary time in the past. Must be a double precision variable.

\item[\moc{BARRIER}] keyword used to stop the calculation until every node has reach this barrier.

\end{ListeDeDescription}

\dusa{NAME} is always empty. What matters is that \dusa{NAME} is no more only declared, it now exists after the call of DRVMPI: module.

The output parameters, denoted as $>>$\dusa{value}$<<$, are recovered as CLE-2000 variables in the
module data located after the \moc{::} keyword.

\subsection{The SNDMPI: module}\label{sect:SNDMPIData}

This module is used to send or receive a linked list or an XSM file from one node to another one thanks to MPI. It is possible to send a linked list into an XSM file and vice versa.
The module is blocked until the message is sent or received.
The calling specifications are:

\begin{DataStructure}{Structure \dstr{SNDMPI:}}
$[$ \dusa{NAME1} \moc{:=} $]$ \moc{SNDMPI:} $[$ \dusa{NAME2} $]$ \moc{::} $[$ \moc{EDIT} \dusa{iprint} $]$ \moc{FROM} \dusa{iFrom} \moc{TO}  $\{$ \dusa{iTo} $|$ ALL $\}$ \\ $[$ ITEM \dusa{from} $>>$\dusa{to}$<<$ $]$ \moc{;}
\end{DataStructure}

\begin{ListeDeDescription}{mmmmmmmm}

\item[\dusa{NAME1}] {\tt character*12} name of the data structure that will be received. It can be a linked list or an XSM file.

\item[\dusa{NAME2}] {\tt character*12} name of the data structure that will be sent. It can be a linked list or an XSM file. Since on the RHS, it has to exist even for receiving scripts. In this case it is recommanded to create an empty data structure \dusa{NAME2} by calling the DRVMPI: module.

\item[\moc{EDIT}] keyword used to modify the print level \dusa{iprint}.

\item[\dusa{iprint}] index used to control the printing of this module. The
amount of output produced by this tracking module will vary substantially
depending on the print level specified.

\item[\moc{FROM}] keyword used to set \dusa{iFrom}.

\item[\dusa{iFrom}] rank of the node from which \dusa{NAME2} has to be read.

\item[\moc{TO}] keyword used to set \dusa{iTo}.

\item[\dusa{iTo}] rank of the node where \dusa{NAME1} has to be written.

\item[\moc{ALL}] keyword to make every node receive \dusa{NAME2} except the node \dusa{iFrom}.

\item[\moc{ITEM}] keyword used to send the value \dusa{from} to \dusa{to} either on \dusa{iTo} or \moc{ALL} nodes. \dusa{NAME1} and \dusa{NAME2} are optional since they will be ignored.

\item[\dusa{from}] value to send. Can be an integer, a real, a double or a logical.

\item[\dusa{to}] variable used to receive \dusa{from} value. Must match \dusa{from} type.

\end{ListeDeDescription}
