[ncl-talk] handling binary data with direct access

Arijeet Dutta arijeet.uoh at gmail.com
Sat Oct 21 11:49:42 MDT 2017


Sorry for the last message, that was due to I set time array size 730 (two
years) in fortran code, and then I realised it should be 365 since 'nr' is
taking care of the increasing index. Thanks for your help.

Cheers
Arijeet

On Sat, Oct 21, 2017 at 6:28 PM, Arijeet Dutta <arijeet.uoh at gmail.com>
wrote:

> Hi, thanks for the corrections. The fortran reading and writing part seems
> logically correct but it's showing "Fortran runtime error: Non-existing
> record number"!
>
> On Fri, Oct 20, 2017 at 10:12 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> If you are "new to NCL", please read the NCL User Guide created by DKRZ.
>> There are many examples.
>>
>> https://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/
>>
>> ==============
>> BinCreate.ncl (modified bincreate.ncl)
>>
>> f1 = addfile("uwnd.850.1951.nc","r")
>> uwnd = f1->uwnd
>> dimu  = dimsizes(uwnd)
>> ntim   = dimu(0)
>>
>>    do i = 0=ntim-1    ; each 'i' (time) is a record number
>>      fbindirwrite ("1951.bin",uwnd(i,:,:))  ; each time (record number)
>> has lat*lon pts
>>     end do
>>
>> ==================
>> Your binread.f95 is odd (?not correct?).
>>
>> (a) You are opening units 11 and 12 but not reading either file (unit).
>> Why are they there?
>>
>> (b) Where is 'uwnd' created? ***Where is the 'time' (record) dimension?***
>>
>> (c) Further, it is *writing* (nor *reading* as the file name would imply)
>> one grid point value at each iteration.
>>
>> To read what 'BinCreate.ncl' is doing you would need something like:
>>
>> implicit none
>> integer::time,lon,lat,i,j,k,nu,nr
>> parameter (time=730)
>> parameter (lat=25)
>> parameter (lon=144)
>> real::uwnd(lat,lon)
>>
>> open(11,file="1950.bin",form="unformatted",access="direct",r
>> ecl=4*lat*lon)
>> open(21,file="1951.bin",form="unformatted",access="direct",r
>> ecl=4*lat*lon)
>> open(31,file="50_51.bin",form="unformatted",access="direct",
>> status="replace",recl=4*lat*lon)
>>
>>
>>      nr = 0
>>      do nu=11,21,10
>>         do i = 1,time
>>            read(nu,rec=i) uwnd    ! read all lat*lon
>>            nr = nr+1
>>            write(31,rec=nr) uwnd  ! write all lat*lon
>>
>>         end do
>>      end do
>>
>> close(31)
>> close(21)
>> close(11)
>>
>> end
>>
>>
>> ====================
>>
>> Good luck
>>
>>
>> On Fri, Oct 20, 2017 at 7:05 AM, Arijeet Dutta <arijeet.uoh at gmail.com>
>> wrote:
>>
>>> Hi, I am aware of addfiles() and I am able to merge nc files, that's not
>>> the issue; I am just playing around with fbindirread and fbindirwrite and
>>> make sense of them. Please have a look when you get time. Thanks
>>>
>>> Cheers
>>> Arijeet
>>>
>>> On Fri, Oct 20, 2017 at 6:17 PM, Rick Brownrigg <brownrig at ucar.edu>
>>> wrote:
>>>
>>>> I've not looked at the scripts just yet, but if all you are trying to
>>>> do is to merge several NetCDF files, you might want to look at the addfile
>>>> s() command:
>>>>
>>>> http://ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml
>>>>
>>>> This potentially save you some trouble.
>>>>
>>>> On Fri, Oct 20, 2017 at 6:17 AM, Arijeet Dutta <arijeet.uoh at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi all, I am new to NCL. I had u-wind daily data at 850hPa as netcdf
>>>>> files. To get into how binary file works I converted the nc file into .bin
>>>>> using fbindirwrite and then used fortran to read and merge two such files
>>>>> and then tried to read the merged bin file in NCL with fbindirread I am
>>>>> having unrealistic values for u-wind. Please see the attached scripts I
>>>>> wrote and let me know if you can make out anything
>>>>>
>>>>> Cheers
>>>>> Arijeet
>>>>>
>>>>> _______________________________________________
>>>>> 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/20171021/6e0716ae/attachment.html>


More information about the ncl-talk mailing list