[ncl-talk] reading consecutive ascii files in do loop

Dennis Shea shea at ucar.edu
Tue Jun 12 13:19:26 MDT 2018


Also:

NCL is a "strongly typed language."

By design, it will not allow an *existing array* to be overwritten by a new
array of a different size.
Further, if the new array is of a different data type, it *may* not allow
the existing array to be overwritten.


fsl_data = asciiread(input(i),(/nlvl(i),ncol/), "float")   ; <=== this may
change size upon each iteration

Please use NCL's reassignment operator    *:=*
      https://www.ncl.ucar.edu/Document/Language/varb_assign.shtml

fsl_data *:=* asciiread(input(i),(/nlvl(i),ncol/), "float")

D

On Tue, Jun 12, 2018 at 1:09 PM, Dave Allured - NOAA Affiliate <
dave.allured at noaa.gov> wrote:

> Dave,
>
> The problem is in "nlvl".  You are using floats in a place that requires
> integers only.  Change the function call on this line to
> "stringtointeger".  Also, "tointeger" or "toint" would be better.
>
> nlvl = stringtofloat(str_get_cols(data,13,15))
>
> --Dave A.
>
>
> On Tue, Jun 12, 2018 at 12:51 PM, David Adams <dave.k.adams at gmail.com>
> wrote:
>
>> Hi all,
>> I am using the skew T plot routine. I try to open each ascii file and
>> plot it as a pdf. My file list contains the file name and number of lines
>> (i.e., pressure levels) in the sounding files.
>> filename       nlvl
>> 7_11_00.dat  129
>> 7_11_12.dat  122
>> 7_12_00.dat  148
>>  etc...
>> I read and open the files this way
>> -------------------------------------------------------------------------
>>  filename ="Sounding_file_list.txt"
>>    data = asciiread(filename,-1,"string")
>>     input  = str_get_cols(data,0,10)
>>     nlvl = stringtofloat(str_get_cols(data,13,15))
>>     ncol =11
>>
>>   do i = 0,47
>>       fsl_data = asciiread(input(i),(/nlvl(i),ncol/), "float")
>> etc...
>> But I get the following error.
>>
>> fatal:asciiread: The input dimension sizes must be byte, short, integer
>> or long  fatal:["Execute.c":8575]:Execute: Error occurred at or near
>> line 27 in file test.ncl
>>
>> Here is the print out of the variable filenames
>> ---------------------------------------------
>> Variable: input
>> Type: string
>> Total Size: 384 bytes
>>             48 values
>> Number of Dimensions: 1
>> Dimensions and sizes:    [48]
>> Coordinates:
>>
>> I am sure this is a simple error, but I am brain dead at this point.
>> thanks in advance,
>> Dave
>>
>
> _______________________________________________
> 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/20180612/78f0114b/attachment.html>


More information about the ncl-talk mailing list