Limit in ASCII input with read
Jennifer Adams
jma at COLA.IGES.ORG
Mon Nov 26 11:07:28 EST 2007
Hi, Christoph --
The 'read' function in the scripting language boils down to a call to
'fgets' with a hard-coded size limit of RSIZ-3 (where RSIZ is defined
to be 600). I'm not sure why this limit is 600, but it could probably
be changed for version 2.0. In the meanwhile, you can call 'read' in
your script two (or more) times and concatenate the results to get a
complete line from your input file. This technique was implemented in
the basemap.gs script because some of the lines in the polygon ascii
files were very long. Relevant scripts lines from basemap.gs are
copied below, but they are based on the premise that there is known
text at the beginning of the line (in this case, the 5th word of each
line in the ascii file is "draw"). You may need to modify this code
for your application to distinguish between a reading of a new line
and the reading of the continuation of a really long line.
--Jennifer
* Read the first record from the polygon file
result = read(file)
rc = sublin(result,1)
rc = subwrd(rc,1)
if (rc!=0)
say 'Error reading 'file
return
endif
nwcmd = sublin(result,2)
* Read subsequent records, allowing for read input buffer overflow
flag = 1
while (flag)
ignore = 0
wcmd = nwcmd
while(1)
result = read(file)
rc = sublin(result,1)
rc = subwrd(rc,1)
if (rc!=0)
flag = 0
break
else
nwcmd = sublin(result,2)
if (subwrd(nwcmd,5) != 'draw')
wcmd = wcmd % nwcmd
else
break
endif
endif
endwhile
* now do something with line read from the file which is stored in wcmd
endwhile
On Nov 23, 2007, at 5:49 AM, Stegert wrote:
> Dear GrADSusers,
>
> I tried to read in an ASCII data set (m by n matrix
> corresponding to my model area defined in the .ctl)
> and found, that GrADS only read the first 576 letters
> (if I counted right) and cut the rest.
> When reducing the length of the lines, all went well.
>
> Can anyone related to the development of GrADS confirm
> this limitation? And, is it possible to overcome this
> limit in future GrADS releases?
> I'm actually using GrADS 1.8SL11 on WinXP.
>
> Cheers, Christoph
>
> --
> Christoph Stegert: Ecological Modelling group
> Institut für Meereskunde - Universität Hamburg, Germany
> Zentrum f. Marine u. Atmosphärische Wissenschaften ZMAW
> Bundesstr.53, 20146 Hamburg - Phone: +49-40/ 42838-7486
--
Jennifer M. Adams
IGES/COLA
4041 Powder Mill Road, Suite 302
Calverton, MD 20705
jma at cola.iges.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20071126/62a8b90c/attachment.html
More information about the gradsusr
mailing list