Hello Ethan,
thank you for your answer. I tried to used the flags you sent me but I have an error while running the Makefile. I copy the text below:
This is the content of the Makefile
moduleomp: moduleomp.f90
f2py --fcompiler=intelem --f90flags='-fpp -openmp' -lguide --opt='-fast' -DF2PY_REPORT_ON_ARRAY_COPY=1 -c -m moduleomp modul\
eomp.f90 only: paral :
and that is what happens running "make"
make: Warning: File `Makefile' has modification time 33 s in the future
f2py --fcompiler=intelem --f90flags='-fpp -openmp' -lguide --opt='-fast' -DF2PY_REPORT_ON_ARRAY_COPY=1 -c -m moduleomp moduleomp.f90 only: paral :
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler
options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "moduleomp" sources
f2py options: ['only:', 'paral', ':']
f2py:> /tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.c
creating /tmp/tmpK4hQam
creating /tmp/tmpK4hQam/src.linux-x86_64-2.7
Reading fortran codes...
Reading file 'moduleomp.f90' (format:free)
Post-processing...
Block: moduleomp
Block: moduleomp
In: :moduleomp:moduleomp.f90:moduleomp
get_useparameters: no module omp_lib info used by moduleomp
Block: paral
In: :moduleomp:moduleomp.f90:moduleomp:paral
get_useparameters: no module omp_lib info used by paral
Post-processing (stage 2)...
Block: moduleomp
Block: unknown_interface
Block: moduleomp
Block: paral
Building modules...
Building module "moduleomp"...
Constructing F90 module
support for "moduleomp"...
Constructing wrapper function "moduleomp.paral"...
nthreads,thread_id = paral()
Wrote C/API module "moduleomp" to file "/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.c"
Fortran 90 wrappers are saved to "/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.f90"
adding '/tmp/tmpK4hQam/src.linux-x86_64-2.7/fortranobject.c' to sources.
adding '/tmp/tmpK4hQam/src.linux-x86_64-2.7' to include_dirs.
copying /usr/import/epd/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpK4hQam/src.linux-x86_64-2.7
copying /usr/import/epd/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpK4hQam/src.linux-x86_64-2.7
adding '/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.f90' to sources.
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize
IntelEM64TFCompiler
Found executable /usr/import/intel/fce/9.0/bin/ifort
customize IntelEM64TFCompiler using build_ext
building 'moduleomp' extension
compiling C sources
C compiler: gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -fPIC
creating /tmp/tmpK4hQam/tmp
creating /tmp/tmpK4hQam/tmp/tmpK4hQam
creating /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7
compile options: '-DF2PY_REPORT_ON_ARRAY_COPY=1 -I/tmp/tmpK4hQam/src.linux-x86_64-2.7 -I/usr/import/epd/lib/python2.7/site-packages/numpy/core/include -I/usr/import/epd/include/python2.7 -c'
gcc: /tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.c
gcc: /tmp/tmpK4hQam/src.linux-x86_64-2.7/fortranobject.c
compiling Fortran 90 module sources
Fortran f77 compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -w90 -w95 -KPIC -cm -fast -tpp7 -xW
Fortran f90 compiler: /usr/import/intel/fce/9.0/bin/ifort -FR -fpp -openmp -KPIC -cm -fast -tpp7 -xW
Fortran
fix compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -fpp -openmp -KPIC -cm -fast -tpp7 -xW
compile options: '-DF2PY_REPORT_ON_ARRAY_COPY=1 -I/tmp/tmpK4hQam/src.linux-x86_64-2.7 -I/usr/import/epd/lib/python2.7/site-packages/numpy/core/include -I/usr/import/epd/include/python2.7 -c'
extra options: '-module /tmp/tmpK4hQam/ -I/tmp/tmpK4hQam/'
ifort:f90: moduleomp.f90
ifort: Command line warning: -fast overrides any subsequent processor specific option. '-xW' has no effect
compiling Fortran sources
Fortran f77 compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -w90 -w95 -KPIC -cm -fast -tpp7 -xW
Fortran f90 compiler: /usr/import/intel/fce/9.0/bin/ifort -FR -fpp -openmp -KPIC -cm -fast -tpp7 -xW
Fortran fix compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -fpp -openmp -KPIC -cm -fast -tpp7 -xW
compile options: '-DF2PY_REPORT_ON_ARRAY_COPY=1 -I/tmp/tmpK4hQam/src.linux-x86_64-2.7
-I/usr/import/epd/lib/python2.7/site-packages/numpy/core/include -I/usr/import/epd/include/python2.7 -c'
extra options: '-module /tmp/tmpK4hQam/ -I/tmp/tmpK4hQam/'
ifort:f90: /tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.f90
ifort: Command line warning: -fast overrides any subsequent processor specific option. '-xW' has no effect
/usr/import/intel/fce/9.0/bin/ifort -shared -shared -nofor_main /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.o /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7/fortranobject.o /tmp/tmpK4hQam/moduleomp.o /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.o -L/usr/import/epd/lib -lguide -lpython2.7 -o ./moduleomp.so
moduleomp.f90(16) : (col. 6) remark: OpenMP DEFINED REGION WAS PARALLELIZED.
ld: /tmp/ipo_ifortvrTUJH.o: relocation R_X86_64_PC32 against symbol `_moduleomp_mp_paral__16__par_region0' can not be used when making a shared object; recompile
with -fPIC
ld: final link failed: Bad value
moduleomp.f90(16) : (col. 6) remark: OpenMP DEFINED REGION WAS PARALLELIZED.
ld: /tmp/ipo_ifortvrTUJH.o: relocation R_X86_64_PC32 against symbol `_moduleomp_mp_paral__16__par_region0' can not be used when making a shared object; recompile with -fPIC
ld: final link failed: Bad value
error: Command "/usr/import/intel/fce/9.0/bin/ifort -shared -shared -nofor_main /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.o /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7/fortranobject.o /tmp/tmpK4hQam/moduleomp.o /tmp/tmpK4hQam/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.o -L/usr/import/epd/lib -lguide -lpython2.7 -o ./moduleomp.so" failed with exit status 1
make: *** [moduleomp] Error 1
Finally, this is the content of moduleomp.f90 (i.e. the basic "hello world" example):
module moduleomp
implicit none
contains
subroutine
paral(nthreads,thread_id)
integer, intent(out) :: nthreads, thread_id
integer OMP_GET_NUM_THREADS, OMP_GET_THREAD_NUM
!$OMP PARALLEL PRIVATE(thread_id)
thread_id = OMP_GET_THREAD_NUM()
write(*,*) 'Hello World from thread = ', thread_id
if (thread_id .eq. 0) then
nthreads = OMP_GET_NUM_THREADS()
write(*,*) 'Number of threads = ', nthreads
end if
!$OMP END PARALLEL \
end subroutine paral
end module moduleomp
And this is the simple content of my python script:
from moduleomp import moduleomp
print moduleomp.paral()
Thank you again for you
help...
Cheers!
n.
_________
_________
>Hi Noctuelles,
>
>The following flags work for me on a linux machine.
>
>F2PYFLAGS=--fcompiler=intelem --f90flags='-fpp -openmp' -lguide --opt='-fast' -DF2PY_REPORT_ON_ARRAY_COPY=1
>f2py -c sourcefile.pyf ${F2PYFLAGS} sourcefile.f90
>
>The -lguide flag is the only difference that stands out for me, I don't think -fast should matter, though you could try it too.
>
>Other information
>ifort (IFORT) 10.1 20070913
>f2py Version: 1
>numpy Version: 1.5.1
>python Version: 2.6.5
>
>I struggled with it too, and I'm about to migrate to a new machine so I'm hoping I don't have to figure it all out again on that machine. The only environment variable I can see set that seems like it might affect compilation is
>
>LIBPATH includes … intel/fce/10.0.023/lib
>
>good luck, and let us know if you get it fixed.
>
>Ethan
>
>On Jan 17, 2013, at 4:22 AM, Noctuelles <noctu111 at yahoo.es> wrote:
>
>> Dear all,