! Sample interface description file for Python/Fortran connection tool. ! Paul F. Dubois dubois1@llnl.gov ! More than one module is allowed, this file just has one. function doit(x) ! y = doit(x) returns y = x**2 ! x must be a Python float. doubleprecision x !scalar float double precision doit !returns scalar float end SUBROUTINE ITIMES(X, Y, N, W) ! itimes(x, y, n, w) sets w(i) = x(i) * y(i), i = 1, n integer, intent(in):: x(n), y(n) ! must have size n integer, intent(out):: w(n) integer n END SUBROUTINE itimes subroutine dtimes(x, y, n, w) ! dtimes(x, y, n, w) sets w(i) = x(i) * y(i), i = 1, n double precision, intent(in):: x(n), y(n) ! must have size n doubleprecision, intent(out):: w(n) integer n end subroutine function two (n, m, k, a, b, c) real two integer n, m, k real a(n, m), b(m, k) real, intent(out):: c(n, m) end function two function atwo (n, m, k, a, b, c) real atwo integer n, m, k real, allocatable:: a(n, m), b(m, k) real, allocatable, intent(out):: c(n, m) end function atwo subroutine copy1 (a, n, c) integer:: n = size(a) real a(n) real, intent(out):: c(n) end subroutine copy1 subroutine copy2 (n, m, a, c) integer n = size(a, 1), m = size(a, 2) real a(n, m) real, intent(out):: c(n, m) end subroutine copy2 subroutine no_return () end subroutine no_return function sarg (s, slen) ! sarg(s) returns a tuple: ! First component is 1 if s == 'yes' ! Second component is length of s. integer sarg integer, intent(out):: slen character*(*) s end subroutine sarg subroutine inoutme (n, m) integer n integer, intent(inout):: m(n) end subroutine inoutme function nocheck (n, m, z) integer nocheck integer n integer m(*) integer z(3, *) end function nocheck function work (n, x, ly, y) real work integer n = size(x), ly = (n + n) real x(n) real, intent(temporary):: y(ly) end function awork2d (n, m, x, ny, my, y) real awork2d integer n = size(x,1), m = size(x,2), ny = (n + n), my = (m + m) real, allocatable:: x(n,m) real, allocatable, intent(temporary):: y(ny,my) end function chartest (c) !returns "y" if c is x, "n" otherwise character chartest, c end function chartest function ctry (n, x, y) ! return dot product of x and y integer:: n = size(x) doubleprecision ctry doubleprecision x(n), y(n) end function ctry subroutine cout (n, x, y) ! return y = sqrt(2.)*x integer:: n = size(x) doubleprecision x(n) doubleprecision, intent(out):: y(n) end subroutine cout function c2 (n, m, x) integer:: n = size(x,1) integer:: m = size(x,2) doubleprecision c2 doubleprecision x(n,m) end function ac2 (n, m, x) integer:: n = size(x,1) integer:: m = size(x,2) doubleprecision ac2 doubleprecision, allocatable:: x(n,m) end function c3 (a) real a doubleprecision c3 end subroutine acopy2 (n, m, a, c) integer n = size(a, 1), m = size(a, 2) real, allocatable:: a(n, m) real, allocatable, intent(out):: c(n, m) end subroutine acopy2 subroutine acopy3 (n, m, p, a, c) integer n = size(a, 1), m = size(a, 2), p = size(a, 3) real, allocatable:: a(n, m, p) real, allocatable, intent(out):: c(n, m, p) end subroutine acopy3 subroutine acopy4 (n, m, p, q, a, c) integer n = size(a, 1), m = size(a, 2), p = size(a, 3), q = size(a, 4) real, allocatable:: a(n, m, p, q) real, allocatable, intent(out):: c(n, m, p, q) end subroutine acopy3