On Aug 17, 2006, at 1:44 PM, Alberto Fasso' wrote:
> I am completely astonished. In Fortran 77 we used to do it all the
> time,
> just assigning the subroutine or function name to a variable
> which had to be declared EXTERNAL. All the programs of integration
> worked that
> way.
> Are you saying that this is not possible in Fortran anymore???
Others have answered in more detail, but let me point out where the
misuse of terminology has confused you here.
What you had in F77 was not a variable that you could "assign"
anything to. The only form of procedure variable was a dummy
argument, which could get defined only by argument association with
an actual argument. The actual argument name had to be a hard-coded
name of an external - not a variable (unless it was another level of
dummy argument, which just punts the matter up a level). At some
point or other you had to hard-code the procedure name in the source
file. Those had-coded names are not variables in any sense of the
word (notably, they cannot vary - note the common root of the words
"variable" and "vary"). Just because something has a name does not
make it a variable; some people confuse those concepts and end up
referring to things such as named constants as variables, which then
leads to further confusions.
As some have mentioned, you could hard-code multiple names and select
among them, though such selection was made slightly awkward by the
fact that there was no form of procedure variable other than a dummy
argument.
Yes, you have been able to do that "forever", and you still can.
Sometimes when people ask about "procedure variables" that is
adequate for their needs - after all, it is useful as has been
illustrated by its past use. But other times, it doesn't fit the
application.
F2003 has procedure pointers, which are far more flexible, although
there still isn't a standard-conforming way to set such a pointer
based on an input string. The C interop stuff of F2003, which
combined with procedure pointers, provides an avenue that has at
least a reasonable amount of portability with the widely available
"dl" library on Unix (and Unix-like) systems. I've used the dl
library with f90 code, though it requires quite a bit more "trickery"
and compiler-dependence to fake the procedure pointers in f90.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|