traymund@uiuc.edu (Tim Raymund) (03/22/91)
Is there a f77 compiler option to swap byte order on i/o? I ran the same program on a DECstation 5000 and an HP 9000/835 (see program at the end) and the resulting files look like: DECstation 5000> od -h float.data 0000000 0028 0000 0000 3f80 0000 4000 0000 4040 0000020 0000 4080 0000 40a0 0000 40c0 0000 40e0 0000040 0000 4100 0000 4110 0000 4120 0028 0000 0000060 HP 9000/835> od -h float.data 0000000 0000 2800 803f 0000 0040 0000 4040 0000 0000020 8040 0000 a040 0000 c040 0000 e040 0000 0000040 0041 0000 1041 0000 2041 0000 0000 2800 0000060 We like to use binary file i/o as in the program, and it would be handy if a f77 compiler option could be set to make the files identical across systems. Thanks for any help! tim raymund traymund@uiwpl.ece.uiuc.edu program gen integer n parameter (n = 10) real numb(n) integer i do i = 1,n numb(i) = float(i) end do open (21, file='float.data',access='SEQUENTIAL', $ form='UNFORMATTED',status='UNKNOWN') rewind (21) write (21) numb close (21) stop end -- Tim Raymund Wave Propagation Lab, Department of Electrical and Computer Engineering, University of Illinois, 1406 W. Green St., Urbana, IL 61801-2991 USA Internet: t-raymund@uiuc.edu Phone: 217/333-2931 FAX: 217/244-5624
peterson@fman.enet.dec.com (Bob Peterson) (03/23/91)
In article <traymund.669594979@uiwpl.ece.uiuc.edu>, traymund@uiuc.edu (Tim Raymund) writes: >Is there a f77 compiler option to swap byte order on i/o? I ran >the same program on a DECstation 5000 and an HP 9000/835 (see program >at the end) and the resulting files look like: ... >We like to use binary file i/o as in the program, and it would >be handy if a f77 compiler option could be set to make the >files identical across systems. Yes. The DEC Fortran V3.0 compiler might help. It is capable of byte swapping and VAX<->IEEE conversion on binary I/O. The drawbacks of this are that FORTRAN programmers sometimes equivalance a lot of data in COMMON to a single integer vector, and then do I/O with the vector. The conversions then may fail. The experimental support allows you three options to control this: a per-unit environment variable, a compiler option affecting all units, and a new OPEN statement keyword, CONVERT. Details on request. We haven't had enough experience with this to catch all the gotchas. One gotcha: the binary data may be converted, but the binary record formats have to be the same as well. We think we match formats pretty well, but like I said, we're in learn mode. \bob