Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!ai-lab!life!burley From: burley@geech.ai.mit.edu (Craig Burley) Newsgroups: comp.lang.fortran Subject: Re: EQUIVALENCE or STRUCTURE/RECORD ? Message-ID: Date: 10 Jan 91 14:58:22 GMT References: <6683.278c85d2@cc.curtin.edu.au> Sender: news@ai.mit.edu Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139 (617) 253-8568 Lines: 44 In-reply-to: Gumley_LE@cc.curtin.edu.au's message of 10 Jan 91 07:18:42 GMT In article <6683.278c85d2@cc.curtin.edu.au> Gumley_LE@cc.curtin.edu.au (Liam Gumley) writes: Main program byte buffer(100) Subroutine (has 'buffer' passed to it) byte buffer(100) integer*4 data(20) equivalence ( buffer(3), data(1) ) The VAX compiler gives an error at the equivalence line. Now I know I could do the equivalence in the main program and pass 'data' to the subprogram, but I would like to do it in the subroutine if I can. Can I do this using structure and record statements, or some other way? You can't equivalence dummies, as you have discovered. Instead, use STRUCTURE, UNION, and MAP to make the same thing. I don't know if you'll have to change the main program to pass the same data (STRUCTURE) type; I'd guess not, since Fortran passes by reference anway and I don't think anything about VMS' STRUCTURE facility requires passing additional information (compare to CHARACTER type, which requires passing a length). I don't have a VMS Fortran manual handy, but I'd guess what you need would look something like this: SUBROUTINE FOO(BUFFER) STRUCTURE /BUFFERUNION/ BUFFER UNION MAP BYTE BYTES(100) END MAP MAP BYTE ignore(2) INTEGER*4 DATA(20) END MAP END UNION END STRUCTURE Then you'd refer to BUFFER.BYTES or BUFFER.DATA. Good luck! -- James Craig Burley, Software Craftsperson burley@ai.mit.edu