<div dir="ltr"><div><div><div>;---Read needed variables from file<br><br></div><div>  itStrt = 9         ;<br></div><div>  itLast = 12<br></div><div>  lonStrt = 20<br></div><div>  lonLast = 100 <br></div><div>   <br>   u       = short2flt(in->u(itStrt:itLast,:,::-1,<wbr>lonStrt:lonLast))  <br></div><div>   SPH  = short2flt(in1->q(itStrt:itLast,:,::-1,<wbr>lonStrt:lonLast))<br>   printVarSummary(u)<br>    <br> ;===> NO: lat=in->latitude(::-1)              Do not explicitly read from file<br> :===> NO: lon=in->longitude(20:100)    NCL does the book keeping<br> ;===> NO: time=in->time(09:12)           as part of data structure/object  input<br> <br></div></div></div><div>  u&level = u&level*100         ; over write with new values<br></div><div>  u&level@units = "Pa"<br></div>  printVarSummary(u)            ; LOOK at this<br><div><div><div><br>;--- Zonal moisture transport ---------------------------------------------------------------------<br>ZMT=u*SPH                                                        ; not appropriate to use monthly means for<br></div><div>                                                                            ; for a non-linear quantity<br></div><div>ZMT@long_name = "zonal moisture transport" <br>ZMT@units="(m/s)(kg/kg)"<br>copy_VarCoords(u, ZMT) <br>printVarSummary(ZMT)<br><br>---<br></div><div>Use Method 1 to write netCDF ... easier<br><br><font size="2"><span style="font-family:arial,helvetica,sans-serif"></span></font>   filo = "<a href="http://example.nc">example.nc</a>"                    ; Output file<br><pre><font size="2"><span style="font-family:arial,helvetica,sans-serif"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml"><strong>   system</strong></a>("/bin/rm -f <a href="http://example.nc">example.nc</a>")   ; remove any pre-existing file</span></font></pre>        fout  = addfile (filo, "c")            ; open output file<br><br>;===================================================================<br>; create global attributes of the file<br><br>        fAtt               = True            ; assign file attributes<br>        fAtt@title         = "NCL Simple Approach to netCDF Creation"  <br>        fAtt@source_file   = "uvwtz_Dec2016.nc"<br>        fAtt@Conventions   = "None"   <br>        fAtt@creation_date = systemfunc ("date")        <br>        fileattdef( fout, fAtt )            ; copy file attributes    <br><pre>    ;===================================================================
    ; make time an UNLIMITED dimension; recommended  for most applications
    ;===================================================================
       <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/filedimdef.shtml"><strong>filedimdef</strong></a>(ncdf,"time",-1,True) <br><br>     fout->ZMT  = ZMT                          ; 4D   
</pre></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 17, 2018 at 11:05 AM, Soma Roy <span dir="ltr"><<a href="mailto:somaroy892@gmail.com" target="_blank">somaroy892@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="ltr">It again shows the following error message;<div><br></div><div><div>fatal:Variable (lev) is undefined</div><div>fatal:["Execute.c":8640]:<wbr>Execute: Error occurred at or near line 44 in file TEST1.ncl</div></div><div><br></div><div>'latitude', 'longitude', 'level' and 'time' are named as variable's dimensions in input file which is very clear from printVarSummary of the data. I modified the code as per your hints. Modified code is attached below. Kindly inform me where I am doing wrong again.<br><br class="m_647736885907970152gmail-Apple-interchange-newline">

