- #1
pezze
- 8
- 0
Hello, I have the following doubt, maybe someone can help me with this.
Suppose I have a general purpose routine that finds the zero of a function f(x), something like
subroutine fzero( func, x1, x2, xzero )
implicit none
real, intent(in) :: x1, x2 ! Upper and lower bounds where the zero lies
real, intent(out) :: xzero ! zero of the function here
interface
real function func(x)
implicit none
real, INTENT(in) :: x
end function func
end interface
...
f = func( x )
...
end subroutine fzero
My problem is the following. The function I want to find the zero depends on some parameter, say alpha, so it would be something like function(x,alpha)
Now, to use the previous general purpose routine I need to input the alpha in some other way. One possibility is to put "alpha" in a module, something like
module parameter
implicit none
real :: alpha
end module parameter
and then define the function
real func( x )
use parameter
...
end func
That would work. But do you know of any other way of doing the same thing?
Thanks for your help!
Suppose I have a general purpose routine that finds the zero of a function f(x), something like
subroutine fzero( func, x1, x2, xzero )
implicit none
real, intent(in) :: x1, x2 ! Upper and lower bounds where the zero lies
real, intent(out) :: xzero ! zero of the function here
interface
real function func(x)
implicit none
real, INTENT(in) :: x
end function func
end interface
...
f = func( x )
...
end subroutine fzero
My problem is the following. The function I want to find the zero depends on some parameter, say alpha, so it would be something like function(x,alpha)
Now, to use the previous general purpose routine I need to input the alpha in some other way. One possibility is to put "alpha" in a module, something like
module parameter
implicit none
real :: alpha
end module parameter
and then define the function
real func( x )
use parameter
...
end func
That would work. But do you know of any other way of doing the same thing?
Thanks for your help!