Commit af87fed7 by Francois Gygi

removed USE_MPI macros


git-svn-id: http://qboxcode.org/svn/qb/trunk@1808 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 48feca8c
......@@ -15,34 +15,31 @@
// testAndersonMixer.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: testAndersonMixer.C,v 1.7 2009-03-08 01:16:33 fgygi Exp $
#include <iostream>
#include <vector>
using namespace std;
#include "Context.h"
#include "AndersonMixer.h"
// use: testAndersonMixer ndim nmax niter
int main(int argc, char** argv)
{
#if USE_MPI
int mype;
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Init(&argc,&argv);
#endif
{
MPI_Comm_rank(MPI_COMM_WORLD,&mype);
if ( argc != 4 )
{
cout << " use: testAndersonMixer ndim nmax niter" << endl;
return 1;
}
// ndim: dimension of vector x
const int ndim = atoi(argv[1]);
// nmax: maximum dimension of subspace used for acceleration
const int nmax = atoi(argv[2]);
// niter: number of iterations
const int niter = atoi(argv[3]);
Context ctxt;
char processor_name[MPI_MAX_PROCESSOR_NAME];
int namelen;
PMPI_Get_processor_name(processor_name,&namelen);
......@@ -55,7 +52,7 @@ int main(int argc, char** argv)
xbar.resize(ndim);
fbar.resize(ndim);
AndersonMixer mixer(ndim,nmax,&ctxt);
AndersonMixer mixer(ndim,nmax,&comm);
for ( int i = 0; i < ndim; i++ )
x[i] = (i+5);
......@@ -89,10 +86,10 @@ int main(int argc, char** argv)
double resnorm = 0.0;
for ( int i = 0; i < ndim; i++ )
resnorm += f[i]*f[i];
#if USE_MPI
ctxt.dsum(1,1,&resnorm,1);
#endif
double rbuf;
MPI_Allreduce(&resnorm,&rbuf,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
resnorm = rbuf;
if ( mype == 0 )
cout << " resnorm: " << sqrt(resnorm) << endl;
mixer.update(&x[0],&f[0],&xbar[0],&fbar[0]);
......@@ -106,9 +103,7 @@ int main(int argc, char** argv)
for ( int i = 0; i < ndim; i++ )
x[i] = xbar[i] + alpha * fbar[i];
}
}
#if USE_MPI
MPI_Finalize();
#endif
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment