comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: VMS vs UNIX, unformatted binary files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: VMS vs UNIX, unformatted binary files [message #3580] Mon, 20 February 1995 03:55
lars is currently offline  lars
Messages: 4
Registered: January 1995
Junior Member
Thank you for your responses to our question. We have now gotten the
software we needed from the <URL:ftp://idlastro.gsfc.nasa.gov> archive.

Greetings,

Rune & Lars
Re: VMS vs UNIX, unformatted binary files [message #3594 is a reply to message #3580] Fri, 17 February 1995 07:25 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
lars@rapid.fi.uib.no (Lars Soeraas) writes:

> We are trying to read unformatted binary files in IDL on a
> UNIX system (HP 9000, series 700). The files to be read have been
> generated by IDL on a VAX VMS. The problem is that the bytes are
> swapped and the files contain a mixture of lonint, int, floats
> and character strings. We have an idl program to read the files
> which works well on a VAX but returns garbage on the UNIX system.
> Is there a simple way of avoiding this problem?

The IDL astronomy library <URL:ftp://idlastro.gsfc.nasa.gov> has some software
to convert VAX data to Unix format. Look particularly at the routines

conv_unix_vax.pro
conv_vax_block.pro
conv_vax_unix.pro
read_vax_block.pro

in the /pro/misc subdirectory.

Bill Thompson
Re: VMS vs UNIX, unformatted binary files [message #3609 is a reply to message #3594] Thu, 16 February 1995 06:52 Go to previous message
ryba is currently offline  ryba
Messages: 33
Registered: October 1992
Member
In article <CHASE.95Feb15180954@retro.jhuapl.edu>, chase@retro.jhuapl.edu (Chris Chase S1A) writes:
|> >>>>> "Lars" == Lars Soeraas <lars@rapid.fi.uib.no> writes:
|> Lars> We are trying to read unformatted binary files in IDL on a
|> Lars> UNIX system (HP 9000, series 700). The files to be read have been
|> Lars> generated by IDL on a VAX VMS. The problem is that the bytes are
|> Lars> swapped and the files contain a mixture of lonint, int, floats
|> Lars> and character strings. We have an idl program to read the files
|> Lars> which works well on a VAX but returns garbage on the UNIX system.
|> Lars> Is there a simple way of avoiding this problem?
|>
|> Use XDR format. This format is portable among versions of IDL running
|> on different machines. This is a special portable binary format that can be
|> read by other programs (e.g., C and PASCAL) on machines that have the
|> XDR library. See Chapter 17 of the IDL User Guide.
|>
|> To use the XDR format, just add the /XDR keyword to your open
|> statements in IDL. It is that easy.
|>
|> If you want to create XDR files with other programs for IDL to read,
|> there is an example in the User Guide. It is C program that creates
|> an XDR data file which is then easily read into IDL.

A probably simpler way to use XDR format if you have any intention
of reading these files outside of IDL is to use netCDF. The ncdf_*
calls in IDL are very easy to use, and the C and FORTRAN API's for
netCDF are essentially identical to the IDL one. I had a problem with
some F77 unformatted files on a VAX, with some VAX FORTRAN routines
for reading them. I wrote a read/process program in FORTRAN that runs
on the VAX and writes its output as a netCDF file, then FTP the file
over, and use IDL (and other C programs) to read them on the Sun. Of
further benefit is the fact that netCDF is a standard self-documenting file
format, which beats custom file formats. Hell, even NCSA Mosaic can parse
a netCDF file, and Collage and Slicer can plot their contents.

--
Dr. Marty Ryba | Generation X:
MIT Lincoln Laboratory | Too young to be cynical,
ryba@ll.mit.edu | too old to be optimistic.
Of course nothing I say here is official policy, and Laboratory affiliation is
for identification purposes only, blah, blah, blah....
Re: VMS vs UNIX, unformatted binary files [message #3612 is a reply to message #3609] Wed, 15 February 1995 19:29 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <3ht8pb$qsj@due.uninett.no>, lars@rapid.fi.uib.no (Lars Soeraas) writes:
> We are trying to read unformatted binary files in IDL on a
> UNIX system (HP 9000, series 700). The files to be read have been
> generated by IDL on a VAX VMS. The problem is that the bytes are
> swapped and the files contain a mixture of lonint, int, floats
> and character strings. We have an idl program to read the files
> which works well on a VAX but returns garbage on the UNIX system.
> Is there a simple way of avoiding this problem?

You can swap the byte order in the "longs" and "ints" with BYTEORDER. However,
there are no built-in routines in IDL on the HP to convert VAX float to
IEEE float. The inverse routines do exist: you can convert VAX float to IEEE
float on tha VAX before writing the data to disk. Again, use the BYTEORDER
routine. If the data are only to be read by IDL the simplest thing to do
is SAVE, /XDR which saves the variables in the portable XDR format.
____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
Re: VMS vs UNIX, unformatted binary files [message #3613 is a reply to message #3612] Wed, 15 February 1995 15:09 Go to previous message
chase is currently offline  chase
Messages: 62
Registered: May 1993
Member
>>>> > "Lars" == Lars Soeraas <lars@rapid.fi.uib.no> writes:
In article <3ht8pb$qsj@due.uninett.no> lars@rapid.fi.uib.no (Lars Soeraas) writes:

Lars> We are trying to read unformatted binary files in IDL on a
Lars> UNIX system (HP 9000, series 700). The files to be read have been
Lars> generated by IDL on a VAX VMS. The problem is that the bytes are
Lars> swapped and the files contain a mixture of lonint, int, floats
Lars> and character strings. We have an idl program to read the files
Lars> which works well on a VAX but returns garbage on the UNIX system.
Lars> Is there a simple way of avoiding this problem?


Use XDR format. This format is portable among versions of IDL running
on different machines. This is a special portable binary format that can be
read by other programs (e.g., C and PASCAL) on machines that have the
XDR library. See Chapter 17 of the IDL User Guide.

To use the XDR format, just add the /XDR keyword to your open
statements in IDL. It is that easy.

If you want to create XDR files with other programs for IDL to read,
there is an example in the User Guide. It is C program that creates
an XDR data file which is then easily read into IDL.

Chris
--
===============================
Bldg 24-E188
The Applied Physics Laboratory
The Johns Hopkins University
Laurel, MD 20723-6099
(301)953-6000 x8529
chris.chase@jhuapl.edu
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: skew T vs. Log p idl routine
Next Topic: How to learn IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:26:45 PDT 2025

Total time taken to generate the page: 0.88075 seconds