Re: explicit array allocation 0



<mlohry@xxxxxxxxx> wrote:

On Jun 10, 1:16 pm, michaelmetc...@xxxxxxxxxxxxxx wrote:

Do you mean that you're trying to avoid the second statement in the
sequence:

allocate(a(n))
a = 0d0

Mike, correct. Is that too lazy of a question? =)
Having 20 allocations followed by 20 assignments looks ugly, heh.

Well, there is the SOURCE= option in the ALLOCATE statement in f2003.
I'm not sure how many compilers implement that feature yet. I don't
think of this as the kind of reason that feature was added, but it looks
like it ought to work.

I personally think that specifying source=0.0 is less intuitively
obvious than the separate statement, but that's just my own taste. (The
source= option is needed for other cases that could not be done with a
separate assignment statement, notably polymorphic allocation to the
same dynamic type and type parameters as source).

It also would make your code dependent on having a compiler with that
particular f2003 feature.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: CHINANET
    ... there were 84451 allocations and assignments world-wide, ... [fermi ~]$ zgrep CN RIPE.gz ...
    (comp.security.firewalls)
  • Re: Redhat certification
    ... and RIPE, the allocations and assignments of Class A, B, and C sized ... chunks is still marginally ahead of classless sized chunks (45502 ...
    (linux.redhat)
  • Re: CHINANET
    ... there were 84451 allocations and assignments world-wide, ... You list 650 address ranges out of 3527 ranges they had allocated or ... $ zgrep CN RIPE.gz ...
    (comp.security.firewalls)
  • Re: Several news in an expression with constructors throwing exceptio
    ... and A's constructor throws an exception, ... All allocations that happened before the exception will leak. ... the compiler to perform all allocations first, then all assignments. ...
    (microsoft.public.vc.language)