[SciPy-user] F2PY, F90 ALLOCATED arrays and AMD64

Neilen Marais nmarais at sun.ac.za
Thu Apr 20 14:05:24 EDT 2006


Hi.

There seems to be a problem with recent version of F2PY on 64bit (or at least
my 64bit) platforms. I'm using the Intel EM64T version of Intel Fortran 9.0. By
default, this compiler doesn't work, since distutils don't recognise the EM64T
versions of the compiler. After patching numpy/distutils/fcompilers/intel.py as
explained in the thread "F2PY stopped working with new scipy", I was able to
compile the wrappers, but they don't quite work right.I think the easiest way
to explain it is by example.

The following code in the file test_data.f90 is being wrapped :

MODULE DATA
  IMPLICIT NONE
  REAL, DIMENSION(:), ALLOCATABLE :: test_arr
CONTAINS
  SUBROUTINE init()
    ALLOCATE(test_arr(10))
    test_arr=55
  END SUBROUTINE init
END MODULE DATA

using this command:
$ f2py --fcompiler=intel -m testmod -c test_data.f90

Using this version of f2py:

$ f2py -v
2.46.243_2020

I get the expected output:

$ python
Python 2.4.2 (#2, Sep 30 2005, 22:19:27) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import testmod
>>> testmod.data.init()
>>> testmod.data.test_arr
array([ 55.,  55.,  55.,  55.,  55.,  55.,  55.,  55.,  55.,  55.],'f')
>>> 

If, instead, I use this version of f2py:

$ f2py -v
2_2383

I get:

$ python
Python 2.4.2 (#2, Sep 30 2005, 22:19:27) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import testmod
>>> testmod.data.init()
>>> testmod.data.test_arr
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: negative dimensions are not allowed


I also checked on a very similarly setup 32-bit machine. I first ran into a
problem compiling:

$ f2py --fcompiler=intel -m testmod -c test_data.f90

.......

ifort:f90: test_data.f90
ifort: Command line warning: extension 'M' not supported ignored in option '-x'
ifort: Command line error: Unrecognized keyword 'SSE' for option '-arch'
ifort: Command line warning: extension 'M' not supported ignored in option '-x'
ifort: Command line error: Unrecognized keyword 'SSE' for option '-arch'
error: Command "/usr/local/bin/ifort -FR -KPIC -cm -O3 -unroll -tpp6 -xM -arch
SSE -I/tmp/tmp1fRBC7/src -I/usr/lib/python2.4/site-packages/numpy/core/include
-I/usr/include/python2.4 -c -c test_data.f90 -o /tmp/tmp1fRBC7/test_data.o
-module /tmp/tmp1fRBC7/ -I/tmp/tmp1fRBC7/" failed with exit status 1

I fixed this by commenting out the offending compiler options in
intel.py. After this, the wrapped code works both with the old and new f2py. I
must add that the 32-bit system is running python 2.4.3 instead of 2.4.2. Don't
know if this would make any difference.

Thanks
Neilen



-- 
you know its kind of tragic 
we live in the new world
but we've lost the magic
-- Battery 9 (www.battery9.co.za)




More information about the SciPy-User mailing list