Re: Question on allocatable arrays in Fortran 90



Shi Jin <jinzishuai@xxxxxxxxxxx> wrote:

> Is the allocatable arrays in Fortran 90 always continuous in memory?

In essense, yes. The standard doesn't say so in quite those terms, but
there are requirements that pretty much demand it in practice.

> Then I figured +out that the top array does NOT seem to be continuous and
> was somehow copied first to a +continuous array and then the function was
> called.

How did you "figure this out?" You are giving us your conclusions
instead of the raw data. I don't see enough actual data to comment
intelligently. In particular.

Is the subroutine called absolutely identical in both cases, or is there
a difference that you thought was unimportant, so you didn't mention?

How did you time this and determine what times the various parts took?
Is there a chance that your timing includes the time of the allocate
itself?

> code2:real,allocatable::top(:,:,:,:)
> allocate(top(N,N,N,3))
> real::newtop(N,N,N,3)
> newtop=top
> call myfunc(newtop)

This is "obviously" not actual code because you have an executable
statement between the two declarations. This makes me wonder what other
parts of the actual code you thought were unimportant and therefore
didn't show us.

It is often the case that when someone asks for debugging help, the
problem lies in the part of the code that they didn't think was
relevant, and thus didn't show.

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



Relevant Pages

  • Re: Speed penalty for using allocatable arrays?
    ... (snip on slow execution using ALLOCATABLE arrays) ... per dimension of the array, ... It takes a two instruction ...
    (comp.lang.fortran)
  • Re: Concatenate integer to string
    ... (snip regarding allocatable arrays and character strings) ... compiler do the "optimization" of leaving the allocation alone if it was ... Reallocation would break any existing pointer ... array with a copy of the old data. ...
    (comp.lang.fortran)
  • Question on allocatable arrays in Fortran 90
    ... Is the allocatable arrays in Fortran 90 always continuous in memory? ... I allocated a 4-dimensional array, say top. ... If I declare a regular variable of the same size, the timing will be much smaller. ... These two codes use almost the same amount of time. ...
    (comp.lang.fortran)
  • Re: fast array assignement
    ... That has not much to do with array notation. ... allocatable arrays and non-pointer dummy arguments and you will get ... > 2) Do loops, wrong order of inner and outer loop ...
    (comp.lang.fortran)
  • How do I save a classs Raw Data (without .NET object data) to a binary file?
    ... I want to save the raw data of a class (without the .NET object ... I want to save the raw characters of the string and the raw integer ... array of Bytes and cast that array as my class, ...
    (microsoft.public.dotnet.languages.vc)