As others have pointed out, there is no way within the F90 standard.
That being said, it can be done in C and by extension, in fortran with
appropriate wrappers.
In general(under unix), you create a shared object library with the
functions you want (in f90 or C). Then with suitable interfaces to the c
functions, dlopen and dlsym, you can store the pointer to a named
subroutine or function in a fortran integer pointer and pass it to a
wrapper subroutine which then can call the named function. There are
several ways to handle run time argument specification from having all the
functions in the shared object having the same argument list to parsing a
string of arguments in the wrapper subroutine. Then you start getting
into all the interface work that F90 does.
It somewhat non portable, but should work on any unix/linux system.
-dr john c wright
Research Associate, Dept. of Physics
University of Wisconsin-Madison, Plasma Physics Group
1150 University Ave
Madison, WI 53706
http://aida.physics.wisc.edu/~jwright
On Tue, 29 Aug 2000, Jaiyong Lee wrote:
> Date: Tue, 29 Aug 2000 17:27:38 -0500
> From: Jaiyong Lee <[log in to unmask]>
> To: [log in to unmask]
> Subject: How to pass a subroutine to another subroutine by a string variable ?
>
> 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 ?
>
> Thanks.
>
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|