用于无效控制谓词的Openmp Parallel(i = 1; i <ngl_-1; ++ i)

时间:2016-05-27 14:27:33

标签: c++ openmp

=“”

你好这是我的代码多重网格解算器。我正在尝试使用openmp parallel for这个特定的代码段进行并行化。但我得到的错误是

 " invalid controlling predicate for (i=1;i<ngl_-1;++i)" 

有人可以帮忙吗?

void Solver::RBGS(int l_level)
{
    int x=level-l_level;
    double ngl_= lev_Vec[x]->Grid::get_ngpValue();
    double h2_= 4.0/((ngl_-1)*(ngl_-1));
    int midval = 0.5*(ngl_-1);
    ///---------------------------------- RED UPDATE -------------------------------------------------//
    int i,j;

    #pragma omp parallel default(shared)
    #pragma omp for
    for(i=1;i<ngl_-1;++i)
    {
        if(i & 1)
        {

            for(j=1;j<ngl_-1;j+=2)
            {
                if(i==midval && j>=midval)
                {
                    lev_Vec[x]->u_app[map(i,j,ngl_)]=0.0;
                }
                else
                {
                    lev_Vec[x]->u_app[map(i,j,ngl_)] =  0.25*(lev_Vec[x]->u_app[map(i,j-1,ngl_)]    +
                    lev_Vec[x]->u_app[map(i,j+1,ngl_)]  +
                    lev_Vec[x]->u_app[map(i-1,j,ngl_)]  +
                    lev_Vec[x]->u_app[map(i+1,j,ngl_)]  +
                    (h2_ * lev_Vec[x]->frc[map(i,j,ngl_)]));
                }
            }
        }
        else
        {
            for(j=2;j<ngl_-1;j+=2)
            {
                if(i==midval && j>=midval)
                {
                    lev_Vec[x]->u_app[map(i,j,ngl_)]=0.0;
                }
                else
                {
                    lev_Vec[x]->u_app[map(i,j,ngl_)] = 0.25*(lev_Vec[x]->u_app[map(i,j-1,ngl_)] +
                    lev_Vec[x]->u_app[map(i,j+1,ngl_)]  +
                    lev_Vec[x]->u_app[map(i-1,j,ngl_)]  +
                    lev_Vec[x]->u_app[map(i+1,j,ngl_)]  +
                    (h2_ * lev_Vec[x]->frc[map(i,j,ngl_)]));
                }
            }
        }
    }
}

0 个答案:

没有答案