sas3@hcx.uucp (Scott Alan Stuff) (06/29/89)
I am trying to compile source code that was made using FORTRAN IV but all I have available to me is FORTRAN 77. The problem is an equivalence statement : program main . . dimension stf (12,3) equivalence (is1,stf(3)) . end Where does the equivalence look? At any rate, I am getting a compiler error. Thanks for any help. Scott Stuff Mechanical Engineering, Univ of Arkansas, Fayetteville ...uunet!harris.cis.ksu.edu!sas3@hcx
johnl@ima.ima.isc.com (John R. Levine) (06/29/89)
In article <2679@cveg.uucp> sas3@hcx.uucp (Scott Alan Stuff) writes: > dimension stf (12,3) > equivalence (is1,stf(3)) This is a wart in F66 that they took out of F77, although most F77 compilers continue to accept it. In F66 equivalence statements you could either give a normally subscripted reference or you could use a single subscript and it would act as though it was a singly dimensioned array of the same size. To make it work, try something like this: dimension stf (12,3) dimension xstf (12*3) equivalence (stf,xstf) equivalence (is1,xstf(3)) -- John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 492 3869 { bbn | spdcc | decvax | harvard | yale }!ima!johnl, Levine@YALE.something Massachusetts has 64 licensed drivers who are over 100 years old. -The Globe
chpf127@ut-emx.UUCP (John W. Eaton) (06/30/89)
In article <4128@ima.ima.isc.com>, (John R. Levine) writes: > In article <2679@cveg.uucp>, (Scott Alan Stuff) writes: > > dimension stf (12,3) > > equivalence (is1,stf(3)) > > This is a wart in F66 that they took out of F77, although most F77 > compilers continue to accept it. In F66 equivalence statements you > could either give a normally subscripted reference or you could use > a single subscript and it would act as though it was a singly > dimensioned array of the same size. To make it work, try something > like this: > > dimension stf (12,3) > dimension xstf (12*3) > equivalence (stf,xstf) > equivalence (is1,xstf(3)) Yikes! There's no need for extra storage here, since stf(3) (if it actually was a singly subscripted array) is guaranteed to be the same as stf(3,1). Assuming that this is what the original programmer intended,% just use dimension stf(12,3) equivalence ( is1, stf(3,1) ) Also, if is1 is of type integer and stf is of type real, this program is not strictly legal, but will probably work on many machines that use the same number of bits for integer and real variables. If you get the thing to compile and it gives you mysterious results, this may be the source of some of your errors. % If this is not what was intended, you've probably got a bigger mess on your hands than you realize :-). P.S. to Scott: I tried to send mail to you but it just bounced back. -- John Eaton chpf127@emx.utexas.edu Department of Chemical Engineering The University of Texas at Austin Austin, Texas 78712
mikel@pyrps5 (Mike Lipsie) (06/30/89)
In article <14674@ut-emx.UUCP> chpf127@ut-emx.UUCP (John W. Eaton) writes: > > dimension stf(12,3) > equivalence ( is1, stf(3,1) ) > >Also, if is1 is of type integer and stf is of type real, this program >is not strictly legal, but will probably work on many machines that >use the same number of bits for integer and real variables. The rest of your article was excellent but I couldn't let this error slip past. Fortran 77 (as well as 66) requires that INTEGER and REAL use the same amount of storage. The relevant passages in the standard are 4.3 and 4.4 which require "a[n] [integer|real] datum has one numeric storage unit". Mike
johnl@ima.ima.isc.com (John R. Levine) (06/30/89)
In article <14674@ut-emx.UUCP> chpf127@ut-emx.UUCP (John W. Eaton) writes: >In article <4128@ima.ima.isc.com>, (John R. Levine) writes: >> dimension stf (12,3) >> dimension xstf (12*3) >> equivalence (stf,xstf) >> equivalence (is1,xstf(3)) > >Yikes! There's no need for extra storage here, ... Extra storage? Who's using extra storage? I'm using equivalence statements. The array xstf exists only so that the compiler will figure out the subscripts rather than trying to do it manually. >Also, if is1 is of type integer and stf is of type real, this program >is not strictly legal, ... On the contrary, it is entirely legal. The F77 standard states that real and integer variables are the same size and you are allowed to equivalence them together. The result of storing into a location as an integer and reading it back as a real is undefined, but so long as you keep your types straight, it's perfectly legal and portable. Equivalencing character and arithmetic types is a different issue, but we've heard plenty about that. -- John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 492 3869 { bbn | spdcc | decvax | harvard | yale }!ima!johnl, Levine@YALE.something Massachusetts has 64 licensed drivers who are over 100 years old. -The Globe