<div dir="ltr"><div>NCL is a 'strongly-typed' language.</div><div><br></div><div>One consequence is that it will not allow a larger dimensione variable to overwrite a smaller dimensioned variable.</div><div><br></div><div>EG: variable 'A' exists and is (say)  A(10) and, subsequently there is Anew(20), NCL will not allow:</div><div><br></div><div>   A = Anew  ; not allowed</div><div><br></div><div>NCL requires that the '<a href="https://www.ncl.ucar.edu/Document/Language/varb_assign.shtml"><b>reassignment operator</b></a>' [ <b>:=</b> ] be used<br></div><div><br></div><div>   A<b> :=</b> Anew <br></div><div><br></div><div>====</div><div>do nf = 0,nfiles-1<br>psfc <b>:=</b> wrf_user_getvar(a[nf],"slp",-1)<br>psfc  = decimalPlaces(psfc,2,True)</div><div>; Loop temporal<br><br>times <b>:=</b> wrf_user_getvar(a[nf],"times",-1)<br>ntimes = dimsizes(times)<br></div><div>[snip]<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 30, 2019 at 4:44 PM Borja Sas González via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">In the following script, the"slp" variable is extracted from several WRF out files and the values are written to the CSV file. The variables are read file by file due to a memory problem. The problem comes when the amount of time steps of the out files are different. In this case, all the files have 1000 time steps, minus one, which has 700. If I run the script taking into account the 700 time step file, the script prints the following error: </div><div dir="ltr"><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">fatal:Dimension sizes of left hand side and right hand side of assignment do not match</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">fatal:["Execute.c":8637]:Execute: Error occurred at or near line 41 in file slp.ncl</span></p></div><div dir="ltr"><br></div><div dir="ltr">If I omit the 700 time step file, the script works successfully. How can I fix the script so that it does not print error when the time steps are not the same?</div><div dir="ltr"><br></div><div dir="ltr"><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">begin</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Abrir archivo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">files = systemfunc("ls /home/ssd/chile/WRF/test/em_real/wrfout_d03_*") + ".nc"</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">a = addfiles(files,"r")</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Definir latitud y longitud</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lat = -22.056923</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lon = -68.573862</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Localización del punto más próximo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">opt = True ; Devuelve la coordenada entera</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">loc = wrf_user_ll_to_xy(a,lon,lat,opt) ; Pasa lon/lat a xy más próximo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures">  </span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lat2 = loc(1) ; Latitud para las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lon2 = loc(0) ; Longitud para las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Opciones del encabezado</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">csv_filename = "slp.csv"</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">system("rm -f " + csv_filename)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">fields = (/"TIME, PRESSURE (hPa)"/)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Crear encabezado</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">dq = str_get_dq()</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">fields = dq + fields + dq</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">header = [/str_join(fields,",")/]</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Formato de escritura de las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">format = "%s,%g,%g,%g;%g" ; Para escribir sin espacios</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Crea el archivo con el encabezado</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">write_table(csv_filename, "w", header, "%s")</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Para leer archivo por archivo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">nfiles = dimsizes(files)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">do nf = 0,nfiles-1</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Presión en superficie</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">psfc = wrf_user_getvar(a[nf],"slp",-1)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">psfc = decimalPlaces(psfc,2,True)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Loop temporal</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">times = wrf_user_getvar(a[nf],"times",-1)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">ntimes = dimsizes(times)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">do it = 0,ntimes-1</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Crea el archivo con las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">alist = [/times(it),psfc(it,lat2,lon2)/]</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">write_table(csv_filename, "a", alist, format)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">end do</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">end do</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">end</span></p><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><br></div>-- <br><div dir="ltr" class="gmail-m_6523042532376210858gmail_signature">Borja Sas González</div></div></div></div></div>
_______________________________________________<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></blockquote></div>