\section{Example: Jacobi 1D}
Following is the content of the orchestration file jacobi.or. 

\begin{SaveVerbatim}{foodecl}
program jacobi

class  JacobiMain : MainChare;
class  JacobiWorker : ChareArray1D;
obj  workers : JacobiWorker[M];
param  lb : double[N];
param  rb : double[N];

begin
    for iter = 1 to MAX_ITER
	foreach i in workers
	    (lb[i], rb[i]) <- workers[i].produceBorders();
	    workers[i].compute(lb[i+1], rb[i-1]);
	end-foreach
    end-for
end
\end{SaveVerbatim}
\vspace{0.1in}
\smallfbox{\BUseVerbatim{foodecl}}
\vspace{0.1in}

The class {\tt JacobiMain} does not need any sequential code, so the only
sequential code are in JacobiWorker.h and JacobiWorker.C. Note that
JacobiWorker.h contains only the sequential portion of JacobiWorker's
declaration. 

\begin{SaveVerbatim}{foodecl}
#define N 512
#define M 16

int currentArray;	
double localData[2][M][N]; 
double localLB[N];
double localRB[N];
int myLeft,myRight,myUpper,myLower;

void initialize();
void compute(double lghost[], double rghost[]);
void produceBorders(outport lb,outport rb);
double abs(double d);
\end{SaveVerbatim}
\vspace{0.1in}
\smallfbox{\BUseVerbatim{foodecl}}
\vspace{0.1in}

Similarly, the sequential C code will be integrated into the generated C file.
Below is part of the sequential C code taken from JacobiWorker.C to show how
consumed parameters ({\tt rghost} and {\tt lghost} in {\tt
JacobiWorker::compute}) and produced parameters ({\tt lb} and {\tt rb} in {\tt
JacobiWorker::produceBorders}) are handled.

\begin{SaveVerbatim}{foodecl}
void JacobiWorker::compute(double rghost[], double lghost[]){
    /* local computation for updating elements*/
}

void JacobiWorker::produceBorders(outport lb, outport rb){
    produce(lb,localData[currentArray][myLeft],myLower-myUpper+1);
    produce(rb,localData[currentArray][myRight],myLower-myUpper+1);
}
\end{SaveVerbatim}
\vspace{0.1in}
\smallfbox{\BUseVerbatim{foodecl}}
\vspace{0.1in}

The user compile these input files with the following command:

\begin{SaveVerbatim}{foodecl}
  > orchc jacobi.or
\end{SaveVerbatim}
\vspace{0.1in}
\smallfbox{\BUseVerbatim{foodecl}}
\vspace{0.1in}

The compiler generates the parallel code for sending out messages, organizing
flow of control, and then it looks for sequential code files for the classes
declared, namely {\tt JacobiMain} and {\tt JacobiWorker}, and integrates them
into the final output: {\tt jacobi.h}, {\tt jacobi.C} and {\tt jacobi.ci}, which
is a Charm++ program and can be built the way a Charm++ program is built.

