* Endian problems...
@ 1995-11-07 5:00 decroix
1995-11-08 5:00 ` Andrew Gallatin
1995-11-09 5:00 ` Steve Lionel
0 siblings, 2 replies; 5+ messages in thread
From: decroix @ 1995-11-07 5:00 UTC (permalink / raw)
I have a rather strange problem, but I think others must have run into this.
I have written an unformatted file on a cray Y-MP using IEEE floating point
format. I can read this file on the Alpha, running Digital Unix Ver. 3.2c, by
setting a few compiler flags to force all i/o to be big endian or little endian.
Here's the problem:
I want to *read* a IEEE floating point file and *write* a dec-native unformatted
file. The compiler line flags set ALL files to either big endian or little endian.
The way I did it on the cray was using the 'assign' command in an execution
c-shell script, but assign doesn't appear to be available on the alpha.
How do I read a big endian and write a little endian unformatted file?
I have been working with in FORTRAN, so that solution would be prefered.
I know a little C, so if someone could tell me the pertinent statements,
I could probably muddle my way through! ;)
Thanks for any help!
-Dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David DeCroix Mesoscale Modeling and Analysis
(919)515-1437(voice) Dept of Marine, Earth, and Atmospheric Sciences
(919)515-1683(fax) North Carolina State University
decroix@brunt.meas.ncsu.edu Raleigh, NC 27695-8208
Team OS/2 - Warping through a Ph.D.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Endian problems...
1995-11-07 5:00 Endian problems decroix
@ 1995-11-08 5:00 ` Andrew Gallatin
1995-11-13 5:00 ` Lukas Rosenthaler
1995-11-09 5:00 ` Steve Lionel
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Gallatin @ 1995-11-08 5:00 UTC (permalink / raw)
In article <47me7b$9an@taco.cc.ncsu.edu>, <decroix@brunt.meas.ncsu.edu> wrote:
>
>I want to *read* a IEEE floating point file and *write* a dec-native unformatted
Can't you just write the file w/the wrong byte ordering & then run the
result through 'dd conv=swap' to get a file w/the proper byte
ordering?
From the dd(1) man page:
...
conv=specification[,specification ...]
Specifies one or more of the following conversions:
..
swab
Swaps every pair of bytes.
...
We've done this to convert raw files created on a sparc for use w/our
alphas.
Drew
##############################################################################
# Andrew Gallatin, Computer Project Manager #
# Institute of Statistics and Decision Sciences #
# Box 90251, Duke University, Durham, NC 27708-0251 #
##############################################################################
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Endian problems...
1995-11-07 5:00 Endian problems decroix
1995-11-08 5:00 ` Andrew Gallatin
@ 1995-11-09 5:00 ` Steve Lionel
1 sibling, 0 replies; 5+ messages in thread
From: Steve Lionel @ 1995-11-09 5:00 UTC (permalink / raw)
In article <47me7b$9an@taco.cc.ncsu.edu>, decroix@brunt.meas.ncsu.edu writes:
|>
|>I have a rather strange problem, but I think others must have run into this.
|>I have written an unformatted file on a cray Y-MP using IEEE floating point
|>format. I can read this file on the Alpha, running Digital Unix Ver. 3.2c, by
|>setting a few compiler flags to force all i/o to be big endian or little endian.
|>Here's the problem:
|>
|>I want to *read* a IEEE floating point file and *write* a dec-native unformatted
|>file. The compiler line flags set ALL files to either big endian or little endian.
|>The way I did it on the cray was using the 'assign' command in an execution
|>c-shell script, but assign doesn't appear to be available on the alpha.
|>
|>How do I read a big endian and write a little endian unformatted file?
|>I have been working with in FORTRAN, so that solution would be prefered.
|>I know a little C, so if someone could tell me the pertinent statements,
|>I could probably muddle my way through! ;)
There are three DEC Fortran "hammers" with which you can affect the
data-conversion attribute of I/O. You've picked the biggest one, the
compile command switch, which affects all I/O on all units. The next smaller
hammer is to define an environment variable of the form FORT_CONVERTn, where
"n" is the unit number, before running the program. The value of the variable
is the convert type wanted for that unit, for example, BIG_ENDIAN. The
smallest hammer is the CONVERT= keyword on the OPEN statement for the
file you want to use.
For more information, please read the chapter on non-native data conversion
during I/O in the DEC Fortran User Manual.
--
Steve Lionel Mail: lionel@quark.enet.dec.com
DEC Fortran Development WWW: http://www.digital.com/info/slionel.html
Digital Equipment Corporation CompuServe: 75263,3001
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For information on DEC Fortran 90, see http://www.digital.com/info/hpc/f90/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Endian problems...
1995-11-08 5:00 ` Andrew Gallatin
@ 1995-11-13 5:00 ` Lukas Rosenthaler
1995-11-13 5:00 ` Andrew Gallatin
0 siblings, 1 reply; 5+ messages in thread
From: Lukas Rosenthaler @ 1995-11-13 5:00 UTC (permalink / raw)
gallatin@renoir.isds.duke.edu (Andrew Gallatin) writes:
>In article <47me7b$9an@taco.cc.ncsu.edu>, <decroix@brunt.meas.ncsu.edu> wrote:
>>
>>I want to *read* a IEEE floating point file and *write* a dec-native unformatted
>Can't you just write the file w/the wrong byte ordering & then run the
>result through 'dd conv=swap' to get a file w/the proper byte
>ordering?
>From the dd(1) man page:
>...
> conv=specification[,specification ...]
> Specifies one or more of the following conversions:
>..
> swab
> Swaps every pair of bytes.
>...
>We've done this to convert raw files created on a sparc for use w/our
>alphas.
Then You have been lucky - under normal circumstances this will not work.
That's because swapping of a 4 byte value (int) and of a 2 byte value (short)
is different. If You have binary files with mixed data, let's say
doubles, floats, ints, shorts and strings, then every item has to be swapped
appropriately!
Lukas Rosenthaler
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Endian problems...
1995-11-13 5:00 ` Lukas Rosenthaler
@ 1995-11-13 5:00 ` Andrew Gallatin
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Gallatin @ 1995-11-13 5:00 UTC (permalink / raw)
In article <1995Nov13.114607.45664@yogi.urz.unibas.ch>,
Lukas Rosenthaler <rosenth@foto.chemie.unibas.ch> wrote:
>Then You have been lucky - under normal circumstances this will not work.
>That's because swapping of a 4 byte value (int) and of a 2 byte value (short)
>is different. If You have binary files with mixed data, let's say
>doubles, floats, ints, shorts and strings, then every item has to be swapped
>appropriately!
The original poster said:
I want to *read* a IEEE floating point file and *write* a dec-native unformatted
So I assumed that the file was all floats. I probably should have
included your warning in case that wasn't true...
Drew
##############################################################################
# Andrew Gallatin, Computer Project Manager #
# Institute of Statistics and Decision Sciences #
# Box 90251, Duke University, Durham, NC 27708-0251 #
##############################################################################
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1995-11-13 5:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-11-07 5:00 Endian problems decroix
1995-11-08 5:00 ` Andrew Gallatin
1995-11-13 5:00 ` Lukas Rosenthaler
1995-11-13 5:00 ` Andrew Gallatin
1995-11-09 5:00 ` Steve Lionel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox