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-12 05:52:03 PST Path: nntp.gmd.de!newsserver.jvnc.net!yale.edu!noc.near.net!paperboy.wellfleet.com!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!pipex!uunet!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 04:31:31 -0500 Organization: Public Access Internet & UNIX Message-ID: <39vdlj$944@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." In C, you can use the swab() function to swap bytes ... exchanges adjacent even and odd bytes in a given array. It's easy enough to write such a routine in fortran, something like ... SUBROUTINE SWAB( A, NBYTES ) REAL*4 A(*) INTEGER NBYTES C REAL*4 NOTVAX, VAX CHAR*1 SWAPIN(4), SWAPOU(4) EQUIVALENCE (NOTVAX, SWAPIN) EQUIVALENCE (VAX, SWAPOU) C C "NBYTES" must be even C IF (MOD(NBYTES,2) .EQ. 0) THEN N = NBYTES ELSE N = NBYTES - 1 ENDIF C DO 10 I = 1, N NOTVAX = A(I) SWAPOU(1) = SWAPIN(2) SWAPOU(2) = SWAPIN(1) SWAPOU(3) = SWAPIN(4) SWAPOU(4) = SWAPIN(3) A(I) = VAX 10 CONTINUE RETURN END -- Ken Bell :: kenbell@panix.com :: (212) 475-4976 ======== :: syklb@nasagiss.giss.nasa.gov :: (212) 678-5545