Re: XDR- External Data Representation [message #1202] |
Tue, 29 June 1993 07:39 |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:
> Are there any facilities in Dos to convert a binary file to the XDR binary
> format.
> I am receiving binary data from a PC which i would then like to process on
> a Unix(Sun) Workstation using the IDL software.
> Any advice will be very welcome.
You could do the conversion in IDL on the Sun workstation. The binary
representation of numbers on the PC are the same as on the Sun, except that the
order of the bytes is reversed. You can use the BYTEORDER routine to convert
from PC format to Sun format. For example:
For byte arrays:
No conversion necessary.
For short integer arrays:
BYTEORDER, /SSWAP, array
For long integer, floating point, or complex arrays:
BYTEORDER, /LSWAP, array
For double precision arrays:
TEMP = LONG( array, 0, 2, N_ELEMENTS(array) )
BYTEORDER, TEMP, /LSWAP
TEMP = REVERSE(TEMP, 1)
array(0) = DOUBLE( TEMP, 0, N_ELEMENTS(array) )
That last one is kind of complicated, and is probably not as efficient as the
others, but I don't have any better ideas for how to handle double precision
numbers.
On the other hand, if you had IDL for Microsoft Windows, you could do the
conversion on the PC, either using the /XDR switch on the OPEN statement, or by
using BYTEORDER, /HTOXDR (host-to-XDR) and it's complement BYTEORDER, /XDRTOH.
Bill Thompson
P.S. By the way, the Sun workstation uses the same internal binary
representation as XDR.
|
|
|
Re: XDR- External Data Representation [message #1203 is a reply to message #1202] |
Tue, 29 June 1993 06:24  |
jacobsen
Messages: 28 Registered: July 1992
|
Junior Member |
|
|
In article <9306290949.AA06550@tigermoth.aero.gla.ac.uk.gla.ac.uk> gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:
Are there any facilities in Dos to convert a binary file to the XDR binary
format.
I am receiving binary data from a PC which i would then like to process on
a Unix(Sun) Workstation using the IDL software.
Any advice will be very welcome.
Another option would be to use netCDF on the PC by getting the
netCDF subroutine library (free) from pub/netcdf/netcdf.tar.z
on unidata.ucar.edu
Then IDL could read in the netCDF file. netCDF is binary
transportable (actually built on XDR), and will also let
you preserve file header info.
--
*******************
Chris Jacobsen, Department of Physics, SUNY at Stony Brook
Phone (516) 632-8093, FAX -8101 Bitnet: cjacobsen@sbccmail
jacobsen@xray1.physics.sunysb.edu ALL-IN_ONE: CJACOBSEN
*******************
|
|
|
|