comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Question about 'READ input error'
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Question about 'READ input error' [message #24231] Wed, 21 March 2001 00:52
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Anil Kochhar wrote:
>
>>> readf,lun,aaa
>>> print, aaa
>>> close,lun
>>>
>>
>> Don't you need a space after the -c?
>> Dick
>>
> Sorry I doubled checked my code now, I actually have the space. I must
> have mistyped when I sent the email
> Thanks
> Anil
>>

Anil,

an input conversion error is - in short - an error that occurs
when IDL tries to interpret ASCII characters as numerical values. The
easiest way to demonstrate this is to use ReadS which works exactly
like ReadF but uses input from a string rather than a file:

IDL> s=' 1. 2. 3. 4.'
IDL> res=fltarr(4)
IDL> reads,s,res
IDL> print,res
1.00000 2.00000 3.00000 4.00000
IDL> s=' 1. 2. 3. C'
IDL> reads,s,res
% READS: Input conversion error. Unit: 0, File: <stdin>
% Execution halted at: $MAIN$

So, the error occurs, because Read expects a number but receives a
character ('C'). Now it's up to you to find out where that "format
error" in the ASCII file you are trying to read occurs. NIMBUS sounds
like a pretty standardized product - with other ASCII files I
sometimes find a ********* (indicating an overflow in a formatted
output). Different line endings (DOS/Windows vs. Unix or Mac) I think,
were also a problem until IDL 5.4.

Following up on a recent discussion here, I think it would be nice
to have a routine that reads ASCII files efficiently but safely as
well. Probably, a 2-3 step approach would be best:
(1) try to read the whole block of data at once (this is fastest)
(2) scan the file line by line if (1) fails
Step (2) could be split into (2a): try to read each line "directly",
(2b) read each line into a string first, then use ReadS.
This routine would handle the simpler file structures where (at least
after a certain number of comment lines) you only have numerical data.
For more convoluted file structures, one needs to go with the
read-into-structure approach.

This is something that has been on my list for over a year now;
but I am happy these days if I find any time for IDL at all.

Cheers,

Martin



--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
Re: Question about 'READ input error' [message #24232 is a reply to message #24231] Tue, 20 March 2001 21:34 Go to previous message
akk is currently offline  akk
Messages: 10
Registered: July 1998
Junior Member
>> readf,lun,aaa
>> print, aaa
>> close,lun
>>
>
> Don't you need a space after the -c?
> Dick
>
Sorry I doubled checked my code now, I actually have the space. I must
have mistyped when I sent the email
Thanks
Anil
>
Re: Question about 'READ input error' [message #24233 is a reply to message #24232] Tue, 20 March 2001 20:24 Go to previous message
Richard French is currently offline  Richard French
Messages: 173
Registered: December 2000
Senior Member
> My idl code is:
> --------------------------------
>
> lun=13
> aaa=fltarr(2,180,51)
> spawn,'/usr/ucb/uncompress -c'+'~anilk/Nimbus7/GriddedData/grid_EP_79134.dat.Z',unit=lu n
> readf,lun,aaa
> print, aaa
> close,lun
>

Don't you need a space after the -c?
Dick
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: AD&D site / sito AD&D
Next Topic: Re: Linux and 3D graphics hardware support

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:43:08 PDT 2025

Total time taken to generate the page: 0.00657 seconds