f2py loses double precision when passing to python
Question: I can't seem to get my module created with f2py to keep a number at double
precision when it is passed back to python. A minimal example, with file
fmodules.f90:

    
    
          subroutine example(output)
                  implicit none
                  double precision :: output
    cf2py         intent(out) :: output
                  output = 1.3
          end subroutine example
    

I then create the module with f2py:

    
    
    $ f2py -c -m fmodules fmodules.f90
    

and call it from python:

    
    
    >>> from fmodules import example
    >>> example()
    1.2999999523162842
    

By my count, that's about 8 digits of precision. My impression was that double
precision should give about 16. I've tried all the permutations of this I can
think of, including playing with the `.f2py_f2cmap` file. Any ideas on what I
am missing?


Answer: You should set output in the Fortran code using double precision,

    
    
    output = 1.3d0
    

In Fortran 1.3 is a single precision constant.

