home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / fortran / 3027 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  2.5 KB

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