<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Adam is right, I've missed that you want to convert numerous files.
    It is not possible to have one common ctl file for numerous binary
    files! Each data file has to have its own ctl file. So, follow Adams
    instructions and you'll be fine.<br>
    <br>
    -Karin<br>
    <br>
    <div class="moz-cite-prefix">Am 11.12.17 um 19:44 schrieb Adam
      Phillips:<br>
    </div>
    <blockquote type="cite"
cite="mid:CACvWuqA5nXcTvpQJ84rawbsi-35NLgO5ooOcJo1fzTBS-BvZWg@mail.gmail.com">
      <div dir="ltr">Hi Arka,
        <div>To be clear to everyone on ncl-talk you are asking how to
          convert numerous dat files to .nc files using a single control
          file and the CDO import_binary option whose use is illustrated
          here:<br>
          <a href="https://www.ncl.ucar.edu/Applications/grads.shtml"
            target="_blank" moz-do-not-send="true">https://www.ncl.ucar.edu/<wbr>Applications/grads.shtml</a> </div>
        <div><br>
        </div>
        <div>You can write a script (in any language, NCL, c-shell, etc)
          that runs a do loop for each .dat file, that will create a new
          ctl file and  convert to a NetCDF file:
          <div><br>
          </div>
          <div>; UNTESTED. You will need to alter the following to suit
            your needs.</div>
          <div>fn = (/"file1.dat","file2.dat","<wbr>file3.dat"/)</div>
          <div><br>
          </div>
          <div>ctl = new(8,string)    ; set up control file (or
            alternatively read in existing one)</div>
          <div>ctl(1) = "UNDEF 1E30"</div>
          <div>ctl(2) = "XDEF 128 LINEAR 0.0 2.8125"</div>
          <div>.....  <snip></div>
          <div>ctl(5) = "VARS 1"</div>
          <div>ctl(6) = "z 1 99 sea surface temperature"</div>
          <div>ctl(7) = "ENDVARS"</div>
          <div><br>
          </div>
          <div>do gg = 0,dimsizes(fn)-1 </div>
          <div>    ctl(0) = "DSET "+fn(gg)<br>
          </div>
        </div>
        <div>    asciiwrite("file.ctl",ctl)</div>
        <div>    system("cdo -f nc import_binary file.ctl
          "+fn(gg)+".nc")</div>
        <div>    system("rm file.ctl")   ; optional</div>
        <div>end do</div>
        <div><br>
        </div>
        <div>Hope that helps. If you have any further questions please
          respond to ncl-talk.</div>
        <div>Adam</div>
        <div><br>
        </div>
        <div> </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Dec 11, 2017 at 11:25 AM, Arka
          Banerjee <span dir="ltr"><<a
              href="mailto:arka354deb@gmail.com" target="_blank"
              moz-do-not-send="true">arka354deb@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="auto">Hi..
              <div dir="auto"><br>
              </div>
              <div dir="auto">How to convert .dat files to .nc files
                using one .ctl file?</div>
              <div dir="auto"><br>
              </div>
              <div dir="auto">Thanks</div>
              <span class="HOEnZb"><font color="#888888">
                  <div dir="auto">Arka</div>
                  <div dir="auto"><br>
                  </div>
                </font></span></div>
            <br>
            ______________________________<wbr>_________________<br>
            ncl-talk mailing list<br>
            <a href="mailto:ncl-talk@ucar.edu" moz-do-not-send="true">ncl-talk@ucar.edu</a><br>
            List instructions, subscriber options, unsubscribe:<br>
            <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="gmail_signature" data-smartmail="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div>
                      <div dir="ltr">
                        <div>
                          <div>
                            <div><span><font color="#888888">Adam
                                  Phillips <br>
                                </font></span></div>
                            <span><font color="#888888">Associate
                                Scientist,  </font></span><span><font
                                color="#888888">Climate and Global
                                Dynamics Laboratory, NCAR<br>
                              </font></span></div>
                        </div>
                        <div><span><font color="#888888"><a
                                href="http://www.cgd.ucar.edu/staff/asphilli/"
                                target="_blank" moz-do-not-send="true">www.cgd.ucar.edu/staff/asphilli/</a>  
                            </font></span><span><font color="#888888">303-497-1726
                            </font></span></div>
                        <span></span>
                        <div>
                          <div><span><font color="#888888"><br>
                              </font></span>
                            <div><span></span></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>