One of the issues with posting a GrADS script to ncl-talk
is that the post assumes that people in ncl-talk are familiar
with GrADS. That is not the case.
A few random comments:
[0] There is a whole section of the Applications page
devoted to GrADS files. Please read the following:
http://www.ncl.ucar.edu/Applications/grads.shtml
I highly recommend that you use the Climate Data Operators
(CDO) to convert the GrADS binary to netCDF. It can be done
from the command line.
------
NCL comments:
[1] GrADS can produce sequential or direct (stream) binary.
Which did you use? If you did not explicitly specify this,
then what is the GrADS default?
sequential: fbinrecread
direct: fbindirread
http://www.ncl.ucar.edu/Document/Functions/Built-in/fbinrecread.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml
[2] Is the binary big-endian or little-endian?
http://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml
setfileoption("bin","ReadByteOrder","LittleEndian")
or
setfileoption("bin","ReadByteOrder","BigEndian")
[3] Not sure but I think GrADS grid ordering is like fortran's
(mlon,nlat,klev,ntim). NCL's is like C (ntim,klev,nlat,mlon)
Hence, your array order should be the reverse. Also, NCL record
ordering starts at 0 not 1. Please carefully read the
documentation. If 'thf' is the 1st record, 'nsf' the 2nd record,
etc:
thf = new ((/ntim,klev,nlat,mlon),"float")
nsf = ths
.........
nt = -1
do nyr=1,nyrs
do nmo=1,12
nt = nt+1
thf(nt,:,:,:) =
fbindirread(path,nt,(/klev,nlat,mlon/),"float")
or
fbinrecread(....)
nsf(nt,:,:,:) = ...
end do
end do
same storage order as a FORTRAN array,
On 2/19/14, 3:17 PM, Jatin Kala wrote:
> Hi,
> I’ve had to deal with binary data (had no choice) for a few projects.
> You’ve probably messed up the order of the dimensions or something when reading the variable.
> My advice: Don’t write to binary format, it’s a Pain (in my opinion).
> I don’t use grads, but it seems you can write to netcdf:
> http://www.iges.org/grads/gadoc/gradcomdsdfwrite.html
> I would use that instead, then, reading in NCL is a breeze.
> Cheers,
> Jatin.
>
>
>
> On 20 Feb 2014, at 4:52 am, Colfescu Ioana <colfiii@yahoo.it> wrote:
>
>> Hi,
>>
>> I'm trying to read in NCL binary data I wrote in GrAds and I don't understand what error I'm doing so that NCL mixes the values.
>> The data I m trying to read is written as follows :
>> while( day <= daymax )
>> 'thfrn=thfr-tr(t-'shift')'
>> 'set x 1 128'
>> 'set y 1 64'
>> 'd thfrn'
>> 'd nsfrn'
>> 'd zwsrn'
>> 'd mwsrn'
>> 'd fwfrn'
>> day=day+1
>> endwhile
>> mo=mo+1
>> endwhile
>> year=year+1
>> endwhile
>>
>> I try to read the data like :
>> thf=fbindirread(path,1,(/64,128,5,nt/),"float").
>> I get the values but they are mixed. Does anyone know what am I doing wrong ?
>> Thanks,
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> 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
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 19 16:39:03 2014
This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST