<div dir="ltr"><div class="gmail_default" style="font-size:small">Guilherme,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You are creating a new NetCDF file for each variable. You have these lines inside your innermost do loop:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">      ; Salva no netCDF.                                                                                                               </font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">      system(&quot;/bin/rm -f &quot;+var(j)+&quot;.nc&quot;)</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">      nc = addfile(var(j)+&quot;.nc&quot; ,&quot;c&quot;)</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">      filedimdef(nc,&quot;time&quot;,-1,True)</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">      nc-&gt;$var(j)$ = xint</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Note that you are creating the file with the same name as your variable, so this means that each variable is being written to its own file: &quot;<a href="http://hus.nc">hus.nc</a>&quot;, &quot;<a href="http://water.nc">water.nc</a>&quot;, &quot;<a href="http://va.nc">va.nc</a>&quot; and &quot;<a href="http://ps.nc">ps.nc</a>&quot;.  If you want the four variables to be written to the same file, then perhaps what you mean to do is open the file to be created outside of the &quot;do 0,nvar-1&quot; loop:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><div class="gmail_default" style=""><font face="monospace, monospace">do i = 0,nmodels-1</font></div><div class="gmail_default" style=""><font face="monospace, monospace">  dir = &quot;/media/gui/GUI_1Tb/gui/CMIP5_DOLMAN/historical/&quot;+modelos(i)+&quot;/bruto/&quot;</font></div><div class="gmail_default" style=""><font face="monospace, monospace">    ; Salva no netCDF.                                                                             out_filename = &quot;somefile&quot; + i + &quot;.nc&quot;  ; obviously you will want to use a more appropriate filename</font></div><div class="gmail_default"><font face="monospace, monospace">  system(&quot;/bin/rm -f &quot;+ out_filename)</font></div><div class="gmail_default"><font face="monospace, monospace">  nc = addfile(out_filename,&quot;c&quot;)</font></div><div class="gmail_default"><font face="monospace, monospace">  filedimdef(nc,&quot;time&quot;,-1,True)</font></div><div class="gmail_default" style=""><font face="monospace, monospace">  do j = 0,nvar-1<br>    . . .</font></div><div class="gmail_default" style=""><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default" style=""><font face="arial, helvetica, sans-serif">--Mary</font></div><div class="gmail_default" style=""><font face="monospace, monospace"><br></font></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 19, 2016 at 10:30 PM, Guilherme Martins <span dir="ltr">&lt;<a href="mailto:jgmsantos@gmail.com" target="_blank">jgmsantos@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"><div dir="ltr">Hi Mary,<div><br></div><div>The code is right, the problem is I want to create the four variables (<span style="line-height:1.5"> </span><span style="line-height:1.5">&quot;hus&quot;, &quot;water&quot;, &quot;va&quot;, &quot;ps&quot;</span><span style="line-height:1.5"> </span><span style="line-height:1.5">) in a single file for each model. In my loop is being written only the last variable (&quot;ps&quot;). The variables are being overwritten. My final file contains only the last variable, ie, ps (my list of variables =&gt; var = (/ &quot;hus&quot;, &quot;water&quot;, &quot;va&quot;, &quot;ps&quot; /)). I hope you understand me.</span></div><div><br></div><div>Thanks,</div><div><br></div><div>Guilherme.</div><div><div class="h5"><br><div class="gmail_quote"><div dir="ltr">Em seg, 20 de jun de 2016 às 01:19, Mary Haley &lt;<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>&gt; escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Guilherme,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The error message is indicating that that units of &quot;time&quot; are not set right before you call cd_calendar. You said that you did explicitly set this, but I can&#39;t tell from looking at the code how you did this. You need to look at your &quot;time&quot; array every time in the loop, using &quot;printVarSummary&quot; to verify whether or not you have the expected &quot;units&quot; attribute:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default">         time := f-&gt;$nome_var(0)$</div><div class="gmail_default">         printVarSummary(time)         ; Check for valid &quot;units&quot; attribute</div><div class="gmail_default">         YYYYMM := cd_calendar(time,-1)</div><div class="gmail_default"><br></div><div class="gmail_default">You have this code in both the &quot;if&quot; and &quot;else&quot; parts of an &quot;if&quot; statement, so you must do this in both locations.</div><div class="gmail_default"><br></div><div class="gmail_default">For your second question, you didn&#39;t indicate exactly what the problem is.  Are you getting an error of any kind? Does the file simply not exist after you run the script?  Please be explicit. Your code looks correct to me, but without being able to run it, or knowing if there are any errors, it&#39;s hard to help.</div><div class="gmail_default"><br></div><div class="gmail_default">--Mary</div><div class="gmail_default"><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Sat, Jun 18, 2016 at 1:15 PM, Guilherme Martins <span dir="ltr">&lt;<a href="mailto:jgmsantos@gmail.com" target="_blank">jgmsantos@gmail.com</a>&gt;</span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi users,<div><br></div><div><div><div>1) I&#39;m reading some netCDF files to interpolate and to fill missing values.</div><div><br></div><div>The first model it&#39;s ok, but the others I don&#39;t know why the reason it don&#39;t work. I get the following message error:</div></div></div><div><br></div><div><b><span style="line-height:1.5">fatal:cd_calendar: no &#39;units&#39; attribute provided</span><br></b></div><div><div><b>fatal:[&quot;Execute.c&quot;:8575]:Execute: Error occurred at or near line 25 in file 01limpa.CMIP5.ncl</b></div></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">I tried to use the time@units = &quot;day since ...&quot; but it doesn&#39;t work.</span><br></div><div><br></div><div>2) Other question, I want to write the four variables (&quot;hus&quot;,&quot;ua&quot;,&quot;va&quot;,&quot;ps&quot;) in same netCDF file for each model, but I&#39;m not capable to do that.<br></div><div><br></div><div>My script is in attachment.</div><div><br></div><div>Any help is very apreciated.</div><div><br></div><div>Cheers,</div><div><br></div><div>Guilherme Martins.</div></div><span><font color="#888888"><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><font size="2"><div>------------------------------------------------------------------------------------------</div><div>Dr. Guilherme Martins</div><div>Instituto Nacional de Pesquisas Espaciais (INPE)<br></div></font></div><div><font size="2">Centro de Previsão de Tempo e Estudos Climáticos (CPTEC)<br></font>Grupo de Desenvolvimento em Assimilação de Dados (GDAD)<font size="2"><br></font></div><div>Telefone (INPE/CP): <a href="tel:%2B55%2012%203186-8551" value="+551231868551" target="_blank">+55 12 3186-8551</a> || Celular (TIM): <a href="tel:%2B55%2012%2098152-8580" value="+5512981528580" target="_blank">+55 12 98152-8580</a><br>E-mail: <a href="mailto:guilherme.martins@inpe.br" target="_blank">guilherme.martins@inpe.br</a> || <a href="mailto:jgmsantos@gmail.com" target="_blank">jgmsantos@gmail.com</a><br>Skype: guilherme.martins.<br>Homepage: <a href="https://sites.google.com/site/jgmsantos" target="_blank">https://sites.google.com/site/jgmsantos</a><br>Currículo Lattes: <a href="http://lattes.cnpq.br/5997657584785803" target="_blank">http://lattes.cnpq.br/5997657584785803</a><span><br></span>------------------------------------------------------------------------------------------</div></div></div>
</font></span><br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><font size="2"><div>------------------------------------------------------------------------------------------</div><div>Dr. Guilherme Martins</div><div>Instituto Nacional de Pesquisas Espaciais (INPE)<br></div></font></div><div><font size="2">Centro de Previsão de Tempo e Estudos Climáticos (CPTEC)<br></font>Grupo de Desenvolvimento em Assimilação de Dados (GDAD)<font size="2"><br></font></div><div>Telefone (INPE/CP): <a href="tel:%2B55%2012%203186-8551" value="+551231868551" target="_blank">+55 12 3186-8551</a> || Celular (TIM): <a href="tel:%2B55%2012%2098152-8580" value="+5512981528580" target="_blank">+55 12 98152-8580</a><br>E-mail: <a href="mailto:guilherme.martins@inpe.br" target="_blank">guilherme.martins@inpe.br</a> || <a href="mailto:jgmsantos@gmail.com" target="_blank">jgmsantos@gmail.com</a><br>Skype: guilherme.martins.<br>Homepage: <a href="https://sites.google.com/site/jgmsantos" target="_blank">https://sites.google.com/site/jgmsantos</a><br>Currículo Lattes: <a href="http://lattes.cnpq.br/5997657584785803" target="_blank">http://lattes.cnpq.br/5997657584785803</a><span><br></span>------------------------------------------------------------------------------------------</div></div></div></div></div></div>
</blockquote></div><br></div>