LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to integrate c++ into mpich (https://www.linuxquestions.org/questions/programming-9/how-to-integrate-c-into-mpich-162533/)

alisha 03-26-2004 02:51 AM

how to integrate c++ into mpich
 
hi ,

i need to make the following c++ code run by integrating it with mpich-1.2.5.2 can someone plzzzzz give me some tips on how to integrate it. i'm working on a 4 node cluster(using linux platform) implementing parallel computing but have no experience with mpich. The c++ code i want to run in mpich is:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include <process.h>
void main(void)
{
clrscr();
float U[500],V[500],THALF,DX,DT;

int NP1;
//defining constants

float T=0.0;
const float TF=20.0;
const float LEN=10.0;
const int N=10;
const float K=0.53;
const float RATIO=0.25;
const float RHO=2.70;
const float C=0.226;
V[0]=0.0;
V[N-1]=100.0;
//read in the initial temperatures and write them out
NP1=N+1;
DX=LEN/N;
DT=(RATIO*C*RHO*DX*DX)/K;
cout<<"ENTER INITIAL VALUES "<<endl;
for (int I=0;I<NP1;I++)
{ //cin>>U[I];
U[I] = 20.0;
}
for (I=0;I<NP1;I++)
{cout<<U[I];
}
getche();
cout<<"POTENTIAL VALUES IN ONE DIMENSION BY EXPLICIT METHOD"<<endl;
cout<<"FOR X="<<T<<"TO X="<<TF;
cout<<"WITH DELTA X OF"<<DX<<endl;
cout<<"AT T="<<T<<endl;
for (I=1;I<N-1;I++)
{cout<<U[I]<<" ";
}

LABEL:
{
THALF=T+(DT/2.0);
U[0]=0.0;
U[N]=100.0;
for(I=1;I<N;I++)
{
V[I]=RATIO * ((U[I+1] +U[I-1]) + ((1.0 -(2.0 *RATIO)) * U[I]));
}
T=T+DT;
V[0]=0.0;
V[N-1]=100.0;

cout<<endl<<"VALUES AT= "<<T<<endl;
for(I=0;I<=N;I++)
{ cout<<V[I]<<" ";
}
if(T>TF)
{ exit(0);
}
//now doing second set of values
THALF=T+(DT/2.0);
V[0]=0.0;
V[N]=100.0;
I=2;
for(I=1;I<N;I++)
{
U[I]=RATIO * (V[I+1] +V[I-1]) + (1.0 -(2.0 *RATIO)) * V[I];
}
T=T+DT;
U[0]=0.0;
U[N]=100.0;
cout<<endl<<"VALUES AT"<<T<<endl;

for(I=0;I<NP1;I++)
{cout<<U[I]<<" ";
}
}
while(T<=TF)
goto LABEL;
getche();
}


thanx
Alisha


All times are GMT -5. The time now is 03:09 AM.