"Jaiyong Lee" <[log in to unmask]> writes:
> Is this possible ? Name of a subroutine is stored in character string and
> that string variable is passed to another subroutine. And, within the
> second subroutine, the first subroutine is called.
>
> What I am trying to achieve is to create a string array to hold a sequence
> of subroutine names and pass that array to a subroutine to execute those
> subroutines listed in the string array.
>
> Is there a way in FORTRAN 90/95 standard ?
In a word, no.
You could have something like
CALL SUB(X,Y,Z,SUBSUB)
SUBROUTINE SUB(X,Y,Z,SUBSUB)
INTEGER :: SUBSUB
SELECT CASE (SUBSUB)
CASE(1)
CALL SUB1()
etc. Of course, SUBSUB could be an integer, character, whatever.
Obviously, this is a workaround.
What you need are pointers to functions. This has been discussed, and I
seem to recall someone saying it would probably show up in the future,
but I don't know if it will be in the next standard or one after.
It depends on what you want to do. At least since F77, you can pass the
NAME of a routine to another routine (and to another, etc). However,
these are not character strings, but routine names. Thus, they have to
be hard-wired into the code, i.e. one cannot read them from a file etc
without a workaround similar to the one above.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|