Call subroutine based on character variables? Guru Required!
From: Matt (i.mosgplc_at_aunet)
Date: 01/06/05
- Next message: Rich Townsend: "Re: Call subroutine based on character variables? Guru Required!"
- Previous message: G.R.: "Re: CPU for Compaq Fortran V 6.4"
- Next in thread: Rich Townsend: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Rich Townsend: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: beliavsky_at_aol.com: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Ryo: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: bud: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: bv: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Dick Hendrickson: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Oyvind Sylta: "Re: Call subroutine based on character variables? Guru Required!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 6 Jan 2005 01:49:20 +0000
Hi there,
I've been using g77 for several years now (for various projects at
University) and I'm now in a situation whereby I have a large library
of subroutines. Several of these subroutines solve a specific set of
equations using different numerical methods (i.e. one uses the explicit
Euler method, others use various semi-implicit methods, ... etc).
In my current program I am solving this set of equations many times
over, at various different parts of the program. I want to be able to
choose which method the program will use without using hundreds of
embedded IF statements, e.g.
IF(method.EQ.1) then
CALL EXPL( ... )
ELSE
IF(method.EQ.2) then
CALL IMP1( ... )
ELSE
IF(method.EQ.3) then
CALL IMP2( ... )
... etc ...
END IF
END IF
END IF
It would be bad enough doing this just once, but as I said there are
several (currently eleven!) parts in the program where the correct
method must be chosen. However, note that the method to be employed is
chosen at run-time, and will be the same at each 'solving' instance.
I'm wondering if it would be possible to somehow call the appropriate
subroutine based on a character variable. Something along the lines of
CALL METHOD( ... )
where "METHOD" is chosen at run-time (in the previous example, it would
take the values: "EXPL", "IMP1", IMP2", ...etc). Of course, this would
be *far* neater than using nested IF statements. Is this possible in
either fortran77 or g77?
If anyone has any other suggestions, I'd be delighted to hear them! ;)
Many thanks,
-Matt
- Next message: Rich Townsend: "Re: Call subroutine based on character variables? Guru Required!"
- Previous message: G.R.: "Re: CPU for Compaq Fortran V 6.4"
- Next in thread: Rich Townsend: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Rich Townsend: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: beliavsky_at_aol.com: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Ryo: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: bud: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: bv: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Dick Hendrickson: "Re: Call subroutine based on character variables? Guru Required!"
- Reply: Oyvind Sylta: "Re: Call subroutine based on character variables? Guru Required!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|