Article View: comp.lang.misc
Article #854Re: Re: NOT Educating FORTRAN progr
From: hirchert
Date: Wed, 24 Jan 1990 18:55
Date: Wed, 24 Jan 1990 18:55
58 lines
3164 bytes
3164 bytes
mjs@hpfcso.HP.COM writes:
>>If suspect that you would really be happier with Fortran 90. It has
>>dynamic memory (but NOT implemented using explicit pointers - so no
>>aliasing slow-down).
>
>Now wait a minute. Last I heard, Fortran 90 has something very akin to
>a pointer, only worse - you can have a pointer to arbitrary and even sparse
>array slices. For instance, given an array indexed from 1 to 20 of reals, it
>is possible to have a pointer to an arrary of 5 reals, and get it to "point"
>at the "array" consisting of a[2], a[6], a[7], a[17], and a[19], where the
>latter indices are determined at run time. Now they may require that you not
>modify this pointer and the original array itself in the same scope, but
>dereferencing these types of pointers has got to be a logistic mightmare worse
>than aliasing.
There is a lot of misinformation mixed in with information above. Let me
try to sort them out:
. Fortran 90 has an allocatable memory mechanism which has NO aliasing.
. Fortran 90 also has a "pointer" facility. These can alias each other but
not you other variables (unless you explicitly declare the other variables
to be potential pointer targets). Thus, the statements actually manipulating
pointers (and the storage they point to) may be less optimized due to
aliasing, but none of the remaining code should be slowed down at all!
. Fortran 90 pointers to arrays do include the possibility of pointing to
noncontiguous array sections, but not non-linear sections like the one
suggested above. Thus you could
P => A(1::2) ! point P at the odd elements of A or
P => A(6:14:2) ! point P at the even elements of A between 6 and 14
! or even
P => A(19:1:-3)! point P at every 3rd element of A counting down from 19
but you are not allowed to
P => A((/ 2,6,7,17,19 /)) ! point P at elements 2,6,7,17, and 19
Dealing with A(19:1:-3) is roughly equivalent to dealing with A(I) in a loop
that begins
DO 10 I=19,1,-3
-- no big deal for the compiler.
. Fortran 90 does allow the use of non-linear sections (just not as the target
of a pointer). For example,
A((/ 2,6,7,17,19 /)) = B
would be the equivalent of
A(2) = B(1); A(6)=B(2); A(7)=B(3); A(17)=B(4); A(19)=B(5)
or to
DATA IA/ 2,6,7,17,19 /
DO 10 I=1,5
10 A(IA(I)) = B(I)
Such indirect subscripting certainly reduces optimization opportunities but
is not the logistical nightmare that has been suggested.
Kurt W. Hirchert hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications
Technical Details
Message-ID:
<7300003@ux1.cso.uiuc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!psuvax1!rutgers!deimos!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!hirchertReferences:
<8960006@hpfcso.HP.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!psuvax1!rutgers!deimos!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!hirchert From: hirchert@ux1.cso.uiuc.edu Newsgroups: comp.lang.misc Subject: Re: Re: NOT Educating FORTRAN progr Message-ID: <7300003@ux1.cso.uiuc.edu> Date: 24 Jan 90 18:55:00 GMT References: <8960006@hpfcso.HP.COM> Lines: 58 Nf-ID: #R:hpfcso.HP.COM:8960006:ux1.cso.uiuc.edu:7300003:000:2605 Nf-From: ux1.cso.uiuc.edu!hirchert Jan 24 12:55:00 1990