[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Whats up in opening files: Unix vs. Windows
- Subject: Re: Whats up in opening files: Unix vs. Windows
- From: Paul van Delst <paul.vandelst(at)noaa.gov>
- Date: Tue, 13 Mar 2001 09:36:09 -0500
- Newsgroups: comp.lang.idl-pvwave
- Organization: CIMSS @ NOAA/NCEP
- References: <firstname.lastname@example.org>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23961
Sean Heukels wrote:
> I use this code on a Unix System and it has been working fine for 4 years.
> The only thing is that the header is not read properly. It crashes on
> file_header.ebytes, which is set to 0 (0*2=> array size ?? no way)
> A piece of what it does read:
> ** Structure FILE_HEADER, 9 tags, length=32:
> NBLOCKS LONG 3276800
> NTRACES LONG 16777216
> Should be more like 164 and 220.
Looks like a byte swap problem given that SWAP_ENDIAN(16777216L) = 1. Posting just the
code for this sort of problem isn't enough for diagnosing your problem. On what system was
the file created and on what system are you trying to read it. You say "Unix" but have you
upgrading your machine(s) or OS in the last 4 years? E.g. going from 32 to 64 bit OS may
cause problems. Or a different platform (e.g. IBM->SGI). Regardless, binary files aren't
too portable - *especially* if you're writing/reading using a structure variable which may
or may not be padded to certain byte boundaries (*Very* platform dependent) - the
endianness notwithstanding. Same problem using derived types in compiled f90/f95 code too.
Personally I only use "regular" binary files for testing algorithms on my development
platform and even then I always check for endianness - just in case (some code sticks
around like sh*t to a blanket). For distribution, I (nearly) always use netCDF.
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
email@example.com Alexander Pope.