[f2py] f2py and OpenMP problem

Akand Islam <[email protected]> Thu, 30 Jun 2011 10:52:18 -0500
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Hello,
Following is my simple "omp_hello.f" program:

 PROGRAM HELLO

     INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,
    +        OMP_GET_THREAD_NUM

C     Fork a team of threads giving them their own copies of variables
!$OMP PARALLEL PRIVATE(NTHREADS, TID)


C     Obtain thread number
     TID = OMP_GET_THREAD_NUM()
     PRINT *, 'Hello World from thread = ', TID

C     Only master thread does this
     IF (TID .EQ. 0) THEN
       NTHREADS = OMP_GET_NUM_THREADS()
       PRINT *, 'Number of threads = ', NTHREADS
     END IF

C     All threads join master thread and disband
!$OMP END PARALLEL
     END

I have made a python module "omp_hello.so" through f2py by following
command:
/usr/bin/f2py2.7 -c -m omp_hello omp_hello.f --f90flags="-fopenmp -lgomp"

Now when I try to import omp_hello in python it comes up with following
errors:
import omp_hello
ImportError: /home/scipylot/Desktop/
practice/omp_hello.so: undefined symbol: omp_get_thread_num_

It seems for some reason "-fopenmp -lgomp" although shows no compilation
error,  is not connected well and thats why module "omp_hello.so" can not
execute any omp command. I will be grateful if some one please help to over
come this.

To be more specific, in my UBUNTU 11.04 system  gcc version 4.5.2, gfortran
version 4.5.2, libgomp1 version 4.5.2. My default python is 2.7. Inspecting
"nm omp_hello.so" shows following:

00003a70 T main
        U malloc@@GLIBC_2.0
        U memcpy@@GLIBC_2.0
        U memset@@GLIBC_2.0
        U omp_get_num_threads_
        U omp_get_thread_num_
00006214 b omp_hello_error
00006210 b omp_hello_module
00004320 r options.2.1509
000062d8 b save_def
00001660 t set_data
        U sprintf@@GLIBC_2.0
        U stderr@@GLIBC_2.0
        U strcmp@@GLIBC_2.0
        U strlen@@GLIBC_2.0


Thanks in advance.

-- Akand

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users