[MITgcm-support] Question about .bin files
Elja Huibregtse
J.N.Huibregtse at student.TUDelft.NL
Thu Mar 13 11:43:26 EDT 2008
Hi Lucas,
Thanks; it works!
Elja
-----Original Message-----
From: mitgcm-support-bounces at mitgcm.org on behalf of Lucas Merckelbach
Sent: Thu 3/13/2008 3:53 PM
To: mitgcm-support at mitgcm.org
Subject: Re: [MITgcm-support] Question about .bin files
Hi Elja,
> Therefore, I would like to adapt the topography-file (topog.bin)
> -and the other .bin files- to the situation on this moon. Unfortunately,
> I do not know how to proceed. From the manual (page 151), I learned that
> the files are 'assumed to contain 64-bit binary numbers'. However, when
> I try to load the file in Matlab, it does not work, properly.
Two things that can cause trouble: the size: 32 or 64 bit and the order of
bits: little or bigendian. When reading a binary, you have to make sure
that file and hardware agree on this as the endian issue is hardware
dependent. When reading a binary (and writing is similar) with matlab you
can specify the size and also the endianess. I suggest to have a look at
any of the examples that come with the code and look for a file gendata.m.
This will contain something like
ieee='b'
fid=fopen('Qbot.bin','w',ieee); fwrite(fid,Qbot,'real*8'); fclose(fid);
ieee can be 'l' or 'b', meaning little endian or big endian respectively.
If not specified, it uses the machine native endianess, which may be not
the one your file is in. Also make sure that if you create your own
binaries, you make them for the machine you are going to run the model on,
as the model should also be able to read the file...
I don't use matlab myself, but you should be able to recreate the binary
files using the corresponding gendata.m script. These prescribe the
endianess.
Good luck,
lucas
_______________________________________________
MITgcm-support mailing list
MITgcm-support at mitgcm.org
http://mitgcm.org/mailman/listinfo/mitgcm-support
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20080313/7fe8cb4f/attachment.htm>
More information about the MITgcm-support
mailing list