<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div>NCL's binary write functions do not have the ability to write mixed type records. <br></div>Further, fortran default sequential modepre/post-pend each record<br></div>with a 'hidden' record separator .<br><br></div>I'd suggest creating a fortran subroutine to do what you want. Untested f77<br><br></div>C NCLFORTSTART<br></div> subroutine wrhead(fname, llc, urc, nlat, mlon, dx, dy, kk)<br></div> implicit none<br></div><div>C input<br></div> integer nlat, mlon, llc(2), kk<br></div> real urc(2), dx, dy<br></div> character*(*) fname<br></div><div>C NCLEND<br></div><div><br><br></div> open(unit=11, file=fname, form="unformatted", access="sequential")<br><br></div> write(11) llc(0), urc(0), llc(1), urc(1), dx, dy, nlat, nlon, kk)<br></div> return <br></div> end<br><br>C NCLFORTSTART<br> subroutine wrrec(fname, ......)<br> implicit none<br> .....<br><div>C NCLEND<br></div><div><br></div> return <br> end<br><div><div><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 10, 2014 at 5:54 PM, Jatin Kala <span dir="ltr"><<a href="mailto:jatin.kala.jk@gmail.com" target="_blank">jatin.kala.jk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
This may or may not help solve your problem.<br>
My general experience is, it's easier to deal with direct-access binary<br>
versus sequential.<br>
I would consider using fbindirwrite rather than fbinrecwrite.<br>
<br>
Also in our OPEN statement, have you tried to specify the "ACCESS=" option?<br>
Cheers,<br>
Jatin.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On 10/09/14 8:33 PM, Ufuk Utku Turuncoglu (BE) wrote:<br>
> Hi,<br>
><br>
> I am trying to write a binary file, which is in following form,<br>
><br>
> header 1 - 6 float and 2 integer<br>
> header 2 - character (len = 14), holds time information<br>
> data 1 - 2 dimensional data written as a chunk of lons (inside a lat loop)<br>
> data 2 - 2 dimensional data written as a chunk of lons (inside a lat loop)<br>
> header 2<br>
> data 1<br>
> data 2<br>
> ...<br>
> ...<br>
><br>
> So, my ncl script writes the data as follows,<br>
><br>
> ihead = (/ llc(0), urc(0), llc(1), urc(1), 0.25, 0.25, nlat, nlon, 3 /)<br>
> fbinrecwrite(fname, -1, ihead)<br>
><br>
> do k = 0, ntime-1<br>
> print(k+" "+date_str(k))<br>
> fbinrecwrite(fname, -1, date_str(k))<br>
> do i = 0, nlat-1<br>
> fbinrecwrite(fname, -1, uwnd_rmap(k,i,:))<br>
> end do<br>
> do i = 0, nlat-1<br>
> fbinrecwrite(fname, -1, vwnd_rmap(k,i,:))<br>
> end do<br>
> end do<br>
><br>
> The problem is that the fortran code try to read "header 1" with a<br>
> single read command. Like following,<br>
><br>
> OPEN<br>
> (UNIT=IU01,FILE=FILE01(1:LEN),FORM='UNFORMATTED',STATUS='OLD',IOSTAT=IOS)<br>
> READ (IU01,IOSTAT=IOS) SOUTH, NORTH, WEST, EAST, D_LON, D_LAT,<br>
> N_LAT, N_LON<br>
><br>
> but the data type are different for header (real for SOUTH, NORTH, WEST,<br>
> EAST, D_LON, D_LAT and integer for N_LAT, N_LON). As it can be seen<br>
> above, i tried to write the header as,<br>
><br>
> ihead = (/ llc(0), urc(0), llc(1), urc(1), 0.25, 0.25, nlat, nlon, 3 /)<br>
><br>
> but fortran file can not read it correctly. It reads "header 1"<br>
> correctly for SOUTH, NORTH, WEST, EAST, D_LON, D_LAT variables but<br>
> N_LAT, N_LON is wrong. So, i think that i have to find another way to<br>
> write header in a single record. I also check that NCL float and integer<br>
> data types and both of them are 32 bits but even the size are same<br>
> fortran reads them wrongly.<br>
><br>
> I just wonder that is there any other way to write this kind of header<br>
> (has multiple data types) to the binary file.<br>
><br>
> Regards,<br>
><br>
> --ufuk<br>
><br>
> _______________________________________________<br>
> ncl-talk mailing list<br>
> List instructions, subscriber options, unsubscribe:<br>
> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</div></div></blockquote></div><br></div>