🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.dec
Article #3333

Re: f77 comp option to swap bytes?

#3333
From: Jim Gettys
Date: Fri, 22 Mar 1991 12:46
99 lines
5286 bytes
In article <12660002@acf3.NYU.EDU> tihor@acf3.NYU.EDU (Stephen Tihor) writes:
>dd can swap bytes.  Unfortunately the things that make binary i/o good argue
>against tricks liek byteswapping.  Still if HP supports it you can make a 
>case that DEc should to for competitive reasons.  I bet they don't though.

You'd lose that bet, with the new release of DEC Fortran on the RISC machines.
When you open a file (or by setting an environment variable) you can specify
that bytes should be appropriately swapped.  This works for well formed
binary I/O (i.e. you'd better not be playing evil tricks equivalencing
stuff to what you are reading in). This compiler has gone to the software
distribution center, and should start appearing in customers hands
in the not too distant future.  Note that it also helps with converting
to and from VAX floating point format as well.

To quote from the release notes of DEC Fortran for Ultrix RISC Systems
Version 3.0:

        1.7.1 Support for Big/Little Endian and VAX Floating Point Data

              DEC Fortran contains features that allow Fortran programs to read
              unformatted binary files that contain either data in big-endian
              byte order or floating point data in VAX format.  When the user
              specifies that a file has either of these attributes, all
              unformatted READs and WRITEs will process the elements of the
              I/O list and perform the necessary conversion.

              These tools provided by DEC Fortran for handling big endian and
              VAX floating point binary data in files are only a partial
              solution because it depends on the application being "data type
              clean", ie, the data in the file must be processed by an I/O
              list that uses the data types of the data in the file.  For
              example, if lots of data is EQUIVALENCEd to an INTEGER array and
              then that array is written out, the data types of the actual
              data are not correctly represented by the data types of the
              I/O list elements (in this case, INTEGER) and correct conversion
              will not take place.

              There are several ways to specify that a file should have
              conversion attributes:

              o  a compiler option spelled "-assume big_endian" tells DEC
                 Fortran that all files opened for unformatted READs and WRITEs
                 in the program being compiled contain big endian binary data.

                 All the user has to do is recompile his application (or just
                 the routines that touch the big endian files) with "-assume
                 big_endian", and the READs and WRITEs will convert the data
                 from big to little endian and back.



        1-22 DEC Fortran for ULTRIX RISC Systems Release Notes
^L
              o  "-assume vaxd" means that the file contains little endian data
                 in VAX floating point format and that double precision is in
                 VAX D format.

              o  "-assume vaxg" means that the file contains little endian data
                 in VAX floating point format and that double precision is in
                 VAX G format.



              o  An environment variable, named FORT_CONVERTn, associated with
                 Fortran I/O unit number "n", contains the conversion attributes
                 for the file associated with that unit at run-time.

                 The settings would look like

                 -  setenv FORT_CONVERTn "BIG_ENDIAN"

                 -  setenv FORT_CONVERTn "VAXD"

                 -  setenv FORT_CONVERTn "VAXG"

                 to set the attribute for the file associated with unit = n.
                 DEC Fortran already uses the environment variable

                    FORTn

                 to be the file spec for the file opened on unit = n.

              o  For those who are willing to modify their source code, there
                 is a new keyword on the OPEN statement:

                    OPEN (... CONVERT = 'BIG_ENDIAN', ...)
                    OPEN (... CONVERT = 'VAXD', ...)
                    OPEN (... CONVERT = 'VAXG', ...)

                 that specifies the attributes for the file.  The INQUIRE
                 statement also recognizes the CONVERT keyword and returns a
                 character string of the conversion attribute set for the file.
                 The default is 'LITTLE_ENDIAN' which implies IEEE floating
                 point.


--
Digital Equipment Corporation
Cambridge Research Laboratory
Technical Details
Message-ID: <1991Mar22.124601.25596@crl.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!elroy.jpl.nasa.gov!ncar!gatech!purdue!haven!decuac!pa.dec.com!shlump.nac.dec.com!news.crl.dec.com!news
References: <traymund.669594979@uiwpl.ece.uiuc.edu> <12660002@acf3.NYU.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!elroy.jpl.nasa.gov!ncar!gatech!purdue!haven!decuac!pa.dec.com!shlump.nac.dec.com!news.crl.dec.com!news
From: jg@crl.dec.com (Jim Gettys)
Newsgroups: comp.sys.dec
Subject: Re: f77 comp option to swap bytes?
Message-ID: <1991Mar22.124601.25596@crl.dec.com>
Date: 22 Mar 91 12:46:01 GMT
References: <traymund.669594979@uiwpl.ece.uiuc.edu> <12660002@acf3.NYU.EDU>
Sender: news@crl.dec.com (USENET News System)
Organization: DEC Cambridge Research Lab
Lines: 99