I am currently wrapping fortran code with f2py
. However, even some simple tests will trigger malloc error. For example:
! file name is simple.F90
SUBROUTINE test(aout, ain, rank)
INTEGER :: rank
COMPLEX(kind=16) :: ain(rank, rank)
COMPLEX(kind=16), INTENT(out) :: aout(rank, rank)
print *, ain
aout = ain
END SUBROUTINE test
I wrapped this code with f2py -m simple -c simple.F90
and used it:
import simple
import numpy as np
ain = np.array([[1,0],[0,1]],dtype="complex")
simple.test(ain,2)
The output is rather confusing:
(2.98323129689261721470924741607413318E-4947,0.00000000000000000000000000000000000) (0.00000000000000000000000000000000000,2.98323129689261721470924741607413318E-4947) (5.43913343041483495234482095052061699E-4937,1.19445898260724927749750105155089048E-4946) (2.03058027046167518900674768173335535E-4945,5.42471021397611822645684765587671432E-4937)
Python(9481,0x7fff7ad40000) malloc: \*** error for object 0x7fabcaa1adc8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Fortran subroutine is not getting the correct array and something's wrong with the memory.
More information:
- OS: OS X
- python: 3.5.1