array-valued function as dummy argument
- From: harper@xxxxxxxxxxxxx (John Harper)
- Date: 28 Feb 2007 12:55:12 +1300
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
.
- Follow-Ups:
- Re: array-valued function as dummy argument
- From: Ron Shepard
- Re: array-valued function as dummy argument
- From: Richard Maine
- Re: array-valued function as dummy argument
- Prev by Date: Re: suggestion for new intrinsic function: CONFORM
- Next by Date: Re: character string assumed length
- Previous by thread: Matlab -> Fortran
- Next by thread: Re: array-valued function as dummy argument
- Index(es):
Relevant Pages
|
|