</div><div><br></div><div>Thanks,</div><div>Soma</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 17, 2018 at 10:09 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><span>
    Hi Soma,<br>
    <br>
    please, reply always to ncl-talk that everybody is able to follow. <br>
    <br>
    The problem is, that you changed the name of the level dimension to
    lev. ZMT has the dimension name level. Change lev to level and it
    should work or<br>
    <br>
    ZMT!1    = "lev"<br>
    ZMT&lev = lev<br>
    <br>
    -Karin<br>
    <br>
    <div class="m_647736885907970152m_-6506838175746249636moz-cite-prefix">Am 17.07.18 um 14:06 schrieb Soma Roy:<br>
    </div>
    </span><blockquote type="cite">
      
      <div dir="auto">In the directory there is no file named as <a href="http://example.nc" rel="noreferrer" target="_blank">example.nc</a>.
        <div><div class="m_647736885907970152h5"><div dir="auto">It is created at the run time.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Now I am getting the following error massage;</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">
          <div style="font-family:sans-serif;font-size:12.8px" dir="auto">FileAddVar, in file: NclFile.c, line: 412</div>
          <div style="font-family:sans-serif;font-size:12.8px" dir="auto">fatal:FileAddVar: Dimension (level) is not
            currently defined, can't add variable</div>
          <div style="font-family:sans-serif;font-size:12.8px" dir="auto">fatal:["Execute.c":8640]:Execu<wbr>te: Error occurred
            at or near line 77 in file TEST1.ncl</div>
          <br>
        </div>
        <div dir="auto">Kindly inform me what I am doing wrong in this. </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Thanking you,</div>
        <div dir="auto">Soma</div>
        <div dir="auto"><br>
        </div>
      </div></div></div><div><div class="m_647736885907970152h5">
      <br>
      <div class="gmail_quote">
        <div dir="ltr">On Tue, Jul 17, 2018, 16:31 Karin Meier-Fleischer
          <<a href="mailto:meier-fleischer@dkrz.de" rel="noreferrer" target="_blank">meier-fleischer@dkrz.de</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div text="#000000" bgcolor="#FFFFFF"> Hi Soma,<br>
            <br>
            if the file <a href="http://example.nc" rel="noreferrer
              noreferrer" target="_blank">example.nc</a>
            already exists NCL can't create a new one with the same
            name. You have to remove the file, first.<br>
            <br>
            <font color="#3333ff"><tt>    filo = "<a href="http://example.nc" rel="noreferrer noreferrer" target="_blank">example.nc</a>"                  <wbr> 
                ; Output file</tt><tt><br>
              </tt><b><tt>    system("rm -rf "+filo)</tt></b><tt><br>
              </tt><tt>    fout  = addfile (filo, "c")            ; open
                output file</tt><tt><br>
              </tt></font><br>
            -Karin<br>
            <br>
            <div class="m_647736885907970152m_-6506838175746249636m_8295191540575769387m_-7654072512693969903moz-cite-prefix">Am
              17.07.18 um 12:22 schrieb Soma Roy:<br>
            </div>
            <blockquote type="cite">
              <div dir="auto">
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">I am trying to save the variable ZMT in
                  NetCDF file following the instructions at the
                  below-mentioned link;</div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><a href="http://www.ncl.ucar.edu/Applications/method_2.shtml" style="text-decoration-line:none;color:rgb(66,133,244)" rel="noreferrer
                    noreferrer" target="_blank">http://www.ncl.ucar.edu/Applic<wbr>ations/method_2.shtml</a><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">Summary of the dataset is as follows;</div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">
                  <div>Variable: <span style="background-color:rgb(243,243,243)"><font color="#ff0000">lat</font></span></div>
                  <div>Type: float</div>
                  <div>Total Size: 244 bytes</div>
                  <div>            61 values</div>
                  <div>Number of Dimensions: 1</div>
                  <div>Dimensions and sizes:   [latitude | 61]</div>
                  <div>Coordinates:</div>
                  <div>            latitude: [ 5..20]</div>
                  <div>Number Of Attributes: 2</div>
                  <div>  units :       degrees_north</div>
                  <div>  long_name :   latitude</div>
                  <div><br>
                  </div>
                  <div>Variable: <font color="#ff0000">lon</font></div>
                  <div>Type: float</div>
                  <div>Total Size: 324 bytes</div>
                  <div>            81 values</div>
                  <div>Number of Dimensions: 1</div>
                  <div>Dimensions and sizes:   [longitude | 81]</div>
                  <div>Coordinates:</div>
                  <div>            longitude: [70..90]</div>
                  <div>Number Of Attributes: 2</div>
                  <div>  units :       degrees_east</div>
                  <div>  long_name :   longitude</div>
                  <div><br>
                  </div>
                  <div>Variable: <font color="#ff0000">time</font></div>
                  <div>Type: integer</div>
                  <div>Total Size: 16 bytes</div>
                  <div>            4 values</div>
                  <div>Number of Dimensions: 1</div>
                  <div>Dimensions and sizes:   [time | 4]</div>
                  <div>Coordinates:</div>
                  <div>            time: [1025088..1025160]</div>
                  <div>Number Of Attributes: 3</div>
                  <div>  units :       hours since 1900-01-01 00:00:0.0</div>
                  <div>  long_name :   time</div>
                  <div>  calendar :    gregorian</div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div>Variable: <font color="#ff0000">pnew</font></div>
                  <div>Type: integer</div>
                  <div>Total Size: 112 bytes</div>
                  <div>            28 values</div>
                  <div>Number of Dimensions: 1</div>
                  <div>Dimensions and sizes:   [level | 28]</div>
                  <div>Coordinates:</div>
                  <div>            level: [70..1000]</div>
                  <div>Number Of Attributes: 2</div>
                  <div>  units :       Pa</div>
                  <div>  long_name :   pressure_level</div>
                  <div>(0)     7000</div>
                  <div>(1)     10000</div>
                  <div>(2)     12500</div>
                  <div>(3)     15000</div>
                  <div>..........</div>
                  <div>(26)    97500</div>
                  <div>(27)    100000</div>
                  <div><br>
                  </div>
                  <div>Variable: <font color="#ff0000">ZMT</font></div>
                  <div>Type: float</div>
                  <div>Total Size: 2213568 bytes</div>
                  <div>            553392 values</div>
                  <div>Number of Dimensions: 4</div>
                  <div>Dimensions and sizes:   [time | 4] x [level | 28]
                    x [latitude | 61] x [longitude | 81]</div>
                  <div>Coordinates:</div>
                  <div>            time: [1025088..1025160]</div>
                  <div>            level: [70..1000]</div>
                  <div>            latitude: [ 5..20]</div>
                  <div>            longitude: [70..90]</div>
                  <div>Number Of Attributes: 3</div>
                  <div>  units :       (m/s)(kg/kg)</div>
                  <div>  long_name :   zonal moisture transport</div>
                  <div>  _FillValue :  -32767</div>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">At run-time, I am getting the following
                  error message;</div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">
                  <div>fatal:Could not create (<a href="http://example.nc/" style="text-decoration-line:none;color:rgb(66,133,244)" rel="noreferrer noreferrer" target="_blank">example.nc</a>)</div>
                  <div>warning:FileSetFileOption: invalid file or format</div>
                  <div>fatal:["Execute.c":8640]:Execu<wbr>te: Error occurred
                    at or near line 65 in file TEST1.ncl</div>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">My script is attached below. </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">Please kindly inform me what is wrong with
                  this code and how to fix it.</div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto"><br>
                </div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">Thanking you,</div>
                <div style="font-family:sans-serif;font-size:12.8px" dir="auto">Soma</div>
              </div>
              <br>
              <fieldset class="m_647736885907970152m_-6506838175746249636m_8295191540575769387m_-7654072512693969903mimeAttachmentHeader"></fieldset>
              <br>
              <pre>______________________________<wbr>_________________
ncl-talk mailing list
<a class="m_647736885907970152m_-6506838175746249636m_8295191540575769387m_-7654072512693969903moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu" rel="noreferrer noreferrer" target="_blank">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="m_647736885907970152m_-6506838175746249636m_8295191540575769387m_-7654072512693969903moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a>
</pre>
            </blockquote>
            <br>
          </div>
          ______________________________<wbr>_________________<br>
          ncl-talk mailing list<br>
          <a href="mailto:ncl-talk@ucar.edu" rel="noreferrer noreferrer" 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 noreferrer noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
        </blockquote>
      </div>
    </div></div></blockquote>
  </div>

</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>