## Rank Sort Parallel Algorithm

General OpenMP discussion

### Rank Sort Parallel Algorithm

Hello! I tried to make a ranksort algorithm work parallel. When i am trying to compile the code i keep getting the following error: ranksortomp.c c:18:77 error expected ')' before numeric constant. My code is shown below.
Code: Select all
`# include <stdlib.h># include <stdio.h># include <omp.h>#define N 10int main(){      int x[N], y[N];   int i, j,k, my_num, my_place,startval,endval,rank;      for (k=0; k<N; k++)   {      x[k] = N - i;      y[k]=N-i;   }#pragma omp parallel for private(i, j, startval, endval, rank) shared(x, y, N){    rank = omp_get_thread_num ( );    startval = N*rank/N+1;    endval =  N*(rank+1)/N;    for (j=startval; j<endval; j++) {    my_num = x[j];     my_place = 0;     for (i=0; i<N; i++)    {      if ( my_num > x[i] )          my_place++;      }     y[my_place] = my_num;   }  }     for (i=0; i<N; i++)       printf("%d\n", y[i]);            return 0;}`

Does anyone has any idea for my compilation error;
mike_ledis

### Re: Rank Sort Parallel Algorithm

In line 18, the use of "parallel for" is incorrect since the statement followed is not a "for" loop. Try to just use "parallel", i.e.,
Code: Select all
`#pragma omp parallel private(i, j, startval, endval, rank) shared(x, y, N)`

I'd say the diagnosis printed from the compiler is not very useful or accurate for this case.
hhj

Posts: 16
Joined: Thu May 01, 2008 11:59 am

### Re: Rank Sort Parallel Algorithm

I removed 'for' statement but i keep getting this error! : 0 (
mike_ledis

### Re: Rank Sort Parallel Algorithm

What compiler and compiler options did you use?
hhj

Posts: 16
Joined: Thu May 01, 2008 11:59 am