[f2py] f2py + ifort + openmp

Ee Y <[email protected]> Fri, 18 Jan 2013 10:59:51 +0000 (GMT)
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
--===============1492177327492367384==
Content-Type: multipart/alternative; boundary="-945802626-2051355274-1358506791=:37746"

---945802626-2051355274-1358506791=:37746
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello Ethan,=0A=0A=C2=A0=C2=A0=C2=A0 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:=0A=0AThis is the content of the Makefile=0A=0Amodule=
omp: moduleomp.f90=0Af2py --fcompiler=3Dintelem --f90flags=3D'-fpp -openmp'=
 -lguide --opt=3D'-fast' -DF2PY_REPORT_ON_ARRAY_COPY=3D1 -c -m moduleomp mo=
dul\=0Aeomp.f90 only: paral :=0A=0Aand that is what happens running "make"=
=0A=0Amake: Warning: File `Makefile' has modification time 33 s in the futu=
re=0Af2py --fcompiler=3Dintelem --f90flags=3D'-fpp -openmp' -lguide --opt=
=3D'-fast' -DF2PY_REPORT_ON_ARRAY_COPY=3D1 -c -m moduleomp moduleomp.f90 on=
ly: paral :=0Arunning build=0Arunning config_cc=0Aunifing config_cc, config=
, build_clib, build_ext, build commands --compiler options=0Arunning config=
_fc=0Aunifing config_fc, config, build_clib, build_ext, build commands --fc=
ompiler options=0Arunning build_src=0Abuild_src=0Abuilding extension "modul=
eomp" sources=0Af2py options: ['only:', 'paral', ':']=0Af2py:> /tmp/tmpK4hQ=
am/src.linux-x86_64-2.7/moduleompmodule.c=0Acreating /tmp/tmpK4hQam=0Acreat=
ing /tmp/tmpK4hQam/src.linux-x86_64-2.7=0AReading fortran codes...=0AReadin=
g file 'moduleomp.f90' (format:free)=0APost-processing...=0ABlock: moduleom=
p=0ABlock: moduleomp=0AIn: :moduleomp:moduleomp.f90:moduleomp=0Aget_usepara=
meters: no module omp_lib info used by moduleomp=0ABlock: paral=0AIn: :modu=
leomp:moduleomp.f90:moduleomp:paral=0Aget_useparameters: no module omp_lib =
info used by paral=0APost-processing (stage 2)...=0ABlock: moduleomp=0ABloc=
k: unknown_interface=0ABlock: moduleomp=0ABlock: paral=0ABuilding modules..=
.=0ABuilding module "moduleomp"...=0AConstructing F90 module support for "m=
oduleomp"...=0AConstructing wrapper function "moduleomp.paral"...=0Anthread=
s,thread_id =3D paral()=0AWrote C/API module "moduleomp" to file "/tmp/tmpK=
4hQam/src.linux-x86_64-2.7/moduleompmodule.c"=0AFortran 90 wrappers are sav=
ed to "/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.f90"=0Aa=
dding '/tmp/tmpK4hQam/src.linux-x86_64-2.7/fortranobject.c' to sources.=0Aa=
dding '/tmp/tmpK4hQam/src.linux-x86_64-2.7' to include_dirs.=0Acopying /usr=
/import/epd/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /=
tmp/tmpK4hQam/src.linux-x86_64-2.7=0Acopying /usr/import/epd/lib/python2.7/=
site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpK4hQam/src.linux-x8=
6_64-2.7=0Aadding '/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappe=
rs2.f90' to sources.=0Abuild_src: building npy-pkg config files=0Arunning b=
uild_ext=0Acustomize UnixCCompiler=0Acustomize UnixCCompiler using build_ex=
t=0Acustomize IntelEM64TFCompiler=0AFound executable /usr/import/intel/fce/=
9.0/bin/ifort=0Acustomize IntelEM64TFCompiler using build_ext=0Abuilding 'm=
oduleomp' extension=0Acompiling C sources=0AC compiler: gcc -pthread -fno-s=
trict-aliasing -g -O2 -DNDEBUG -O2 -fPIC=0A=0Acreating /tmp/tmpK4hQam/tmp=
=0Acreating /tmp/tmpK4hQam/tmp/tmpK4hQam=0Acreating /tmp/tmpK4hQam/tmp/tmpK=
4hQam/src.linux-x86_64-2.7=0Acompile options: '-DF2PY_REPORT_ON_ARRAY_COPY=
=3D1 -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'=0A=
gcc: /tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.c=0Agcc: /tmp/tmpK=
4hQam/src.linux-x86_64-2.7/fortranobject.c=0Acompiling Fortran 90 module so=
urces=0AFortran f77 compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -w90 =
-w95 -KPIC -cm -fast -tpp7 -xW=0AFortran f90 compiler: /usr/import/intel/fc=
e/9.0/bin/ifort -FR -fpp -openmp -KPIC -cm -fast -tpp7 -xW=0AFortran fix co=
mpiler: /usr/import/intel/fce/9.0/bin/ifort -FI -fpp -openmp -KPIC -cm -fas=
t -tpp7 -xW=0Acompile options: '-DF2PY_REPORT_ON_ARRAY_COPY=3D1 -I/tmp/tmpK=
4hQam/src.linux-x86_64-2.7 -I/usr/import/epd/lib/python2.7/site-packages/nu=
mpy/core/include -I/usr/import/epd/include/python2.7 -c'=0Aextra options: '=
-module /tmp/tmpK4hQam/ -I/tmp/tmpK4hQam/'=0Aifort:f90: moduleomp.f90=0Aifo=
rt: Command line warning: -fast overrides any subsequent processor specific=
 option.  '-xW' has no effect=0Acompiling Fortran sources=0AFortran f77 com=
piler: /usr/import/intel/fce/9.0/bin/ifort -FI -w90 -w95 -KPIC -cm -fast -t=
pp7 -xW=0AFortran f90 compiler: /usr/import/intel/fce/9.0/bin/ifort -FR -fp=
p -openmp -KPIC -cm -fast -tpp7 -xW=0AFortran fix compiler: /usr/import/int=
el/fce/9.0/bin/ifort -FI -fpp -openmp -KPIC -cm -fast -tpp7 -xW=0Acompile o=
ptions: '-DF2PY_REPORT_ON_ARRAY_COPY=3D1 -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'=0Aextra options: '-module /tmp/tmpK4hQam/=
 -I/tmp/tmpK4hQam/'=0Aifort:f90: /tmp/tmpK4hQam/src.linux-x86_64-2.7/module=
omp-f2pywrappers2.f90=0Aifort: Command line warning: -fast overrides any su=
bsequent processor specific option.  '-xW' has no effect=0A/usr/import/inte=
l/fce/9.0/bin/ifort -shared -shared -nofor_main /tmp/tmpK4hQam/tmp/tmpK4hQa=
m/src.linux-x86_64-2.7/moduleompmodule.o /tmp/tmpK4hQam/tmp/tmpK4hQam/src.l=
inux-x86_64-2.7/fortranobject.o /tmp/tmpK4hQam/moduleomp.o /tmp/tmpK4hQam/t=
mp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.o -L/usr/import/e=
pd/lib -lguide -lpython2.7 -o ./moduleomp.so=0Amoduleomp.f90(16) : (col. 6)=
 remark: OpenMP DEFINED REGION WAS PARALLELIZED.=0Ald: /tmp/ipo_ifortvrTUJH=
.o: relocation R_X86_64_PC32 against symbol `_moduleomp_mp_paral__16__par_r=
egion0' can not be used when making a shared object; recompile with -fPIC=
=0Ald: final link failed: Bad value=0Amoduleomp.f90(16) : (col. 6) remark: =
OpenMP DEFINED REGION WAS PARALLELIZED.=0Ald: /tmp/ipo_ifortvrTUJH.o: reloc=
ation R_X86_64_PC32 against symbol `_moduleomp_mp_paral__16__par_region0' c=
an not be used when making a shared object; recompile with -fPIC=0Ald: fina=
l link failed: Bad value=0Aerror: Command "/usr/import/intel/fce/9.0/bin/if=
ort -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=0Amake: *** [module=
omp] Error 1=0A=0A=0AFinally, this is the content of moduleomp.f90 (i.e. th=
e basic "hello world" example):=0A=0Amodule moduleomp=0A=0Aimplicit none=0A=
=0Acontains=0A=0Asubroutine paral(nthreads,thread_id)=0A=0Ainteger, intent(=
out) ::  nthreads, thread_id=0Ainteger OMP_GET_NUM_THREADS, OMP_GET_THREAD_=
NUM=0A=0A=0A!$OMP PARALLEL PRIVATE(thread_id) =0A=0Athread_id =3D OMP_GET_T=
HREAD_NUM()=0Awrite(*,*) 'Hello World from thread =3D ', thread_id=0A=0Aif =
(thread_id .eq. 0) then=0Anthreads =3D OMP_GET_NUM_THREADS()=0Awrite(*,*) '=
Number of threads =3D ', nthreads=0Aend if=0A=0A!$OMP END PARALLEL         =
                                                                        \=
=0A=0Aend subroutine paral=0A=0Aend module moduleomp=0A=0A=0AAnd this is th=
e simple content of my python script:=0A=0Afrom moduleomp import moduleomp=
=0A=0Aprint moduleomp.paral()=0A=0A=0A=0AThank you again for you help...=0A=
=0ACheers!=0An.=0A_________=0A_________=0A=0A=0A=0A>Hi Noctuelles, =0A>=0A>=
The following flags work for me on a linux machine. =0A>=0A>F2PYFLAGS=3D--f=
compiler=3Dintelem --f90flags=3D'-fpp -openmp' -lguide --opt=3D'-fast' -DF2=
PY_REPORT_ON_ARRAY_COPY=3D1=0A>f2py -c sourcefile.pyf ${F2PYFLAGS} sourcefi=
le.f90=0A>=0A>The -lguide flag is the only difference that stands out for m=
e, I don't think -fast should matter, though you could try it too. =0A>=0A>=
Other information=0A>ifort (IFORT) 10.1 20070913=0A>f2py Version:     1=0A>=
numpy Version: 1.5.1=0A>python Version: 2.6.5=0A>=0A>I struggled with it to=
o, 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 c=
an see set that seems like it might affect compilation is=0A>=0A>LIBPATH in=
cludes  =E2=80=A6 intel/fce/10.0.023/lib=0A>=0A>good luck, and let us know =
if you get it fixed.  =0A>=0A>Ethan=0A>=0A>On Jan 17, 2013, at 4:22 AM, Noc=
tuelles <noctu111 at yahoo.es> wrote:=0A>=0A>>Dear all, >>>>I am new to the=
 mailing list and almost new to python/fortran programming. >>However, that=
 is my problem. >>>>I wrote a code in python that uses modules written in f=
ortran. Then, for the >>compilation in the Makefile I put >>>>f2py --fcompi=
ler=3Dintelem -c -m modules modules.f90 only : mod1 mod2 mod3 : >>>>and eve=
rything works fine. >>>>Since in the fortran modules there are many do loop=
s, I want them to run even >>faster than now, that's why I learned how to u=
se OPENMP, but I have a problem >>while compiling, I mean, while running th=
e Makefile. >>>>In fact, if I use as a fortran compiler gfortran, I have to=
 add the flags >>--opt=3D"-fopenmp -O3", i.e. >>>>f2py --fcompiler=3Dgfortr=
an --opt=3D"-fopenmp -O3" -c -m modules modules.f90 only : >>mod1 mod2 mod3=
 : >>>>and in this way I can create modules.so and my script can run in par=
allel. >>>>My problem is that if I run the python script with fortran modul=
es compiled by >>gfortran, I have a
 segmentation fault. >>That's way I have to use ifort (this explains why I =
use the --fcompiler=3Dintelem >>in the first example). >>>>f2py --fcompiler=
=3Dintelem --opt=3D"-fopenmp -O3" -c -m modules modules.f90 only : >>mod1 m=
od2 mod3 : >>>>BUT... If I use ifort and put --opt=3D"-fopenmp -O3" ... the=
 Makefile works, it >>creates modules.so, but the python script does not ru=
n in parallel! >>>>I also tried with the following flags (I found while goo=
gling), but in this last >>case the modules.so file is not created. >>>>f2p=
y --fcompiler=3Dintelem -c --opt=3D"-O3" --f90flags=3D"-fpp -openmp -D__OPE=
NMP" >>-liomp5 -m modules modules.f90 only : mod1 mod2 mod3 : >>>>Have you =
any idea? >>>>Thanks for your attention, >>best regards. >>>>Noctuelles
---945802626-2051355274-1358506791=:37746
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><body><div style=3D"color:#000; background-color:#fff; font-family:ti=
mes new roman, new york, times, serif;font-size:12pt"><pre>Hello Ethan,<br>=
<br><span class=3D"tab">&nbsp;&nbsp;&nbsp; thank you for your answer. I tri=
ed to used the flags you sent me but I have an error while running the Make=
file. I copy the text below:<br><br>This is the content of the Makefile<br>=
<br>moduleomp: moduleomp.f90<br>        f2py --fcompiler=3Dintelem --f90fla=
gs=3D'-fpp -openmp' -lguide --opt=3D'-fast' -DF2PY_REPORT_ON_ARRAY_COPY=3D1=
 -c -m moduleomp modul\<br>eomp.f90 only: paral :<br><br>and that is what h=
appens running "make"<br><br>make: Warning: File `Makefile' has modificatio=
n time 33 s in the future<br>f2py --fcompiler=3Dintelem --f90flags=3D'-fpp =
-openmp' -lguide --opt=3D'-fast' -DF2PY_REPORT_ON_ARRAY_COPY=3D1 -c -m modu=
leomp moduleomp.f90 only: paral :<br>running build<br>running config_cc<br>=
unifing config_cc, config, build_clib, build_ext, build commands --compiler
 options<br>running config_fc<br>unifing config_fc, config, build_clib, bui=
