\hypertarget{mdi__mpi_8c}{}\doxysection{/repo/build/\+M\+D\+I\+\_\+\+Library/\+M\+D\+I\+\_\+\+Library/mdi\+\_\+mpi.c File Reference}
\label{mdi__mpi_8c}\index{/repo/build/MDI\_Library/MDI\_Library/mdi\_mpi.c@{/repo/build/MDI\_Library/MDI\_Library/mdi\_mpi.c}}


M\+PI communication implementation.  


{\ttfamily \#include $<$mpi.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$signal.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include \char`\"{}mdi.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}mdi\+\_\+mpi.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}mdi\+\_\+global.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \mbox{\hyperlink{mdi__mpi_8c_a027fc7cf6eb7e67c2b54a6091ee4ebd5}{set\+\_\+world\+\_\+size}} (int world\+\_\+size\+\_\+in)
\begin{DoxyCompactList}\small\item\em Set the size of M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{mdi__mpi_8c_a0639f31fe7860f028614354b78b22205}{set\+\_\+world\+\_\+rank}} (int world\+\_\+rank\+\_\+in)
\begin{DoxyCompactList}\small\item\em Set the rank of this process in M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_ae5707c90e83c457a434a15879325a696}\label{mdi__mpi_8c_ae5707c90e83c457a434a15879325a696}} 
int \mbox{\hyperlink{mdi__mpi_8c_ae5707c90e83c457a434a15879325a696}{enable\+\_\+mpi\+\_\+support}} (int code\+\_\+id)
\begin{DoxyCompactList}\small\item\em Enable support for the T\+CP method. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_ae032bc6ef7a446927f7326767c9b0162}\label{mdi__mpi_8c_ae032bc6ef7a446927f7326767c9b0162}} 
int \mbox{\hyperlink{mdi__mpi_8c_ae032bc6ef7a446927f7326767c9b0162}{mpi\+\_\+on\+\_\+selection}} ()
\begin{DoxyCompactList}\small\item\em Callback when the end-\/user selects M\+PI as the method. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_adef834500d9d26158121e8ce3683b00f}\label{mdi__mpi_8c_adef834500d9d26158121e8ce3683b00f}} 
int \mbox{\hyperlink{mdi__mpi_8c_adef834500d9d26158121e8ce3683b00f}{mpi\+\_\+on\+\_\+accept\+\_\+communicator}} ()
\begin{DoxyCompactList}\small\item\em Callback when the M\+PI method must accept a communicator. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_aa098cc466a809718abfe60d8b0e328c2}\label{mdi__mpi_8c_aa098cc466a809718abfe60d8b0e328c2}} 
int \mbox{\hyperlink{mdi__mpi_8c_aa098cc466a809718abfe60d8b0e328c2}{mpi\+\_\+on\+\_\+send\+\_\+command}} (const char $\ast$command, M\+D\+I\+\_\+\+Comm comm, int $\ast$skip\+\_\+flag)
\begin{DoxyCompactList}\small\item\em Callback when the M\+PI method must send a command. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_a223bd117110a35fb549654cba21b552c}\label{mdi__mpi_8c_a223bd117110a35fb549654cba21b552c}} 
int \mbox{\hyperlink{mdi__mpi_8c_a223bd117110a35fb549654cba21b552c}{mpi\+\_\+after\+\_\+send\+\_\+command}} (const char $\ast$command, M\+D\+I\+\_\+\+Comm comm)
\begin{DoxyCompactList}\small\item\em Callback after the M\+PI method has received a command. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_a77171623c5d52d85ec77453fcf9aa921}\label{mdi__mpi_8c_a77171623c5d52d85ec77453fcf9aa921}} 
int \mbox{\hyperlink{mdi__mpi_8c_a77171623c5d52d85ec77453fcf9aa921}{mpi\+\_\+on\+\_\+recv\+\_\+command}} (M\+D\+I\+\_\+\+Comm comm)
\begin{DoxyCompactList}\small\item\em Callback when the M\+PI method must receive a command. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{mdi__mpi_8c_a44c7d40baf40b4ece1ab6208dab790eb}{mpi\+\_\+identify\+\_\+codes}} (const char $\ast$code\+\_\+name, int use\+\_\+mpi4py, M\+P\+I\+\_\+\+Comm world\+\_\+comm)
\begin{DoxyCompactList}\small\item\em Identify groups of processes belonging to the same codes. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{mdi__mpi_8c_ae66fead66748e44e6c85283f44b98a15}{mpi\+\_\+update\+\_\+world\+\_\+comm}} (void $\ast$world\+\_\+comm)
\begin{DoxyCompactList}\small\item\em Update a pointer to M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD to instead point to the intra-\/code M\+PI communicator. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{mdi__mpi_8c_a1a43a4b83b8dd21effd6ea28d9168d57}{mpi\+\_\+send}} (const void $\ast$buf, int count, M\+D\+I\+\_\+\+Datatype datatype, M\+D\+I\+\_\+\+Comm comm, int msg\+\_\+flag)
\begin{DoxyCompactList}\small\item\em Send data through an M\+DI connection, using M\+PI. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{mdi__mpi_8c_aec3b930e313d9f1294ddf87c85bd3b2a}{mpi\+\_\+recv}} (void $\ast$buf, int count, M\+D\+I\+\_\+\+Datatype datatype, M\+D\+I\+\_\+\+Comm comm, int msg\+\_\+flag)
\begin{DoxyCompactList}\small\item\em Receive data through an M\+DI connection, using M\+PI. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{mdi__mpi_8c_a23dac41bb73dc520d2786da835507b50}\label{mdi__mpi_8c_a23dac41bb73dc520d2786da835507b50}} 
int \mbox{\hyperlink{mdi__mpi_8c_a23dac41bb73dc520d2786da835507b50}{communicator\+\_\+delete\+\_\+mpi}} (void $\ast$comm)
\begin{DoxyCompactList}\small\item\em Function for M\+P\+I-\/specific deletion operations for communicator deletion. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
M\+PI communication implementation. 



