Internal procedures cannot be used as actual arguments (e.g. Fortran 95
Handbook, Sect. 12.1.1.14).
Can someone (re)state the rationale behind this?
I am finding this increasingly annoying.
I have a subroutine which has several dummy arguments, including a
procedure name. Fine. I have a function which I want to pass as an
actual argument to another subroutine. Fine. This function uses some
of the arguments of the initial subroutine. It would seem natural to
make this function internal to the first subroutine, so that it can
access the needed arguments through host association. However, if I do
this, I cannot pass it as an actual argument to the second subroutine.
Thus, I have to make it a module procedure (in this case, in the same
module with the first subroutine) and have the needed values passed as
arguments. In the case of the first subroutine, they really are
arguments, while in the case of the second routine, they function more
as "global variables". I know that the functionality is the same, but I
like to have the code's looks correspond to what it does in a
higher-level sense. Another opportunity would to have some variables
declared in the module and assign the needed actual arguments of the
first subroutine to these and use them in the function. Not as clear as
it could be.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|