[ncl-talk] writing binary data

Dennis Shea shea at ucar.edu
Mon Mar 27 20:15:55 MDT 2017


Dave is correct.

FYI only:

; only one type per write

    fbinrecwrite(filName, -1, str)  ; write out all values
    fbinrecwrite(filName, -1, ix)
    fbinrecwrite(filName, -1, rx)
    fbinrecwrite(filName, -1, con)

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

----


NCL's WRAPIT understands f77 syntax only...... *NOT TESTED*

http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclExtend.shtml#WRAPIT


%> cat > raj.f
C NCLFORTSTART
      subroutine rajwrite(fname, nw, str, ix, rx, con)
      implicit none
      integer nw, ix(nw)                    ! INPUT
      character*(*) fname, str(nw)
      real rx(nw), con
C NCLEND
      integer n, nunit                       ! LOCAL

      nunit = 31
      open(nunit, file=fname)
      do n=1,nw
         write(nunit) str(n), ix(n), rx(n), con
      end do

      return
      end

%> WRAPIT raj.f

%> ncl RAJ.ncl
=====

RAJ.ncl has

external  MYRAJ  "./raj.so"

    filName = "./FOO.bin"
    system("/bin/rm -f "+filName)  ; remove any preexisting file

    str = ...
    ix  = ...
    rx = ...
    con = ...

    nw = dimsizes(ix)
    MYRAJ::rajwrite(filName, nw, str, ix, rx, con)

On Mon, Mar 27, 2017 at 5:11 PM, Dave Allured - NOAA Affiliate <
dave.allured at noaa.gov> wrote:

> Raj,
>
> The short answer is no.  The function fbinrecwrite does not support mixed
> data types, and this is the only function that can write Fortran sequential
> unformatted records without a horrible kludge.  I recommend either text or
> Netcdf formats for what you want to do.
>
> You could look into calling a Fortran output subroutine from NCL, but that
> would be more complicated than text or Netcdf formats.
>
> --Dave
>
>
> On Mon, Mar 27, 2017 at 2:42 PM, Raj K. Rai <rajkrai at gmail.com> wrote:
>
>> Hi,
>>
>> I am trying to write string, integer, and real values using ncl as in the
>> following fortran format.
>>
>> do j=1,5
>>
>> write(unit) stringx(j), intx(j),realx(j), 23.2
>>
>> end do
>>
>>
>>
>> I saw there is fbinrecwrite(fout,-1,stringx(1)) and so on for each
>> value. Is there anyway we can write the data in ncl as in fortran.
>>
>>
>> Thanks,
>>
>> Raj
>>
>
> _______________________________________________
> 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/20170327/69896db0/attachment.html 


More information about the ncl-talk mailing list