\doxysubsection{Function Documentation}
\mbox{\Hypertarget{mdi__mpi_8c_a44c7d40baf40b4ece1ab6208dab790eb}\label{mdi__mpi_8c_a44c7d40baf40b4ece1ab6208dab790eb}} 
\index{mdi\_mpi.c@{mdi\_mpi.c}!mpi\_identify\_codes@{mpi\_identify\_codes}}
\index{mpi\_identify\_codes@{mpi\_identify\_codes}!mdi\_mpi.c@{mdi\_mpi.c}}
\doxysubsubsection{\texorpdfstring{mpi\_identify\_codes()}{mpi\_identify\_codes()}}
{\footnotesize\ttfamily int mpi\+\_\+identify\+\_\+codes (\begin{DoxyParamCaption}\item[{const char $\ast$}]{code\+\_\+name,  }\item[{int}]{use\+\_\+mpi4py,  }\item[{M\+P\+I\+\_\+\+Comm}]{world\+\_\+comm }\end{DoxyParamCaption})}



Identify groups of processes belonging to the same codes. 

If use\+\_\+mpi4py == 0, this function will call M\+P\+I\+\_\+\+Comm\+\_\+split to create an intra-\/code communicator for each code.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em code\+\_\+name} & M\+DI name of the code associated with this process, indicated by the user with the -\/name runtime option. \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+mpi4py} & Flag to indicate whether M\+P\+I\+\_\+\+Comm\+\_\+split should be called in order to create an intra-\/code communicator for each code. The intra-\/code communicators are created only if use\+\_\+mpi4py == 0. Should normally be set to 0, unless the code associated with this process is a Python code. In that case, the Python wrapper code will do the split instead. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{mdi__mpi_8c_aec3b930e313d9f1294ddf87c85bd3b2a}\label{mdi__mpi_8c_aec3b930e313d9f1294ddf87c85bd3b2a}} 
\index{mdi\_mpi.c@{mdi\_mpi.c}!mpi\_recv@{mpi\_recv}}
\index{mpi\_recv@{mpi\_recv}!mdi\_mpi.c@{mdi\_mpi.c}}
\doxysubsubsection{\texorpdfstring{mpi\_recv()}{mpi\_recv()}}
{\footnotesize\ttfamily int mpi\+\_\+recv (\begin{DoxyParamCaption}\item[{void $\ast$}]{buf,  }\item[{int}]{count,  }\item[{M\+D\+I\+\_\+\+Datatype}]{datatype,  }\item[{M\+D\+I\+\_\+\+Comm}]{comm,  }\item[{int}]{msg\+\_\+flag }\end{DoxyParamCaption})}



Receive data through an M\+DI connection, using M\+PI. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em buf} & Pointer to the buffer where the received data will be stored. \\
\hline
\mbox{\texttt{ in}}  & {\em count} & Number of values (integers, double precision floats, characters, etc.) to be received. \\
\hline
\mbox{\texttt{ in}}  & {\em datatype} & M\+DI handle (M\+D\+I\+\_\+\+I\+NT, M\+D\+I\+\_\+\+D\+O\+U\+B\+LE, M\+D\+I\+\_\+\+C\+H\+AR, etc.) corresponding to the type of data to be received. \\
\hline
\mbox{\texttt{ in}}  & {\em comm} & M\+DI communicator associated with the connection to the sending code. \\
\hline
\mbox{\texttt{ in}}  & {\em msg\+\_\+flag} & Type of role this data has within a message. 0\+: Not part of a message. 1\+: The header of a message. 2\+: The body (data) of a message. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{mdi__mpi_8c_a1a43a4b83b8dd21effd6ea28d9168d57}\label{mdi__mpi_8c_a1a43a4b83b8dd21effd6ea28d9168d57}} 
\index{mdi\_mpi.c@{mdi\_mpi.c}!mpi\_send@{mpi\_send}}
\index{mpi\_send@{mpi\_send}!mdi\_mpi.c@{mdi\_mpi.c}}
\doxysubsubsection{\texorpdfstring{mpi\_send()}{mpi\_send()}}
{\footnotesize\ttfamily int mpi\+\_\+send (\begin{DoxyParamCaption}\item[{const void $\ast$}]{buf,  }\item[{int}]{count,  }\item[{M\+D\+I\+\_\+\+Datatype}]{datatype,  }\item[{M\+D\+I\+\_\+\+Comm}]{comm,  }\item[{int}]{msg\+\_\+flag }\end{DoxyParamCaption})}



Send data through an M\+DI connection, using M\+PI. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em buf} & Pointer to the data to be sent. \\
\hline
\mbox{\texttt{ in}}  & {\em count} & Number of values (integers, double precision floats, characters, etc.) to be sent. \\
\hline
\mbox{\texttt{ in}}  & {\em datatype} & M\+DI handle (M\+D\+I\+\_\+\+I\+NT, M\+D\+I\+\_\+\+D\+O\+U\+B\+LE, M\+D\+I\+\_\+\+C\+H\+AR, etc.) corresponding to the type of data to be sent. \\
\hline
\mbox{\texttt{ in}}  & {\em comm} & M\+DI communicator associated with the intended recipient code. \\
\hline
\mbox{\texttt{ in}}  & {\em msg\+\_\+flag} & Type of role this data has within a message. 0\+: Not part of a message. 1\+: The header of a message. 2\+: The body (data) of a message. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{mdi__mpi_8c_ae66fead66748e44e6c85283f44b98a15}\label{mdi__mpi_8c_ae66fead66748e44e6c85283f44b98a15}} 
\index{mdi\_mpi.c@{mdi\_mpi.c}!mpi\_update\_world\_comm@{mpi\_update\_world\_comm}}
\index{mpi\_update\_world\_comm@{mpi\_update\_world\_comm}!mdi\_mpi.c@{mdi\_mpi.c}}
\doxysubsubsection{\texorpdfstring{mpi\_update\_world\_comm()}{mpi\_update\_world\_comm()}}
{\footnotesize\ttfamily int mpi\+\_\+update\+\_\+world\+\_\+comm (\begin{DoxyParamCaption}\item[{void $\ast$}]{world\+\_\+comm }\end{DoxyParamCaption})}



Update a pointer to M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD to instead point to the intra-\/code M\+PI communicator. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em world\+\_\+comm} & On input, the M\+PI communicator that spans all of the codes. On output, the M\+PI communicator that spans the single code corresponding to the calling rank. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{mdi__mpi_8c_a0639f31fe7860f028614354b78b22205}\label{mdi__mpi_8c_a0639f31fe7860f028614354b78b22205}} 
\index{mdi\_mpi.c@{mdi\_mpi.c}!set\_world\_rank@{set\_world\_rank}}
\index{set\_world\_rank@{set\_world\_rank}!mdi\_mpi.c@{mdi\_mpi.c}}
\doxysubsubsection{\texorpdfstring{set\_world\_rank()}{set\_world\_rank()}}
{\footnotesize\ttfamily int set\+\_\+world\+\_\+rank (\begin{DoxyParamCaption}\item[{int}]{world\+\_\+rank\+\_\+in }\end{DoxyParamCaption})}



Set the rank of this process in M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em world\+\_\+rank\+\_\+in} & Rank of this process within M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{mdi__mpi_8c_a027fc7cf6eb7e67c2b54a6091ee4ebd5}\label{mdi__mpi_8c_a027fc7cf6eb7e67c2b54a6091ee4ebd5}} 
\index{mdi\_mpi.c@{mdi\_mpi.c}!set\_world\_size@{set\_world\_size}}
\index{set\_world\_size@{set\_world\_size}!mdi\_mpi.c@{mdi\_mpi.c}}
\doxysubsubsection{\texorpdfstring{set\_world\_size()}{set\_world\_size()}}
{\footnotesize\ttfamily int set\+\_\+world\+\_\+size (\begin{DoxyParamCaption}\item[{int}]{world\+\_\+size\+\_\+in }\end{DoxyParamCaption})}



Set the size of M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em world\+\_\+size\+\_\+in} & Size of M\+P\+I\+\_\+\+C\+O\+M\+M\+\_\+\+W\+O\+R\+LD \\
\hline
\end{DoxyParams}
