OMP_SET_NUM_THREADS()

General OpenMP discussion

OMP_SET_NUM_THREADS()

Postby morethanair » Sat Dec 13, 2008 3:57 pm

I wrote my first testing code.

----------------------------------------------------

program LoopTest

integer tid,OMP_SET_NUM_THREADS,OMP_GET_THREAD_NUM,OMP_GET_NUM_THREADS

real(16) i


!$OMP PARALLEL PRIVATE(i)
OMP_SET_NUM_THREADS(3)
tid=OMP_GET_THREAD_NUM()
if(tid .EQ. 0) then
print *, 'number of threads', OMP_GET_NUM_THREADS()
end if
do i=1,10383233,1
tid=OMP_GET_THREAD_NUM()
print *, 'thread', tid, ':', i
end do
!$OMP END PARALLEL

end program

-----------------------------------------------------------------------------------

I tried to set the number of threads by using OMP_SET_NUM_THREADS() function, but I got the syntax error on that.

Is there anything I should more?

Sorry for such a trivial question.

Thank you.
morethanair
 

Re: OMP_SET_NUM_THREADS()

Postby ejd » Sat Dec 13, 2008 6:58 pm

It it a subroutine and so it should be "call omp_set_num_threads(3)".
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: OMP_SET_NUM_THREADS()

Postby morethanair » Sat Dec 13, 2008 9:41 pm

Oh... it was my first time to use FORTRAN

Thank you so much-


but it's still not working

error #6552: The CALL statement is invoking a function subprogram as a subroutine. [OMP_SET_NUM_THREADS]

what does this error mean??
morethanair
 

Re: OMP_SET_NUM_THREADS()

Postby ejd » Mon Dec 15, 2008 9:21 am

The problem is that you have listed omp_set_num_threads in the integer declaration. This makes it think that it has a return value and is a function rather than a subroutine. You can get around this in the future by doing either of the following:
Code: Select all
f77 or f90:
include "omp_lib.h"

f90:
use omp_lib

This will give you all of the interface declarations necessary to use any of the OpenMP library routines and you will not have to remember to put them in.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 5 guests