[ncl-talk] difficulty reading multiple files with different dimensions.
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Tue Feb 17 08:39:03 MST 2026
When a variable changes size or type in a loop, use the *reassignment
operator ":="* to redefine the variable each time through the loop. Read
about the *reassignment operator*:
https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#Reassignment
Change one line:
ReadFile = asciiread(files(NF),-1,"string")
To this:
ReadFile := asciiread(files(NF),-1,"string")
On Mon, Feb 16, 2026 at 12:15 AM Geeta Geeta via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
> Hi
> I have multiple files (TEXT files) like this
>
> Variable: files
> Type: string
> Total Size: 248 bytes
> 31 values
> Number of Dimensions: 1
> Dimensions and sizes: [31]
> Coordinates:
> (0)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_01.his
> (1)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_02.his
> (2)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_03.his
> (3)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_04.his
> (4)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_05.his
> (5)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_06.his
> (6)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_07.his
> (7)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_08.his
> (8)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_09.his
> (9)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_10.his
> (10)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_11.his
> (11)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_12.his
> (12)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_13.his
> (13)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_14.his
> (14)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_15.his
> (15)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_16.his
> (16)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_17.his
> (17)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_18.his
> (18)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_19.his
> (19)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_20.his
> (20)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_21.his
> (21)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_22.his
> (22)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_23.his
> (23)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_24.his
> (24)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_25.his
> (25)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_26.his
> (26)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_27.his
> (27)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_28.his
> (28)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_29.his
> (29)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_30.his
> (30)
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_31.his
>
>
> Variable: Nfile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 31
>
> Code that is reading these
> files = systemfunc("ls
> /mnt/c/Users/ACER/Downloads/CELIOMETER/AWOS/AWOSdata/2024/Aug/CLOUD_ALL_*")
> printVarSummary(files)
> print(files)
> Nfile = dimsizes(files)
> ; printVarSummary(Nfile)
> print(Nfile)
>
>
>
> do NF = 0, Nfile-1
> ReadFile = asciiread(files(NF),-1,"string") ; Read each file as string
> DimFile = dimsizes(ReadFile)
> print(DimFile)
> ; print(ReadFile);
> end do
>
> This code is NOT executed till end as dimensions of 6th and 7th file are
> different.
>
> Variable: DimFile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 5762
>
>
> Variable: DimFile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 5762
>
>
> Variable: DimFile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 5762
>
>
> Variable: DimFile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 5762
>
>
> Variable: DimFile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 5762
>
>
> Variable: DimFile
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 5762
> 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 33 in
> file c1.ncl
>
>
> I Request to help me sort out this
>
> Geeta.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20260217/e9e044cc/attachment.htm>
More information about the ncl-talk
mailing list