ttw@lanl.gov (Tony Warnock) (12/12/90)
One of the reasons to prefer Fortran to C for numerical work is that Fortran has the ability to work with large multi-dimensional arrays. These arrays can be passed to subroutines, accessed in any order, read and written from external storage, etc. In general, (not in all cases) a program will access all of one slice of an array. This slice can be one-dimensiona, two-dimensional, etc. For this type of access, strength reduction on small machines and the free incrementation (with stride) on CRAY's make the array structure very efficient in both storage and time. A further complication for the C style of access is that an array may need to be accessed several times with a differing order of dimensions. The example that I posted was a 72 x 24 x 24 x 24 x 48 array. (A biologist, I do not remember who, posted 1000 x 1000 x 1000 x 1000 x 50 which led to a lot of irrevelant discussion about the lack of such memory sizes.) For the case that I mentioned, access in each ordering of dimensions is necessary. (The numerical methods are of higher order of convergence if the dimensions are swept in each permutation of dimensions.) The number of pointers for such a structure is given by: 24 (permutatuions) x 24 x 24 x 24 x 48 for the 72 as the inner loop. 24 (permutatuions) x 24 x 24 x 24 x 72 for the 48 as the inner loop. 24 (permutatuions) x 24 x 24 x 48 x 72 for a 24 as the inner loop. (This last is multiplied by 6 for the permutaions of the 24's.) The total is now 326467584 pointers as opposed to 47775744 array elements. I personally do not see this as a savings in space. The excessive costs of indirect addressing aside, using pointers is too inflexible compared to ordinary array addressing.