[ncl-talk] fatal:Dimension sizes of left hand side and right hand side of assignment do not match

Dennis Shea shea at ucar.edu
Mon Sep 30 11:05:16 MDT 2019


NCL is a 'strongly-typed' language.

One consequence is that it will not allow a larger dimensione variable to
overwrite a smaller dimensioned variable.

EG: variable 'A' exists and is (say)  A(10) and, subsequently there is
Anew(20), NCL will not allow:

   A = Anew  ; not allowed

NCL requires that the '*reassignment operator*
<https://www.ncl.ucar.edu/Document/Language/varb_assign.shtml>' [ *:=* ] be
used

   A* :=* Anew

====
do nf = 0,nfiles-1
psfc *:=* wrf_user_getvar(a[nf],"slp",-1)
psfc  = decimalPlaces(psfc,2,True)
; Loop temporal

times *:=* wrf_user_getvar(a[nf],"times",-1)
ntimes = dimsizes(times)
[snip]

On Mon, Sep 30, 2019 at 4:44 PM Borja Sas González via ncl-talk <
ncl-talk at ucar.edu> wrote:

> 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:
>
> fatal:Dimension sizes of left hand side and right hand side of assignment
> do not match
>
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 41 in
> file slp.ncl
>
> 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?
>
> begin
>
>
> ; Abrir archivo
>
> files = systemfunc("ls /home/ssd/chile/WRF/test/em_real/wrfout_d03_*") +
> ".nc"
>
> a = addfiles(files,"r")
>
>
> ; Definir latitud y longitud
>
> lat = -22.056923
>
> lon = -68.573862
>
>
> ; Localización del punto más próximo
>
> opt = True ; Devuelve la coordenada entera
>
> loc = wrf_user_ll_to_xy(a,lon,lat,opt) ; Pasa lon/lat a xy más próximo
>
>
>
> lat2 = loc(1) ; Latitud para las variables
>
> lon2 = loc(0) ; Longitud para las variables
>
>
> ; Opciones del encabezado
>
> csv_filename = "slp.csv"
>
> system("rm -f " + csv_filename)
>
> fields = (/"TIME, PRESSURE (hPa)"/)
>
>
> ; Crear encabezado
>
> dq = str_get_dq()
>
> fields = dq + fields + dq
>
> header = [/str_join(fields,",")/]
>
>
> ; Formato de escritura de las variables
>
> format = "%s,%g,%g,%g;%g" ; Para escribir sin espacios
>
>
> ; Crea el archivo con el encabezado
>
> write_table(csv_filename, "w", header, "%s")
>
>
> ; Para leer archivo por archivo
>
> nfiles = dimsizes(files)
>
>
> do nf = 0,nfiles-1
>
>
> ; Presión en superficie
>
> psfc = wrf_user_getvar(a[nf],"slp",-1)
>
> psfc = decimalPlaces(psfc,2,True)
>
>
> ; Loop temporal
>
> times = wrf_user_getvar(a[nf],"times",-1)
>
> ntimes = dimsizes(times)
>
>
> do it = 0,ntimes-1
>
>
> ; Crea el archivo con las variables
>
> alist = [/times(it),psfc(it,lat2,lon2)/]
>
> write_table(csv_filename, "a", alist, format)
>
>
> end do
>
>
> end do
>
>
> end
>
>
> --
> Borja Sas González
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190930/463a0a46/attachment.html>


More information about the ncl-talk mailing list