<div dir="ltr">Hi Arka,<div>As I stated to you before please do not write individual ncl-talk contributors, and always respond to the ncl-talk email list. Further communications that are directed solely to ncl-talk contributors and not to the ncl-talk email list will be ignored. </div><div><br></div><div>You stated the following in your email to me:</div><div><div style="font-size:12.8px">--</div><div style="font-size:12.8px">I made a script as per your direction in NCL. But it is not running and showing error at first line.</div><div style="font-size:12.8px">My script is attached below.</div><div style="font-size:12.8px">What is the error in this?</div></div><div>--</div><div>Always send along the error message when communicating with ncl-talk. You are receiving the following message:</div><div>fatal:syntax error: line -1 before or near<br></div><div><br></div><div>You should become familiar with searching the NCL FAQ page:</div><div><a href="http://www.ncl.ucar.edu/FAQ/" target="_blank">http://www.ncl.ucar.edu/FAQ/</a></div><div><br></div><div>Search on that page for "syntax error" and you will see that you need an "end" at the end of your script as you have a "begin". Thus put a "end" at your line 25 and a blank line at line 26 and things should work.</div><div><br></div><div>If they do not, or if you have any further questions respond to the ncl-talk email list and not to me personally.</div><div>Adam</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 11, 2017 at 11:52 AM, Karin Meier-Fleischer <span dir="ltr"><<a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div 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="gmail-m_5543821192587116402m_-5659946228221902623moz-cite-prefix">Am 11.12.17 um 19:44 schrieb Adam
      Phillips:<br>
    </div>
    <blockquote type="cite">
      <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">https://www.ncl.ucar.edu/Appli<wbr>cations/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","fil<wbr>e3.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">arka354deb@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);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="gmail-m_5543821192587116402m_-5659946228221902623HOEnZb"><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" target="_blank">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">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all"><span class="gmail-m_5543821192587116402HOEnZb"><font color="#888888">
        <div><br>
        </div>
        -- <br>
        <div class="gmail-m_5543821192587116402m_-5659946228221902623gmail_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">www.cgd.ucar.edu/staff/asphill<wbr>i/</a>  
                            </font></span><span><font color="#888888"><a href="tel:(303)%20497-1726" value="+13034971726" target="_blank">303-497-1726</a>
                            </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>
      </font></span></div><span class="gmail-m_5543821192587116402HOEnZb"><font color="#888888">
      <br>
      <fieldset class="gmail-m_5543821192587116402m_-5659946228221902623mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
ncl-talk mailing list
<a class="gmail-m_5543821192587116402m_-5659946228221902623moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="gmail-m_5543821192587116402m_-5659946228221902623moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a>
</pre>
    </font></span></blockquote>
    <br>
  </div>

<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_5543821192587116402gmail_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">www.cgd.ucar.edu/staff/<wbr>asphilli/</a>   </font></span><span><font color="#888888"><a href="tel:(303)%20497-1726" value="+13034971726" target="_blank">303-497-1726</a> </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</div></div>