From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,a18c782bd6789eca X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-11-11 18:26:05 PST Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!news.mathworks.com!panix!not-for-mail From: kenbell@panix.com (Ken Bell) Newsgroups: comp.sys.dec Subject: Re: byte swapping to get data readable on a decstations Date: 11 Nov 1994 18:18:00 -0500 Organization: Public Access Internet & UNIX Message-ID: <3a0u38$o32@panix2.panix.com> References: NNTP-Posting-Host: panix2.panix.com In article , Edward Hartnett 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