[Numpy-tickets] [NumPy] #147: ValueError or segfault wrapping ALLOCATABLE f90 arrays using ifort on AMD64/EM64T

NumPy numpy-tickets@scipy....
Thu Apr 19 18:15:11 CDT 2007


#147: ValueError or segfault wrapping ALLOCATABLE f90 arrays using ifort on
AMD64/EM64T
--------------------------+-------------------------------------------------
 Reporter:  NeilenMarais  |        Owner:  pearu
     Type:  defect        |       Status:  new  
 Priority:  normal        |    Milestone:       
Component:  numpy.f2py    |      Version:       
 Severity:  major         |   Resolution:       
 Keywords:                |  
--------------------------+-------------------------------------------------
Comment (by NeilenMarais):

 Well, I did some happy hacking, and I think I've found the root of the
 problem.

 The problem is an index which should be specified as pointer size but is
 specified as integer in the fortran part of the module code. When
 wrapping the following code:

 (geomwrap.f90)
 {{{
 MODULE mesh
   ! The 4 node indices per element that define all the mesh elements
   INTEGER, DIMENSION(:,:), ALLOCATABLE :: element_nodes

 CONTAINS
   SUBROUTINE init_mesh()
     ALLOCATE(element_nodes(4,2))
     element_nodes(:,1) = (/1, 2, 3, 4/)
     element_nodes(:,2) = (/1, 3, 4, 5/)
   END SUBROUTINE init_mesh
 END MODULE mesh
 }}}

 and generating wrappers:

 {{{
 f2py --fcompiler=gnu95 -m geo --build-dir test -c geomwrap.f90
 }}}

 in the file geo-f2pywrappers2.f90

 {{{
 !     -*- f90 -*-
 !     This file is autogenerated with f2py (version:2_3718)
 !     It contains Fortran 90 wrappers to fortran functions.

       subroutine f2py_mesh_getdims_element_nodes(r,s,f2pysetdata,flag)
       use mesh, only: d => element_nodes

       integer flag
       external f2pysetdata
       logical ns
       integer s(*),r,i,j
 }}}

 the definition for s(*) should be interger(8) (at least on 64-bit
 machines), i.e.
 {{{
 !     -*- f90 -*-
 !     This file is autogenerated with f2py (version:2_3718)
 !     It contains Fortran 90 wrappers to fortran functions.

       subroutine f2py_mesh_getdims_element_nodes(r,s,f2pysetdata,flag)
       use mesh, only: d => element_nodes

       integer flag
       external f2pysetdata
       logical ns
       integer(8) s(*)
       integer r,i,j
 }}}

 is correct.

 I'm going to patch f2py on my machine to generate integer(8) sized s(*),
 but this will of course be wrong on 32-bit machines. What is the
 recommended way of getting a pointer-sized int  in fortran?

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/147#comment:5>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list