openMP compile error for simple progam
Feb 27, 2014 at 12:55am UTC
I have a simple program that runs fine as a serial code, but I would like to use openMP to parallelize a time-consuming nest of for-loops. This is the function in the code where the loops are over which I would like to invoke openMP:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
int corrFinder(vector<vector<double > > & g, int count)// correlation function
{
const double r_ave=3;
const double Lx=401.06;
const double Ly=401.06;
const double Lz=32.87;
const double cry_pe=6.75956;
const double b=40;
const int bins=200;
double x=0, y=0, z=0;
int n=0;
double N[bins]={0};
double CE[bins]={0};
#pragma omp parallel for schedule(dynamic)
for (int i=0; i<count-1; i++)
{
for (int j=i+1; j<count; j++)
{
if (g[i][2]-g[j][2] > Lx/2)
// blah blah more if statements
if (n <= 199)
#pragma omp atomic
{
N[n]=N[n]+1;
CE[n]=CE[n]+(g[i][8]+cry_pe)*(g[j][8]+cry_pe);
}
}
}
}
I get the following error when I compile, g++ myprogram.cc -o myprogram -fopenmp:
myprogram.cc: In function βint corrFinder(std::vector<std::vector<double> >&, int)β:
myprogram.cc:70:5: error: expected primary-expression before β{β token
{
^
Anyone know what I'm missing here? Thanks!
Topic archived. No new replies allowed.