\documentstyle [12pt, sane]{article}
\setlength{\textheight}{8.7in}
\setlength{\topmargin}{-1cm}
\setlength{\oddsidemargin}{+7mm}
\setlength{\textwidth}{6.2in}
\pagestyle{fancy}
\input{psfig}

\begin{document}
\title{Flow For Message Passing Codes}
\author{Manu Natarajan }

\date{}
\maketitle

\section {Introduction}
The flows for the various codes are documented here.  The first name
refers to the routine.  The name in paranthesis refers to the file.
All codes call {\em mp\_enable\_nodes } in main2d.f which initializes the
nodal program and starts it running \footnote {Pg 19, Chap. 2 of 
CMMD User's guide has a detailed explanation.}  Although the timings are
updated after one interpolation request has been serviced by the nodal
program, the first starred function (ex. bic\_mp for bicubic interpolation)
and its descendants alone are timed to arrive at total running time for
the message passing version. Secondly, only the bicubic or bilinear
interpolation is performed on the nodes by any of the codes, due
to necessity of being able to measure either performance individually.

\section {Bicubic Interpolation - Reconstruction of Segment Approach}

The following subsections document the flow for the code resident in
\newline /home/A4F/nasa/manu/BICUBIC/INT.

\subsection {Host Program}

\begin{verbatim}
   program slgcm (main2d.f)
     ...
     ...
     ...
     step   - existing serial code    (step.f)
       bic1nu - stub for bicubic interpolation (interpol.f)
         hnint  - host node interface in host (nbill.f)
         wrap   - copy values at xx(i,j) to xx(im+i,j)  where i = 1 to 3; 
                  im is one of the parameters defined in slgcm.slgprm 
                  which changes the resolution of the grid (misc2d.f) 
\end{verbatim}

\newpage

\subsection {Node Program}

\begin{verbatim}
   program hnbill  (nbill.f)
     get_bill_params - get input parameters (nbill.f)
     nbill  - performs lasagna decomposition (nbill.f)
       set_lsd_commons - set logical layout variables (lsd.f)
       mp_send_int     - send partition bounds to other nodes (mp1.f)
       mp_send_rblock  - distribute input among other nodes   (mp1.f)
       mp_send_reals   - send other scalar inputs             (mp1.f)
       bic_mp*          - compute lat, long. indexes ii(i,j), jj(i,j)
                                                             (bicmp.f)
         locubit       - create segment(gather), interpolate (bicubic.f)
           get_lsd_bc_rng - find degree of circulation (bicubic.f)
             cmmd_reduce_int - global reduction  
           comm_south     - build southern part of segment (lsdsr.f)
             mp_sync  (mp1.f)
             mp_send_and_rcvint (mp1.f)
             circ_winbuf - send and receive winds (mp1.f)
               cmmd_send_and_receive
           comm_north     - build northern part of segment (lsdsr.f)
             mp_sync              (mp1.f)
             mp_send_and_rcvint   (mp1.f)
             circ_winbuf - send and receive winds (mp1.f)
               cmmd_send_and_receive
           readjust_jj    - generate local indices         (lsdsr.f)
           find_bc_jj+     - convenience fn.      (bicubic.f)
           cubit+          - interpolate at a point  (cubit.f)
       mp_rcv_reals   - gather interpolated results (mp1.f)
     send_bill_params - send interpolated results (nbill.f)
     print_time       - update timing results (nbill.f)
\end{verbatim}

The subroutine {\em find\_bc\_jj } was used to reduce the number of address
calculations required for the bicubic interpolation subroutine 
{\em cubit} but has in turn introduced a overhead in terms of an extra
subroutine call. Subroutine {\em cubit} is the same as in the serial code.
The subroutines followed by the {\em '+' sign} are those called in the
{\em innermost loop}.


\subsection{Host-Node Interaction}

	Figure 1 shows the flow of information to and from the nodal
program from the host program.  The subroutine hnint alone handles
the information flow in both directions on the host.  On the nodes
the subroutine ``get\_bill\_params'' receives the input parameters and
the subroutine ``send\_bill\_params'' returns the interpolated results.

\begin{figure}
\centerline{\psfig{width=6in,height=3.5in,figure=hnconn.eps}} 
\caption{Figure 1: Host Node Interaction For Bicubic Interpolation}
\end{figure} 

\newpage

\section {Bilinear Interpolation - Reconstruction of Segment Approach}

The following subsections document the flow for the code resident in
\newline /home/A4F/nasa/manu/BILINEAR/INT.  The flow is similar to that of the 
Bicubic Interpolation excepting for a few minor differences.

\subsection {Host Program}

\begin{verbatim}
   program slgcm (main2d.f)
     ...
     ...
     ...
     step   - existing serial code    (step.f)
       bill - stub for bilinear interpolation (interpol.f)
         hnint  - host node interface in host (nbill.f)

\end{verbatim}

\newpage

\subsection {Node Program}

\begin{verbatim}
   program hnbill  (nbill.f)
     get_bill_params - get input parameters (nbill.f)
     nbill  - performs lasagna decomposition (nbill.f)
       set_lsd_commons - set logical layout variables (lsd.f)
       mp_send_int     - send partition bounds to other nodes (mp1.f)
       mp_send_rblock  - distribute input among other nodes   (mp1.f)
       mp_send_reals   - send other scalar inputs             (mp1.f)
       bill_mp*          - compute lat, long. indexes ii(i,j), jj(i,j)
                                                             (billmp.f)
         lobill       - create segment(gather), interpolate (bilinear.f)
           get_lsd_bl_rng - find degree of circulation (bicubic.f)
             cmmd_reduce_int - global reduction  
           comm_south     - build southern part of segment (lsdsr.f)
             mp_sync  (mp1.f)
             mp_send_and_rcvint (mp1.f)
             circ_winbuf - send and receive winds (mp1.f)
               cmmd_send_and_receive
           comm_north     - build northern part of segment (lsdsr.f)
             mp_sync              (mp1.f)
             mp_send_and_rcvint   (mp1.f)
             circ_winbuf - send and receive winds (mp1.f)
               cmmd_send_and_receive
           readjust_jj    - generate local indices         (lsdsr.f)
           bli+          - interpolate at a point  (bilinear.f)
       mp_rcv_reals   - gather interpolated results (mp1.f)
     send_bill_params - send interpolated results (nbill.f)
     print_time       - update timing results (nbill.f)
\end{verbatim}

Subroutine {\em bli} is an inline routine in the serial code.
The subroutines followed by the {\em '+' sign} are those called in the
{\em innermost loop}.

\subsection{Host-Node Interaction}

	The same parameters are sent and returned as shown in Figure 1.
But, they correspond to different quantities.  Please see the 
internal documentation for nbill.f and also Yong Li's notes.


\section {Bilinear Interpolation - Reconstruction of Sets of Points Approach}

The following subsections document the flow for the code resident in
\newline /home/A4F/nasa/manu/BILINEAR/OLD.  All functions names followed
by a ``~`` differ from the functions used in the previous approach.


\subsection {Host Program}

\begin{verbatim}
   program slgcm (main2d.f)
     ...
     ...
     ...
     step   - existing serial code    (step.f)
       bill - stub for bilinear interpolation (interpol.f)
         hnint  - host node interface in host (nbill.f)

\end{verbatim}

\newpage

\subsection {Node Program}

\begin{verbatim}
   program hnbill  (nbill.f)
     get_bill_params - get input parameters (nbill.f)
     nbill  - performs lasagna decomposition (nbill.f)
       set_lsd_commons - set logical layout variables (lsd.f)
       mp_send_int     - send partition bounds to other nodes (mp1.f)
       mp_send_rblock  - distribute input among other nodes   (mp1.f)
       mp_send_reals   - send other scalar inputs             (mp1.f)
       bill_mp*          - compute lat, long. indexes ii(i,j), jj(i,j)
                                                             (billmp.f)
         lobill~      -  interpolate (intplst.f)
           get_lsd_bl_rng - find degree of circulation (bicubic.f)
             cmmd_reduce_int - global reduction  
           comm_south~     - gather from southern nodes (lsdsr.f)
             mp_sync  (mp1.f)
             mp_send_and_rcvint (mp1.f)
             circ_winbuf - send and receive winds (mp1.f)
               cmmd_send_and_receive
	     sel_bill_elems - reconstruct sets of points (intplst.f)
           comm_north~     - gather from northern nodes (lsdsr.f)
             mp_sync              (mp1.f)
             mp_send_and_rcvint   (mp1.f)
             circ_winbuf - send and receive winds (mp1.f)
               cmmd_send_and_receive
	     sel_bill_elems - reconstruct sets of points (intplst.f)
       mp_rcv_reals   - gather interpolated results (mp1.f)
     send_bill_params - send interpolated results (nbill.f)
     print_time       - update timing results (nbill.f)
\end{verbatim}


\subsection{Host-Node Interaction}

	It has the same Host-Node interaction as previous approach.


\end{document}

