-------------- Original message ----------------------
From: Naomi Greenberg <[log in to unmask]>
> Is there a way to call a subroutine whose name is a variable? I want a user to
> be able to pass a routine name to a program and have the program call it without
> giving the subroutine a fixed name. Any advice is appreciated.
If I understand what you want, there is a simple way to
do it. The calling routine has to know the name of the
routine it wants to pass on. Usually this is done with an
external. Something like
Program example
external this, that
call Naomis_routine (this)
call Naomis_routine (that)
...
end
subroutine naomis_routine (users_routine)
external users_routine !this is optional, but safer
...
call users_routine (whatever)
...
end
The first time, naomis_rfoutine will call subroutine this,
the next time, it will call that.
Someplace you need to provide subroutines "this" and "that".
But, they are just plain old normal fortran subroutines. You
don't need to do anything special in them or for them.
Dick Hendrickson
|