Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ROBALO.NYU.EDU!mckenney From: mckenney@ROBALO.NYU.EDU (Alan McKenney) Newsgroups: comp.lang.fortran Subject: FORTRAN array aliasing -- potential problems? Message-ID: <8907311910.AA15243@robalo.nyu.edu> Date: 31 Jul 89 19:10:13 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 49 [USENET posting via mail, since our posting software doesn't work] Subject: FORTRAN array aliasing -- potential problems? Newsgroups: comp.lang.fortran,comp.arch Keywords: FORTRAN argument array aliasing Followup-To: comp.lang.fortrancomp.lang.fortran Reply-To: mckenney@robalo.nyu.edu I am considering a situation in which I would call a FORTRAN subroutine which has several dummy argument arrays using the same actual array. Example: SUBROUTINE SUB1( N, A, LDA, B, LDB, C, LDC, .... ) .... coding which sets and then uses A, then sets and uses B without referencing A again, then sets and uses C without referencing A or B again. ... END .... DIMENSION WORK(LDW,M) .... CALL SUB1( M, WORK, LDW, WORK, LDW, WORK, LDW, ... ) In other words, if A, B, and C were not arguments, I could EQUIVALENCE them without breaking things. As SUB1 stands, if I am interested in the final values of A, B, and C, I call SUB1 with distinct arrays, if not, I call it with the same array. The call to SUB1 violates the FORTRAN standard, since A, B, and C actually refer to the same array, and are modified. In most implementations that I know of, A, B, and C are effectively EQUIVALENCEd to WORK, so it is as if I had used A instead of B and C. The code I have described works on such a system. The FORTRAN on the DECsystem-10 used to copy scalar arguments into local storage on entry and copy them back on exit; I can conceive of systems which would do that for arrays as well, so WORK would be set to either A, B, or C (it being undefined which, but it would be exactly one of them.) My code would also work on such a system. My question then: are there FORTRAN implementations, either existing or which one could make an argument for using, under which such code would break? Alan McKenney E-mail: mckenney@robalo.nyu.edu (INTERNET) Courant Institute,NYU ...!uunet!cmcl2!robalo!mckenney (UUCP)