[ncl-talk] A binary file contains 6 variables(3-dimensional)

Dennis Shea shea at ucar.edu
Tue Mar 14 11:57:41 MDT 2017


If you wrote the binary using:

     open(2,file=ofile,status='unknown',form='unformatted')
     write(2) (((hgtm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)

I believe this is a fortran *sequential* write *not* fortran *direct*
access write.

Sequential writes contain 'hidden' bytes.

You are using

   hgt       = fbindirread(path_prs, 0, dims, "float")
   printMinMax(hgt, 0)     ; what does this indicate<====

The " fbindirread" is for direct access *not* for sequential files.

Please look at:

https://www.ncl.ucar.edu/Document/Functions/Built-in/fbinrecread.shtml

   hgt       = fbinrecread(path_prs, 0, dims, "float")
   printMinMax(hgt, 0)     ; what does this indicate<====

On Tue, Mar 14, 2017 at 10:29 AM, Mary Haley <haley at ucar.edu> wrote:

> Hi,
>
> You have defined your 3D array dimensions as nlat x nlon x nlev, but then
> you are defining the dimensions of "hgt" in a different order:
>
> hgt!0                   = "level"
> hgt!1                   = "lat"
> hgt!2                   = "lon"
>
> The above implies your hgt array is ordered nlev x nlat x nlon.
>
> I don't know how your data is ordered on the binary file, but you either
> need to fix your "dims" array:
>
>   dims  = (/nlev,nlat,nlon/)
>
> or you need to fix the order that you name the "hgt" dimensions:
>
> hgt!0                   = "lat"
> hgt!1                   = "lon"
> hgt!2                   = "level"
>
> I think everything else in your script looks okay, but this code is
> redundant:
>
> hgt&level at units         = "hPa"
> hgt&lat at units           = "degrees_north"
> hgt&lon at units           = "degrees_east"
>
> You've already attached the "units" to the level, lat, and lon arrays, so
> you don't need to do it again.
>
> --Mary
>
>
> On Mon, Mar 13, 2017 at 11:41 PM, 김가은 <gaeun.kim0921 at gmail.com> wrote:
>
>> Hello, world!
>>
>> I want to draw several plots with data which is a binary file contains 6
>> variables(3-dimensional) and made like below:
>>
>> open(2,file=ofile,status='unknown',form='unformatted')
>>      write(2) (((hgtm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)
>>      write(2) (((ugrdm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)
>>      write(2) (((vgrdm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)
>>      write(2) (((vvelm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)
>>      write(2) (((tmpm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)
>>      write(2) (((rhm(i,j,k),i=1,imx),j=1,jmx),k=1,lx)
>>   close(2)
>>
>> And then I wrote a NCL script to read and plot them.
>> Here is the prob:
>> fatal:No coordinate variable exists for dimension (level) in variable
>> (hgt)
>>
>> My script:
>>
>>   nlon = 659
>>   nlat = 539
>>   nlev = 17
>>
>>   dims  = (/nlat,nlon,nlev/)
>>   lat      = fspan(slat,elat,nlat)
>>   lon      = fspan(slon,elon,nlon)
>>  level = (/1000.,925.,850.,700.,600.,500.,400.,300.,\
>>            250.,200.,150.,100.,70.,50.,30.,20.,10./)
>>
>>   hgt       = fbindirread(path_prs, 0, dims, "float")
>>   u       = fbindirread(path_prs, 1, dims, "float")
>>   v       = fbindirread(path_prs, 2, dims, "float")
>>   vvel       = fbindirread(path_prs, 3, dims, "float")
>>   temp       = fbindirread(path_prs, 4, dims, "float")
>>   rh      = fbindirread(path_prs, 5, dims, "float")
>>
>>   lon!0         = "lon"
>>   lon at long_name = "lon"
>>   lon at units     = "degrees_east"
>>   lon&lon       = lon
>>
>>   lat!0         = "lat"
>>   lat at long_name = "lat"
>>   lat at units     = "degrees_north"
>>   lat&lat       = lat
>>
>>   level!0                 = "level"
>>   level at units             = "hPa"
>>   level at long_name         = "isobaric_surface"
>>   level&level           = level
>>
>> hgt!0                   = "level"
>> hgt!1                   = "lat"
>> hgt!2                   = "lon"
>> hgt&level               = level <--- this one makes error!
>> hgt&lat                 = lat
>> hgt&lon                 = lon
>> hgt&level at units         = "hPa"
>> hgt&lat at units           = "degrees_north"
>> hgt&lon at units           = "degrees_east"
>> hgt at units               = "gpm"
>> hgt at long_name           = "geopotential height"
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170314/57b59abd/attachment.html 


More information about the ncl-talk mailing list