array-valued function as dummy argument



In f95, can one declare a dummy argument that is a function whose
value is an array, without having to write an interface block for it?

This problem arose for me when in another thread we were offered two
different ways to randomly reorder the integers between 1 and howmany,
and I wanted to write a subroutine that could use either.

Hoping to avoid writing any interface blocks, I put the two
function declarations in a module called reorder, starting them as:
FUNCTION scatter(how_many)
INTEGER,INTENT(IN)::how_many
INTEGER scatter(how_many)
and
FUNCTION shuffle(how_many)
INTEGER,INTENT(IN)::how_many
INTEGER shuffle(how_many)

The main program begins
PROGRAM randomperm
USE reorder
and declares and initialises an integer variable called how_many.
After a CONTAINS statement, my subroutine began
SUBROUTINE testtime(method)
INTEGER,EXTERNAL::method(how_many)
because I wanted to call it twice in the main program with
CALL testtime(scatter)
CALL testtime(shuffle)

Unfortunately two different compilers told me that a dummy argument
with the EXTERNAL attribute can't also have a DIMENSION attribute.
Changing to
INTEGER,EXTERNAL::method(:)
didn't help.

Deleting an expletive, I took out the offending statement and wrote an
interface block for method. That worked, but why is it necessary, given
that the actual arguments corresponding to the dummy argument method
were in a USEd module, and EXTERNAL is the normal method to specify
that a dummy argument is a function?

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.



Relevant Pages

  • Re: use module to pass data between procedures
    ... If a single scope has both an SZ as a dummy argument ... rename the module variable for the scope in question. ... means that you can't declare SZ twice as a module variable in the same ...
    (comp.lang.fortran)
  • Re: FORMAT and INDEX problems
    ... >What do I have to undersand under a "dummy" argument? ... when you declare a function or ... subroutine F, X and Y are dummy arguments and may be declared ... You may also use *when declaring a character constant ...
    (comp.lang.fortran)
  • Re: Interface declarations
    ... Here is a question I have about explicit interfaces. ... call subroutine sub2 ... have an interface block, right? ... local dummy argument would override anything from the module scope. ...
    (comp.lang.fortran)
  • Re: Array-valued functions possible?
    ... >> specify, I want to pass the name of the function SquareRoots to ... >> SUBROUTINE MySubroutine ... > You need to add an interface block to MySubroutine: ... > Just as you declare dummy arguments using REAL, INTEGER etc, you declare ...
    (comp.lang.fortran)
  • Re: Form k = i + j and test for overflow.
    ... Brooks Moses wrote: ... One would not expect to call a subroutine without ... I had originally written it as a contained subroutine, and when I moved it to external to emphasize the separate compilation, I forgot to declare it. ... The dummy in foo is also kind 1. ...
    (comp.lang.fortran)