<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Dennis,<br>
      <br>
      Thanks for your help. I could write the data correctly after
      making some modifications in the fortran code (it is attached). In
      this case, i have to set the binary file as "formatted" plus
      "sequential" to create file. In this case, the fortran code read
      the file (generated by NCL) without any problem. I don't know why
      but the fortran code confuses when it try to read the binary file
      which is written in "unformatted" option. So, it is still unclear
      for me. Anyway, my problem is solved. Thanks again for your help.<br>
      <br>
      Regards,<br>
      <br>
      --ufuk<br>
      <br>
      On 11/09/14 06:22, Dennis Shea wrote:<br>
    </div>
    <blockquote
cite="mid:CAOF1d_6zfaQRnxbY+fr=PYM0_dWVEMeOzX67L_Aik-5yHu=iPw@mail.gmail.com"
      type="cite">
      <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">&lt;<a moz-do-not-send="true"
              href="mailto:jatin.kala.jk@gmail.com" target="_blank">jatin.kala.jk@gmail.com</a>&gt;</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>
                &gt; Hi,<br>
                &gt;<br>
                &gt; I am trying to write a binary file, which is in
                following form,<br>
                &gt;<br>
                &gt; header 1 - 6 float and 2 integer<br>
                &gt; header 2 - character (len = 14), holds time
                information<br>
                &gt; data 1 - 2 dimensional data written as a chunk of
                lons (inside a lat loop)<br>
                &gt; data 2 - 2 dimensional data written as a chunk of
                lons (inside a lat loop)<br>
                &gt; header 2<br>
                &gt; data 1<br>
                &gt; data 2<br>
                &gt; ...<br>
                &gt; ...<br>
                &gt;<br>
                &gt; So, my ncl script writes the data as follows,<br>
                &gt;<br>
                &gt;     ihead = (/ llc(0), urc(0), llc(1), urc(1),
                0.25, 0.25, nlat, nlon, 3 /)<br>
                &gt;     fbinrecwrite(fname, -1, ihead)<br>
                &gt;<br>
                &gt;     do k = 0, ntime-1<br>
                &gt;       print(k+" "+date_str(k))<br>
                &gt;       fbinrecwrite(fname, -1, date_str(k))<br>
                &gt;       do i = 0, nlat-1<br>
                &gt;         fbinrecwrite(fname, -1, uwnd_rmap(k,i,:))<br>
                &gt;       end do<br>
                &gt;       do i = 0, nlat-1<br>
                &gt;         fbinrecwrite(fname, -1, vwnd_rmap(k,i,:))<br>
                &gt;       end do<br>
                &gt;     end do<br>
                &gt;<br>
                &gt; The problem is that the fortran code try to read
                "header 1" with a<br>
                &gt; single read command. Like following,<br>
                &gt;<br>
                &gt;         OPEN<br>
                &gt;
(UNIT=IU01,FILE=FILE01(1:LEN),FORM='UNFORMATTED',STATUS='OLD',IOSTAT=IOS)<br>
                &gt;         READ (IU01,IOSTAT=IOS) SOUTH, NORTH, WEST,
                EAST, D_LON, D_LAT,<br>
                &gt; N_LAT, N_LON<br>
                &gt;<br>
                &gt; but the data type are different for header (real
                for SOUTH, NORTH, WEST,<br>
                &gt; EAST, D_LON, D_LAT and integer for N_LAT, N_LON).
                As it can be seen<br>
                &gt; above, i tried to write the header as,<br>
                &gt;<br>
                &gt;     ihead = (/ llc(0), urc(0), llc(1), urc(1),
                0.25, 0.25, nlat, nlon, 3 /)<br>
                &gt;<br>
                &gt; but fortran file can not read it correctly. It
                reads "header 1"<br>
                &gt; correctly for SOUTH, NORTH, WEST, EAST, D_LON,
                D_LAT variables but<br>
                &gt; N_LAT, N_LON is wrong. So, i think that i have to
                find another way to<br>
                &gt; write header in a single record. I also check that
                NCL float and integer<br>
                &gt; data types and both of them are 32 bits but even
                the size are same<br>
                &gt; fortran reads them wrongly.<br>
                &gt;<br>
                &gt; I just wonder that is there any other way to write
                this kind of header<br>
                &gt; (has multiple data types) to the binary file.<br>
                &gt;<br>
                &gt; Regards,<br>
                &gt;<br>
                &gt; --ufuk<br>
                &gt;<br>
                &gt; _______________________________________________<br>
                &gt; ncl-talk mailing list<br>
                &gt; List instructions, subscriber options, unsubscribe:<br>
                &gt; <a moz-do-not-send="true"
                  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 moz-do-not-send="true"
                  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>
    </blockquote>
    <br>
  </body>
</html>