Community
cancel
Showing results for 
Search instead for 
Did you mean: 
maria
Beginner
24 Views

Ordered directive question

I have a question about using Ordered directive.

Since we use NCPU (number of CPUs) from inputin our program, we have no problem in the following:
!$OMP parallel do if(NCPU>1) num_threads(NCPU)
......

For another section in our program, we also have no problem with the following:
!$OMP do ordered
....
!$OMP ordered
...
!$OMP end ordered


However, we have the compiler errorif we add cluase if(NCPU>1) num_threads(NCPU) to the above:
!$OMP do ordered if(NCPU>1) num_threads(NCPU)
....
!$OMP ordered
...
!$OMP end ordered

The syntax erroris 'Syntax error, found 'IF' when expecting one of : PRIVATE, FIRSTPRIVATE.....'
What directive should I use if the number of threads will be specified in the code inputs? What's the correct way of specify this? Also I can not use Default(private) directive. Since most of variables inside this ordered section are private, what's the best way to specify these variables?

Thanks, Maria


0 Kudos
1 Reply
jimdempseyatthecove
Black Belt
24 Views

Cann't say this will work

move "if(NCPU>1)" to the right most position on the !$OMP line
.and. add "if(NCPU>1)" to the !$OMP ordered (and !$OMP end ordered).

Jim Dempsey
0 Kudos