ld_ext, build commands --fcompiler options<br>running build_src<br>build_sr=
c<br>building extension "moduleomp" sources<br>f2py options: ['only:', 'par=
al', ':']<br>f2py:&gt; /tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.=
c<br>creating /tmp/tmpK4hQam<br>creating /tmp/tmpK4hQam/src.linux-x86_64-2.=
7<br>Reading fortran codes...<br>=09Reading file 'moduleomp.f90' (format:fr=
ee)<br>Post-processing...<br>=09Block: moduleomp<br>=09=09=09Block: moduleo=
mp<br>In: :moduleomp:moduleomp.f90:moduleomp<br>get_useparameters: no modul=
e omp_lib info used by moduleomp<br>=09=09=09=09Block: paral<br>In: :module=
omp:moduleomp.f90:moduleomp:paral<br>get_useparameters: no module omp_lib i=
nfo used by paral<br>Post-processing (stage 2)...<br>=09Block: moduleomp<br=
>=09=09Block: unknown_interface<br>=09=09=09Block: moduleomp<br>=09=09=09=
=09Block: paral<br>Building modules...<br>=09Building module "moduleomp"...=
<br>=09=09Constructing F90 module
 support for "moduleomp"...<br>=09=09=09Constructing wrapper function "modu=
leomp.paral"...<br>=09=09=09  nthreads,thread_id =3D paral()<br>=09Wrote C/=
API module "moduleomp" to file "/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleo=
mpmodule.c"<br>=09Fortran 90 wrappers are saved to "/tmp/tmpK4hQam/src.linu=
x-x86_64-2.7/moduleomp-f2pywrappers2.f90"<br>  adding '/tmp/tmpK4hQam/src.l=
inux-x86_64-2.7/fortranobject.c' to sources.<br>  adding '/tmp/tmpK4hQam/sr=
c.linux-x86_64-2.7' to include_dirs.<br>copying /usr/import/epd/lib/python2=
.7/site-packages/numpy/f2py/src/fortranobject.c -&gt; /tmp/tmpK4hQam/src.li=
nux-x86_64-2.7<br>copying /usr/import/epd/lib/python2.7/site-packages/numpy=
/f2py/src/fortranobject.h -&gt; /tmp/tmpK4hQam/src.linux-x86_64-2.7<br>  ad=
ding '/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.f90' to s=
ources.<br>build_src: building npy-pkg config files<br>running build_ext<br=
>customize UnixCCompiler<br>customize UnixCCompiler using build_ext<br>cust=
omize
 IntelEM64TFCompiler<br>Found executable /usr/import/intel/fce/9.0/bin/ifor=
t<br>customize IntelEM64TFCompiler using build_ext<br>building 'moduleomp' =
extension<br>compiling C sources<br>C compiler: gcc -pthread -fno-strict-al=
iasing -g -O2 -DNDEBUG -O2 -fPIC<br><br>creating /tmp/tmpK4hQam/tmp<br>crea=
ting /tmp/tmpK4hQam/tmp/tmpK4hQam<br>creating /tmp/tmpK4hQam/tmp/tmpK4hQam/=
src.linux-x86_64-2.7<br>compile options: '-DF2PY_REPORT_ON_ARRAY_COPY=3D1 -=
I/tmp/tmpK4hQam/src.linux-x86_64-2.7 -I/usr/import/epd/lib/python2.7/site-p=
ackages/numpy/core/include -I/usr/import/epd/include/python2.7 -c'<br>gcc: =
/tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleompmodule.c<br>gcc: /tmp/tmpK4hQa=
m/src.linux-x86_64-2.7/fortranobject.c<br>compiling Fortran 90 module sourc=
es<br>Fortran f77 compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -w90 -w=
95 -KPIC -cm -fast -tpp7 -xW<br>Fortran f90 compiler: /usr/import/intel/fce=
/9.0/bin/ifort -FR -fpp -openmp -KPIC -cm -fast -tpp7 -xW<br>Fortran
 fix compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -fpp -openmp -KPIC -=
cm -fast -tpp7 -xW<br>compile options: '-DF2PY_REPORT_ON_ARRAY_COPY=3D1 -I/=
tmp/tmpK4hQam/src.linux-x86_64-2.7 -I/usr/import/epd/lib/python2.7/site-pac=
kages/numpy/core/include -I/usr/import/epd/include/python2.7 -c'<br>extra o=
ptions: '-module /tmp/tmpK4hQam/ -I/tmp/tmpK4hQam/'<br>ifort:f90: moduleomp=
.f90<br>ifort: Command line warning: -fast overrides any subsequent process=
or specific option.  '-xW' has no effect<br>compiling Fortran sources<br>Fo=
rtran f77 compiler: /usr/import/intel/fce/9.0/bin/ifort -FI -w90 -w95 -KPIC=
 -cm -fast -tpp7 -xW<br>Fortran f90 compiler: /usr/import/intel/fce/9.0/bin=
/ifort -FR -fpp -openmp -KPIC -cm -fast -tpp7 -xW<br>Fortran fix compiler: =
/usr/import/intel/fce/9.0/bin/ifort -FI -fpp -openmp -KPIC -cm -fast -tpp7 =
-xW<br>compile options: '-DF2PY_REPORT_ON_ARRAY_COPY=3D1 -I/tmp/tmpK4hQam/s=
rc.linux-x86_64-2.7
 -I/usr/import/epd/lib/python2.7/site-packages/numpy/core/include -I/usr/im=
port/epd/include/python2.7 -c'<br>extra options: '-module /tmp/tmpK4hQam/ -=
I/tmp/tmpK4hQam/'<br>ifort:f90: /tmp/tmpK4hQam/src.linux-x86_64-2.7/moduleo=
mp-f2pywrappers2.f90<br>ifort: Command line warning: -fast overrides any su=
bsequent processor specific option.  '-xW' has no effect<br>/usr/import/int=
el/fce/9.0/bin/ifort -shared -shared -nofor_main /tmp/tmpK4hQam/tmp/tmpK4hQ=
am/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<br>moduleomp.f90(16) : (col. =
6) remark: OpenMP DEFINED REGION WAS PARALLELIZED.<br>ld: /tmp/ipo_ifortvrT=
UJH.o: relocation R_X86_64_PC32 against symbol `_moduleomp_mp_paral__16__pa=
r_region0' can not be used when making a shared object; recompile
 with -fPIC<br>ld: final link failed: Bad value<br>moduleomp.f90(16) : (col=
. 6) remark: OpenMP DEFINED REGION WAS PARALLELIZED.<br>ld: /tmp/ipo_ifortv=
rTUJH.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 -f=
PIC<br>ld: final link failed: Bad value<br>error: Command "/usr/import/inte=
l/fce/9.0/bin/ifort -shared -shared -nofor_main /tmp/tmpK4hQam/tmp/tmpK4hQa=
m/src.linux-x86_64-2.7/moduleompmodule.o /tmp/tmpK4hQam/tmp/tmpK4hQam/src.l=
inux-x86_64-2.7/fortranobject.o /tmp/tmpK4hQam/moduleomp.o /tmp/tmpK4hQam/t=
mp/tmpK4hQam/src.linux-x86_64-2.7/moduleomp-f2pywrappers2.o -L/usr/import/e=
pd/lib -lguide -lpython2.7 -o ./moduleomp.so" failed with exit status 1<br>=
make: *** [moduleomp] Error 1<br><br><br>Finally, this is the content of mo=
duleomp.f90 (i.e. the basic "hello world" example):<br><br>module moduleomp=
<br><br>  implicit none<br><br>contains<br><br>  subroutine
 paral(nthreads,thread_id)<br><br>    integer, intent(out) ::  nthreads, th=
read_id<br>    integer OMP_GET_NUM_THREADS, OMP_GET_THREAD_NUM<br><br><br>!=
$OMP PARALLEL PRIVATE(thread_id)                                           =
                        <br><br>    thread_id =3D OMP_GET_THREAD_NUM()<br> =
   write(*,*) 'Hello World from thread =3D ', thread_id<br><br>    if (thre=
ad_id .eq. 0) then<br>       nthreads =3D OMP_GET_NUM_THREADS()<br>       w=
rite(*,*) 'Number of threads =3D ', nthreads<br>    end if<br><br>!$OMP END=
 PARALLEL                                                                  =
               \<br>                                                       =
                                             <br>  end subroutine paral<br>=
<br>end module moduleomp<br><br><br>And this is the simple content of my py=
thon script:<br><br>from moduleomp import moduleomp<br><br>print moduleomp.=
paral()<br><br><br><br>Thank you again for you
 help...<br><br>Cheers!<br>n.<br>_________<br>_________<br><br><br></span><=
br>&gt;Hi Noctuelles, =0A&gt;=0A&gt;The following flags work for me on a li=
nux machine. =0A&gt;=0A&gt;F2PYFLAGS=3D--fcompiler=3Dintelem --f90flags=3D'=
-fpp -openmp' -lguide --opt=3D'-fast' -DF2PY_REPORT_ON_ARRAY_COPY=3D1=0A&gt=
;f2py -c sourcefile.pyf ${F2PYFLAGS} sourcefile.f90=0A&gt;=0A&gt;The -lguid=
e flag is the only difference that stands out for me, I don't think -fast s=
hould matter, though you could try it too. =0A&gt;=0A&gt;Other information=
=0A&gt;ifort (IFORT) 10.1 20070913=0A&gt;f2py Version:     1=0A&gt;numpy Ve=
rsion: 1.5.1=0A&gt;python Version: 2.6.5=0A&gt;=0A&gt;I struggled with it t=
oo, 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=0A&gt;=0A&gt;LIB=
PATH includes  =E2=80=A6 intel/fce/10.0.023/lib=0A&gt;=0A&gt;good luck, and=
 let us know if you get it fixed.  =0A&gt;=0A&gt;Ethan=0A&gt;=0A&gt;On Jan =
17, 2013, at 4:22 AM, Noctuelles &lt;<a href=3D"http://cens.ioc.ee/mailman/=
listinfo/f2py-users">noctu111 at yahoo.es</a>&gt; wrote:=0A&gt;=0A&gt;&gt;<=
i> Dear all,=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i>    I am new to the mailin=
g list and almost new to python/fortran programming.=0A</i>&gt;&gt;<i> Howe=
ver, that is my problem.=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> I wrote a cod=
e in python that uses modules written in fortran. Then, for the=0A</i>&gt;&=
gt;<i> compilation in the Makefile I put=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<=
i> f2py --fcompiler=3Dintelem -c -m modules modules.f90 only : mod1 mod2 mo=
d3 :=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> and everything works fine.=0A</i>=
&gt;&gt;<i> =0A</i>&gt;&gt;<i> Since in the fortran modules there are many =
do loops, I want them to run even=0A</i>&gt;&gt;<i> faster than now, that's=
 why I learned how to use OPENMP, but I have a problem=0A</i>&gt;&gt;<i> wh=
ile compiling, I mean, while running the Makefile.=0A</i>&gt;&gt;<i> =0A</i=
>&gt;&gt;<i> In fact, if I use as a fortran compiler gfortran, I have to ad=
d the flags=0A</i>&gt;&gt;<i> --opt=3D"-fopenmp -O3", i.e.=0A</i>&gt;&gt;<i=
> =0A</i>&gt;&gt;<i> f2py --fcompiler=3Dgfortran --opt=3D"-fopenmp -O3" -c =
-m modules modules.f90 only :=0A</i>&gt;&gt;<i> mod1 mod2 mod3 :=0A</i>&gt;=
&gt;<i> =0A</i>&gt;&gt;<i> and in this way I can create modules.so and my s=
cript can run in parallel.=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> My problem =
is that if I run the python script with fortran modules compiled by=0A</i>&=
gt;&gt;<i> gfortran, I have a segmentation fault.=0A</i>&gt;&gt;<i> That's =
way I have to use ifort (this explains why I use the --fcompiler=3Dintelem=
=0A</i>&gt;&gt;<i> in the first example).=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;=
<i> f2py --fcompiler=3Dintelem --opt=3D"-fopenmp -O3" -c -m modules modules=
.f90 only :=0A</i>&gt;&gt;<i> mod1 mod2 mod3 :=0A</i>&gt;&gt;<i> =0A</i>&gt=
;&gt;<i> BUT... If I use ifort and put --opt=3D"-fopenmp -O3" ... the Makef=
ile works, it=0A</i>&gt;&gt;<i> creates modules.so, but the python script d=
oes not run in parallel!=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> I also tried =
with the following flags (I found while googling), but in this last=0A</i>&=
gt;&gt;<i> case the modules.so file is not created.=0A</i>&gt;&gt;<i> =0A</=
i>&gt;&gt;<i> f2py --fcompiler=3Dintelem -c --opt=3D"-O3" --f90flags=3D"-fp=
p -openmp -D__OPENMP"=0A</i>&gt;&gt;<i> -liomp5 -m modules modules.f90 only=
 : mod1 mod2 mod3 :=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> Have you any idea?=
=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> Thanks for your attention,=0A</i>&gt;=
&gt;<i> best regards.=0A</i>&gt;&gt;<i> =0A</i>&gt;&gt;<i> Noctuelles</i></=
pre></div></body></html>
---945802626-2051355274-1358506791=:37746--


--===============1492177327492367384==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============1492177327492367384==--