Re: Reshape and write binary

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Apr 26 2012 - 13:30:55 MDT

Don't use Matlab ... No need

I think you should use the 2nd option below.
There is no record number

   fbindirwrite (fo, vals(lat|:,lon|:,time|:) )

http://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirwrite.shtml

On 4/26/12 1:23 PM, Noel Aloysius wrote:
> Hi Dennis
>
> I am reading the file in matlab. Should I drop the 0 in that case?
>
> Noel
>
>
>
> On Thu, Apr 26, 2012 at 2:17 PM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> That should be
> fbinrecwrite (fo, 0, vals(lat|:,lon|:,time|:) )
> Note the 0 ... not -1
>
> fbinrecwrite has fortran record information bytes
> before an after the record. If you are reading the data into a
> fortran program via a sequential read (default in fortran)
> then the abouve is fine.
>
> ==
> Otherwise use:
> fbindirwrite (fo, vals(lat|:,lon|:,time|:) )
>
>
>
>
> On 04/26/2012 12:10 PM, Dennis Shea wrote:
>
> vals = fi->data
> fbinrecwrite (fo, -1, (/ vals(lat|:,lon|:,time|:) /)) ;
>
> ===
> The mini-language manual
> http://www.ncl.ucar.edu/__Document/Manuals/
> <http://www.ncl.ucar.edu/Document/Manuals/>
> briefly discusses this in section 2.10
>
> Also, the Reference manual
>
> http://www.ncl.ucar.edu/__Document/Manuals/Ref_Manual/__NclVariables.shtml
> <http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml>
>
> See "Named Subscripting"
>
>
> On 04/26/2012 11:26 AM, Noel Aloysius wrote:
>
> Hi
>
> The netcdf data variable is written as data (time, lat, lon)
> where the dimenstion are time = 1200, lat = 180, lon = 360
>
> I use the following to write a binary file
>
> fi = addfile (fnames_in1, "r")
> fo = diri + fnames_out
> vals = (fi->data)
> fbinrecwrite (fo, -1, (/ vals(:,:,:) /)) ;
> data(time,lat,lon)
>
> I want to reshape the vals as data(lon,lat,time) and then
> write the
> binary file.
>
> I will appreciate any help on this.
>
> Thanks,
> Noel
>
>
>
>
> _________________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/__mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
> _________________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/__mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 26 13:31:04 2012

This archive was generated by hypermail 2.1.8 : Mon Apr 30 2012 - 09:21:12 MDT