Print

Print


Aleksandar Donev wrote:
>
> Hi,
> > Although what Walt says is true
>
> Yes, of course, this was not the real program, just  a quick and sloppy
> example...
>
> > No, I don't think passing a rank 2 actual argument to a rank 1 dummy
> > argument is "one of the main purposes of assumed-size arrays".  One of the
> main
> > misuses of them, perhaps (if the interface is implicit).
>
> Well, say you are writing a routine that emulates RANDOM_NUMBER and you have
> a serial generator. For contiguous arrays, the best thing you can do is use
> an assumed-size array and just loop through its contents (stride 1 of
> course) populating it with random numbers. Yes, of course, you could declare
> its rank correctly and use nested DO loops to do the traversal but this is
> clumsy and less efficient (the full program I am writing will be posted
> soon!).
>
> But anyway, assumed size arrays should really be used for efficiency, not
> for ease-of-use, so I should just forget about my generic interface
> (sigh...). So although I am aware of misuses and usually do not use
> assumed-size arrays, this is not the case here...

This might be a job for TRANSFER.  Can't say as I employ it very often, if ever,
but you might be able to write a specific under your generic name which takes a
rank 2 array and passes it through transfer on the way to calling the rank 1 version.
Oh, nope -- the argument would have to be intent(in), and yours is clearly intent(out).
Well, maybe someone else has an idea along this line.  As I said, transfer is not
among my commonly used tools.  Oh yea, I think I keep seeing arguments about whether
it's likely to make a copy (loosing efficiency), too.

Maybe I should stick to talking about things I know.
Bill
--
William F. Mitchell
Mathematical and Computational Sciences Division
National Institute of Standards and Technology
[log in to unmask]     http://math.nist.gov/~mitchell