Re: allocatable array *not* equivalent to dynamic allocation?



Craig Powers wrote:

(snip regarding reallocation)

As I understand it (not having looked at it lately), even the "normal" dynamic memory access of the C++ (1998) standard library uses this form of extending something. It's just that it gets buried under the hood of the standard templates, something that isn't so easy to do in F95.

With C, and I believe also C++, it can be done with at most one copy.
As I understand it, to do it in standard Fortran 90 or 95 requires two copies. Copy to a temporary array, deallocate and allocate a larger version of the original array, copy the data back, deallocate the temporary array.

-- glen

.



Relevant Pages

  • Re: Modifying subroutine or function arguments
    ... < end program test ... Still not required by the standard. ... likely require a temporary array. ... it wasn't added earlier in Fortran, ...
    (comp.lang.fortran)
  • Re: allocatable array *not* equivalent to dynamic allocation?
    ... dynamic memory access of the C++ standard library uses this form of extending something. ... It's just that it gets buried under the hood of the standard templates, something that isn't so easy to do in F95. ... Copy to a temporary array, deallocate and allocate a larger version of the original array, copy the data back, deallocate the temporary array. ...
    (comp.lang.fortran)
  • Re: allocatable array *not* equivalent to dynamic allocation?
    ... It's just that it gets buried under the hood of ... the standard templates, something that isn't so easy to do in F95. ... Copy to a temporary array, deallocate and allocate a larger ...
    (comp.lang.fortran)
  • Re: Reassociation of pointers
    ... found it (though I don't have a fresh copy of the standard): ... 20 If a pointer appears in a DEALLOCATE statement, ...
    (comp.lang.fortran)
  • Re: Is there a patent on XML itself?
    ... extending his work, which is contrary to the spirit of the GPL. ... But they will not be allowed to fragment the standard by releasing non- ... The author of the 1960s programming language TRAC tried to use ... trademark law to control the language, ...
    (comp.text.xml)