[f2py] Problem getting my wrapped fortran code to work in python- possible Mac architecture issue?
Chelsea Sharon
c.e.sharon at gmail.com
Thu Oct 21 22:23:53 EEST 2010
Hi All-
So I'm hoping this is just a problem with being a newbie when it comes
to python, but given all the other errors I've been having with
architecture compatibility, I'm not so sure... So the idea is that I
have some fortran code that I would like to pass several variables to
in python, and get one variable back. The fortran code had the main
program, and a subroutine, so I converted the main code into a
subroutine and added the following lines to it (located after all the
variables were defined):
Cf2py intent(in) :: Temp, NCOCOLUMN, NH2
Cf2py intent(in) :: LINE1, LINE2
Cf2py intent(out) :: LINERATIO
(Originally I had specified here that Temp, NCOCOLUMN, and NH2 were
double precision, and LINE1 and LINE2 were integers, but that doesn't
seem to effect my results.) I then do and get the following:
bash-3.2$ f2py --overwrite-signature -m LVG2_SolverSingle -h
LVG2_SolverSingle.pyf LVG2_SolverSingle.f
Reading fortran codes...
Reading file 'LVG2_SolverSingle.f' (format:fix,strict)
Post-processing...
Block: LVG2_SolverSingle
Block: lvg2_solversingle
Block: gaussj
Post-processing (stage 2)...
Saving signatures to file "./LVG2_SolverSingle.pyf"
The content of LVG2_SolverSingle.pyf looks good to me- all the
variable are listed as the correct type, and have to correct intent. I
then do the following:
bash-3.2$ f2py -c LVG2_SolverSingle.pyf LVG2_SolverSingle.f
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 "LVG2_SolverSingle" sources
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6
f2py options: []
f2py: LVG2_SolverSingle.pyf
Reading fortran codes...
Reading file 'LVG2_SolverSingle.pyf' (format:free)
Post-processing...
Block: LVG2_SolverSingle
Block: lvg2_solversingle
Block: gaussj
Post-processing (stage 2)...
Building modules...
Building module "LVG2_SolverSingle"...
Constructing wrapper function "lvg2_solversingle"...
lineratio = lvg2_solversingle(temp,ncocolumn,nh2,line1,line2)
Constructing wrapper function "gaussj"...
gaussj(a,n,b,m,singular,[np,mp])
Wrote C/API module "LVG2_SolverSingle" to file
"/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/LVG2_SolverSinglemodule.c"
adding '/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/fortranobject.c'
to sources.
adding '/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6'
to include_dirs.
copying /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/f2py/src/fortranobject.c
-> /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6
copying /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/f2py/src/fortranobject.h
-> /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize NAGFCompiler
Could not locate executable f95
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could not locate executable xlf
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize GnuFCompiler
Could not locate executable g77
customize Gnu95FCompiler
Found executable /usr/local/bin/gfortran
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/distutils/fcompiler/gnu.py:125:
UserWarning: Env. variable MACOSX_DEPLOYMENT_TARGET set to 10.3
warnings.warn(s)
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'LVG2_SolverSingle' extension
compiling C sources
C compiler: gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing
-fno-common -dynamic -DNDEBUG -g -O3
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me
creating /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6
compile options:
'-I/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6
-I/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include
-I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-c'
gcc-4.0: /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/LVG2_SolverSinglemodule.c
In file included from /usr/include/architecture/i386/math.h:626,
from /usr/include/math.h:28,
from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyport.h:235,
from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:58,
from
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/LVG2_SolverSinglemodule.c:16:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building
for Intel with Mac OS X Deployment Target < 10.4 is invalid.
gcc-4.0: /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/fortranobject.c
In file included from /usr/include/architecture/i386/math.h:626,
from /usr/include/math.h:28,
from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyport.h:235,
from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:58,
from
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/fortranobject.h:7,
from
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/fortranobject.c:2:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building
for Intel with Mac OS X Deployment Target < 10.4 is invalid.
compiling Fortran sources
Fortran f77 compiler: /usr/local/bin/gfortran -Wall -ffixed-form
-fno-second-underscore -arch ppc -arch i686 -arch x86_64 -fPIC -O3
-funroll-loops
Fortran f90 compiler: /usr/local/bin/gfortran -Wall
-fno-second-underscore -arch ppc -arch i686 -arch x86_64 -fPIC -O3
-funroll-loops
Fortran fix compiler: /usr/local/bin/gfortran -Wall -ffixed-form
-fno-second-underscore -Wall -fno-second-underscore -arch ppc -arch
i686 -arch x86_64 -fPIC -O3 -funroll-loops
compile options:
'-I/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6
-I/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include
-I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-c'
gfortran:f77: LVG2_SolverSingle.f
LVG2_SolverSingle.f: In function 'gaussj':
LVG2_SolverSingle.f:1000: warning: 'irow' may be used uninitialized in
this function
LVG2_SolverSingle.f:1001: warning: 'icol' may be used uninitialized in
this function
LVG2_SolverSingle.f: In function 'gaussj':
LVG2_SolverSingle.f:1000: warning: 'irow' may be used uninitialized in
this function
LVG2_SolverSingle.f:1001: warning: 'icol' may be used uninitialized in
this function
LVG2_SolverSingle.f: In function 'gaussj':
LVG2_SolverSingle.f:1000: warning: 'irow' may be used uninitialized in
this function
LVG2_SolverSingle.f:1001: warning: 'icol' may be used uninitialized in
this function
LVG2_SolverSingle.f: In function 'lvg2_solversingle':
LVG2_SolverSingle.f:106: warning: 'recnum' may be used uninitialized
in this function
LVG2_SolverSingle.f: In function 'lvg2_solversingle':
LVG2_SolverSingle.f:106: warning: 'recnum' may be used uninitialized
in this function
LVG2_SolverSingle.f: In function 'lvg2_solversingle':
LVG2_SolverSingle.f:106: warning: 'recnum' may be used uninitialized
in this function
/usr/local/bin/gfortran -Wall -arch ppc -arch i686 -arch x86_64 -Wall
-undefined dynamic_lookup -bundle
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/LVG2_SolverSinglemodule.o
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/fortranobject.o
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/LVG2_SolverSingle.o
-lgfortran -o ./LVG2_SolverSingle.so
ld: warning: in
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/LVG2_SolverSinglemodule.o,
missing required architecture x86_64 in file
ld: warning: in
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me/src.macosx-10.3-fat-2.6/fortranobject.o,
missing required architecture x86_64 in file
ld: warning: object file compiled with -mlong-branch which is no
longer needed. To remove this warning, recompile without
-mlong-branch: /usr/local/lib/gcc/powerpc-apple-darwin8/4.2.3/crt3.o
running scons
Removing build directory
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpNiK3Me
So there are a few warnings in there. One is about the environment
variable MACOSX_DEPLOYMENT_TARGET being set for 10.3, but it needs to
be 10.4 or greater. If I set the variable (env
MACOSX_DEPLOYMENT_TARGET='10.4') in the same line as I run these f2py
commands, the warning disappears, but the behavior I'll describe below
doesn't change. Another set of warnings (found near the end of the
above dump) is about several of the .o files "missing required
architecture x86_64 in file". If I run the above using the
--arch='-arch x86_64' flag, this error does not go away (but I can see
in the output that in the calls to f77 and f90 the flag was passed,
though not to gcc), and again, it doesn't affect my results below.
So, despite the errors, my new python "package" loads just fine:
bash-3.2$ python
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import LVG2_SolverSingle
However, if I try and call the function, python quits:
>>> test = LVG2_SolverSingle.lvg2_solversingle(50.0, 1.E5, 1.E6, 5, 3)
bash-3.2$
Any ideas about what could be up? For a later step I'm going to need
to use pytables, and when I got that all installed, I had to fight
constant architecture issues (I'm running 64-bit, but had to force
everything to compile for i386), so my guess is that something similar
may be going on here. But even when I try setting architecture types
to i386 when I run f2py, instead of getting warnings I get full
errors:
lipo: /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-//cceatwO6.out
and /var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-//ccbu6xmO.out
have the same architectures (i386) and can't be in the same fat output
file
error: Command "/usr/local/bin/gfortran -Wall -ffixed-form
-fno-second-underscore -arch ppc -arch i686 -arch x86_64 -fPIC -O3
-funroll-loops -arch i386 -m32
-I/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpFaI0sJ/src.macosx-10.3-fat-2.6
-I/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include
-I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-c -c LVG2_SolverSingle.f -o
/var/folders/rd/rdcqMoAgECeHnLrFV3Tt3E+++TI/-Tmp-/tmpFaI0sJ/LVG2_SolverSingle.o"
failed with exit status 1
So I'm at a loss. Hopefully I'm just being a moron about something
obvious, but it may be a larger problem. I'd appreciate any help that
I can get.
Thanks,
Chelsea Sharon
PS- Here's a quick dump of what's all installed (let me know if I'm
missing anything missing of major relevance to f2py, but getting
pytables/hdf5 to work was so touch and go, I hesitate to try and
update any packages...):
OS: 10.6.4
python: 2.6.5
setuptools: 0.6
ipython: 0.10
numpy: 1.4.1
scipy: 0.7.2
numexpr: 1.4
cython: 0.13
nose: 0.11.4
matplotlib: 0.99.1.1
gcc: 4.0 and 4.2
hdf5: 1.8.5-patch1
pytables: the bleeding edge version
More information about the f2py-users
mailing list