Complex*16 double precision
You may run into a subtle yet critical problem using double precision complex numbers between Fortran and Python using f2py. The real issue is that f2py doesn’t seem to understand the kind parameters we specify when assigning a variable. So f2py assumes your complex numbers are single precision (8 bytes per complex number) instead of double precision (16 bytes per complex number).
You won’t get an error on compiling, but your Python program importing the Fortran .so module will give erroneous results.
use, intrinsic :: iso_c_binding, only: sp=>C_FLOAT, dp=>C_DOUBLE
assign your double-precision complex variable like
complex(dp) :: x
.f2py_f2cmapinto the top directory of your Python project (where
dict(real= dict(sp='float', dp='double'), complex = dict(sp='complex_float',dp="complex_double"))
At this time it appears we don’t use the
I notice that F90Wrap does the same.