From: kenbell@panix.com (Ken Bell)
Subject: Re: byte swapping to get data readable on a decstations
Date: 11 Nov 1994 18:18:00 -0500 [thread overview]
Message-ID: <3a0u38$o32@panix2.panix.com> (raw)
In-Reply-To: EJH.94Nov10084407@larry.gsfc.nasa.gov
In article <EJH.94Nov10084407@larry.gsfc.nasa.gov>,
Edward Hartnett <ejh@larry.gsfc.nasa.gov> wrote:
>
>Howdy all.
>
>We here distribute some floating point (IEEE) data to various
>users. We generate it on a cray and various workstations, and now we
>have a user who wants to read the data from a fortran program on a
>decstation. He complains that he can't do this because of the order
>that the bytes are stored in. Is there any hope that we can help him
>solve his problem?
>--
>Edward Hartnett ejh@larry.gsfc.nasa.gov
> (301) 286-2396 fax: (301) 286-1754
>
>"Tut! Tut!" cried Sherlock Holmes. "You must act, man, or you are
>lost. Nothing but energy can save you. This is no time for dispair."
Assuming that you just want to turn a Little-Endian ieee-real into
a Big-Endian ieee-real (or vice versa), it's easy enough to write
such a routine in fortran, something like ...
INTEGER FUNCTION SWABYT( A, N )
REAL*4 A(*)
INTEGER N
C
REAL*4 RIN, ROUT
CHAR*1 CIN(4), COUT(4)
EQUIVALENCE (RIN, CIN)
EQUIVALENCE (ROUT, COUT)
C
C--- Return 1 on error, 0 on success
C
IF (N .LT. 1) THEN
SWABYT = 1
RETURN
ENDIF
C
DO 10 I = 1, N
RIN = A(I)
COUT(1) = CIN(4)
COUT(2) = CIN(3)
COUT(3) = CIN(2)
COUT(4) = CIN(1)
A(I) = ROUT
10 CONTINUE
SWABYT = 0
RETURN
END
(Or should bytes 1-2 and 3-4 be swapped for VAXen? It shouldn't be
hard to determine by experiment.)
--
Ken Bell :: kenbell@panix.com :: (212) 475-4976
======== :: syklb@nasagiss.giss.nasa.gov :: (212) 678-5545
next prev parent reply other threads:[~1994-11-11 23:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-10 13:44 byte swapping to get data readable on a decstations Edward Hartnett
1994-11-10 16:07 ` Steve Lionel
1994-11-10 16:47 ` Chuck Campbell
1994-11-11 9:31 ` Ken Bell
1994-11-14 21:55 ` Eric Frey
1994-11-11 23:18 ` Ken Bell [this message]
1994-11-14 14:19 ` Roger Grady
1994-11-16 4:06 ` byte swapping to get data readable on a dec John Lovell
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox