home *** CD-ROM | disk | FTP | other *** search
- From: acmeyer@hpfcso.FC.HP.COM (Alan C. Meyer)
- Date: Thu, 13 Aug 1992 16:45:22 GMT
- Subject: Re: Are assumed-size array args faster than adjustable?
- Message-ID: <9080028@hpfcso.FC.HP.COM>
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Path: sparky!uunet!wupost!sdd.hp.com!hpscdc!hplextra!hpfcso!acmeyer
- Newsgroups: comp.lang.fortran
- References: <1992Aug10.112825.1@lure.latrobe.edu.au>
- Lines: 44
-
- In comp.lang.fortran, matap@lure.latrobe.edu.au (Andrej Panjkov, La Trobe Maths) writes:
-
- > Which makes faster code: declaring array arguments as adjustable arrays
- > or as assumed-size arrays? (Please answer for whatever compiler you
- > use, as I use four compilers, and I'm interested in general principles.)
- >
- > I ask because I noticed different things happen when debugging a Lahey
- > F77L compiled program under SOLD. Suppose I have two array arguments for a
- > subroutine, one adjustable, one assumed-size. I can use the debugger to
- > inspect the contents of the assumed-size array immediately on entering the
- > subroutine. I can't inspect the contents of the adjustable array until I
- > execute at least one statement.
- >
- > I assume this is because the dimensions of the adjustable array are
- > evaluated or decoded on entry to the subroutine. This suggests that
- > assumed-size arrays are just a touch quicker to use. What do you think?
-
- The difference between using assumed-size vs. adjustable arrays should
- be negligible. For example, here are two sets of declarations:
-
- ! Assumed-size ! Adjustable
- SUBROUTINE SUB(A,K,L,M) SUBROUTINE SUB(A,K,L,M,N)
- REAL A(K:L, M:*) REAL A(K:L, M:N)
- ... ...
-
- The processing for A that might typically be performed at procedure prolog
- would include calculation of the size of each dimension. For the assumed-size
- array there is no size for the second dimension so this calculation would
- typically not be executed. This would save you a slight amount of time
- at prolog (compared to the adjustable array).
-
- However, the real concern would be any difference in performing offset
- calculations in referencing the array. Since the upper bound of the last
- dimension is not required (this is column-major Fortran), there should be
- absolutely no difference in performance of accessing array elements.
-
- So, the assumed-size array might save a slight amount (depending on the
- implementation of the compiler) but it would be negligible.
-
- Alan Meyer
- Colorado Language Lab
- acmeyer@fc.hp.com
-
- "These are my own opinions ..."
-