Re: Manage external functions
- From: Mike <SulfateIon@xxxxxxxxx>
- Date: Fri, 24 Oct 2008 01:21:59 -0700 (PDT)
On Oct 24, 2:41 pm, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:
On 24 okt, 07:01, Mike <Sulfate...@xxxxxxxxx> wrote:
On Oct 24, 12:17 pm, Mike <Sulfate...@xxxxxxxxx> wrote:
Hi
Is there a way to better manage some similar external functions as
input arguments in IMSL?
Let's say I use method1 and method2 in IMSL to solve the roots.
There should be different FUNCs for method 1 and method2. Currently I
create two projects for two methods and append the FUNC in the main
program, like:
proj1
module MyStuff1
contains
subroutine myMethod1()
call IMSLMethod1()
end module MyStuff1
program main
use imsl_stuff
use MyStuff
call IMSLMethod1()
end program main
FUNCTION FUNC()
================================
proj2
module MyStuff2
contains
subroutine myMethod2()
call IMSLMethod2()
end module MyStuff2
program main
use imsl_stuff
use MyStuff2
call IMSLMethod2()
end program main
FUNCTION FUNC() <==same FUNC name
I'd like to manage them better, since two projects contains similar
modules.
I also try to put FUNC into module MyStuff, however, if I use both
MuStuff modules
then may be two FUNCs will be used. That will be a bad idea.
Mike
If I do :
program main
use imsl_stuff
use MyStuff1
use MyStuff2
call IMSLMethod1()
call IMSLMethod2()
end program main
FUNCTION FUNC() <==how to specify different FUNCs here?
thank you a million.
Mike- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
That sort of functionality has been around for a very long
time in Fortran. For instance (using Fortran 90 features):
program integrate_a_bit
call integrate( f, 1.0, 2.0, result )
call integrate( g, 1.0, 10.0, result )
containing
subroutine integrate( f, a, b, result )
real :: a, b, result
interface
real function f(x)
real :: x
end interface
! compute a rough approximation of the integral over [a,b]
do i = 1,10
xc = a + (i-0.5) * (b-a)/10.0
result = result + f(x)
enddo
result = result * (b-a)/10.0
end subroutine
real function f(x)
real :: x
f = x**2
end function
real function g(x)
real :: x
g = x*expr(-x)
end function
end program
The method: you pass the function as an argument
Regards,
Arjen
Oh. The problem is the "f" function must be "f", I cannot modify it
to other names (It's defined by some library such as Numerical Recipe
or IMSL).
So two f? How to manage them, such that one f w.r.t. Method1 and
other f w.r.t. Method2?
Thanks.
Mike
.
- Follow-Ups:
- Re: Manage external functions
- From: dpb
- Re: Manage external functions
- From: glen herrmannsfeldt
- Re: Manage external functions
- References:
- Manage external functions
- From: Mike
- Re: Manage external functions
- From: Mike
- Re: Manage external functions
- From: Arjen Markus
- Manage external functions
- Prev by Date: Re: Manage external functions
- Next by Date: Re: Manage external functions
- Previous by thread: Re: Manage external functions
- Next by thread: Re: Manage external functions
- Index(es):
Relevant Pages
|