Fortran 90 How to call a function in a subroutine in a module?

Posted by Feynman on Stack Overflow See other posts from Stack Overflow or by Feynman
Published on 2011-01-08T08:42:02Z Indexed on 2011/01/08 8:54 UTC
Read the original article Hit count: 394

I have a module that "contains" a subroutine that "contains" a function. I say "use themodule" in my main program and I can "call thesubroutine", but how to I get the function that is "contained" in the subroutine? The code looks like this:

module useful
integer, parameter :: N=2
double precision, parameter :: xmin=1, xmax=10, pi=3.1415926535898
double complex :: green(N,N), solution(N), k=(2.0,0.0)
contains
subroutine y(n1)
contains
function x(n1)
real :: n1, x
x=n1*(xmax-xmin)/N
end function x
end subroutine y
end module useful

© Stack Overflow or respective owner

Related posts about function

Related posts about parameters