Dear all,

Sorry about being new to both Fortran 90 and f2py.

I have a module in fortran, written as follows, with a module-scope variable dp:

========================================
! testf2py.f90
module testf2py
    implicit none
    private
    public dp, i1
    integer, parameter :: dp=kind(0.d0)
contains
    real(dp) function i1(m)
        real(dp), intent(in) :: m(3, 3)
        i1 = m(1, 1) + m(2, 2) + m(3, 3)
        return
    end function i1
end module testf2py
========================================

Then, if I run f2py -c testf2py.f90 -m testf2py

It would report an error, stating that dp was not declared.

If I copy the module-scope to the function-scope, it would work.

========================================
! testf2py.f90
module testf2py
    implicit none
    private
    public i1
    integer, parameter :: dp=kind(0.d0)
contains
    real(dp) function i1(m)
        integer, parameter :: dp=kind(0.d0)
        real(dp), intent(in) :: m(3, 3)
        i1 = m(1, 1) + m(2, 2) + m(3, 3)
        return
    end function i1
end module testf2py
========================================

However, this does not look like the best coding practice though, as
it is pretty "wet".

Any ideas?

Thanks,

Shawn

-- 
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
[email protected]
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to