Newsgroups: comp.lang.fortran
From: Ron Shepard <ron-shep...@NOSPAM.comcast.net>
Date: Wed, 24 Oct 2012 10:38:37 -0500
Local: Wed, Oct 24 2012 11:38 am
Subject: Re: efficiency of arrays memory allocation of derived type with type-bound procedures
In article <4951d478-6b4e-449f-bf02-5f562a4f8eec@googlegroups.com>,
Stefano Zaghi <stefano.za...@gmail.com> wrote: > Hi all,
The elements of vec_eff(:,:) are always allocated sequentially, > I am trying to figure out if the use of type-bound procedures could > compromise the efficiency of memory allocation. > Suppose you have e derived type like the following:
> type, public:: Type_Vector_Eff
> Because of the presence of "sequence" statement the 2D array "vec_eff" has regardless of the presence of SEQUENCE. The SEQUENCE affects only what is within the derived type. If you think in terms of low-level code, the addresses of vec_eff(i,j) and veceff(i+1,j) or of vec_eff(i,j) and veceff(i,j+1) will always differ by a fixed amount. However, the relative offsets for the components may depend on the presence of SEQUENCE. The addresses for vec_eff(i,j) and veceff(i+1,j) will be spaced To try to relate this to something practical, an expression like real :: x(:,:)
and in most implementations, this will NOT require anything to be real :: x(m,n)
will almost certainly require the compiler to create a temporary > Now suppose you want to modify the above derived type and introduce some > type, public:: Type_Vector
> Now how are allocated the elements of "vec"? > Is it possible that its elements are not sequentially allocated thus the > Is it possible that the type-bound procedure "init" makes not efficient the > Thank you for all suggestions.
match some kind of external constraints. Within fortran, that would include things like common blocks variables and equivalence. Outside of fortran, it would include things like matching data structures within an OS call or matching data structures defined in other programming languages. SEQUENCE prohibits things like padding and rearrangements of the components. Also, generally speaking, the use of SEQUENCE suppresses $.02 -Ron Shepard
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||