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

Home » Public Forums » archive » Re: idl hangs when reading ascii file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: idl hangs when reading ascii file [message #80242] Sat, 19 May 2012 16:00
whdaffer is currently offline  whdaffer
Messages: 10
Registered: January 2000
Junior Member
Søren;

When you say you've tried 'other methods.' Have you tried something
like this?

; --- untested code snippet ---

nlines=file_lines('rot.out')
;;; hmmm...might what to check if nlines NE 0 here.
data=fltarr(2,nlines)
openr,lun,'rot.out',/get,error=err
if err ne 0 then begin
... handle error however you want to...
... perhaps by returning, or exiting? ...
endif

;; having gotten here, means you've handled the error, so
;; we're good to go.

readf,lun,data
free_lun,lun

; --- untested code snippet ---


You say 'rot.out' constantly being recreated. Is it possible that the
manner in which it is being created can leave the file unclosed just
at the time you attempt your spawn? I know that you say you put some
waits in to make sure, but is it still possible that the writing
routine may have errored out before it issued the close, and so the
file looks open to the filesystem? I don't know how spawn + cat coming
out of an IDL session would react to a file that hasn't been closed by
the filesystem yet.

Finally, is this file on an NFS mounted disk? NFS can have some (quite
a bit) of latency, particularly if you're doing a lot of opening/
closing of a file, which it sounds like you may be doing. If the file
is on an NFS mounted disk, try moving to a local disk and see if that
fixes it.

Just some thoughts.

whd

On May 18, 9:17 am, Søren Frimann <sfrim...@gmail.com> wrote:
> Hi all,
>
> I'm having a problem that I myself at least consider very strange.
>
> I'm running the below bit of code in IDL
>
> *****************************
>   spawnrob, 'cat rot.out',data
>   instr = fltarr(2,n_elements(data))
>   print, n_elements(data)
>   for i=0,n_elements(data)-1 do begin
>     instr(*,i) = float(strsplit(data(i),/extract))
>   endfor
> *********************************
>
> The code uses the shell command cat to read the file 'rot.out'. This
> piece of code is runs over and over since the ascii file 'rot.out' is
> constantly deleted and created anew. At some point however some
> process hang -- I have no control of the terminal and have to kill
> idl.
>
> I know the problem comes from the above piece of code from printing
> diagnostic statements throughout the program, and I've discovered that
> it always stalls at some point within the for-loop
>
> There seems to be no problem with the ascii file itself (after killing
> I can restart idl and read the file with no problems), and the code
> will have worked fine for more than 100 calls before failing.
>
> I've tried introducing wait commands to make sure that the ascii file
> has been written and deleted properly from the disk before trying to
> read it, but that doesn't help either.
>
> I've tried several other ways of reading in the file, but nomatter
> what method I use the code will always fail after some time.
>
> I'm on ubuntu 12.04 32-bit and use IDL 7.0. I've also tried running
> the code on my Ubuntu 12.04 64-bit laptop, also running IDL 7.0, but
> with same result.
>
> I've never had a problem in IDL that baffles me quite this much. Any
> help would be much appreciated.
>
> Cheers,
> Søren
[Message index]
 
Read Message
Previous Topic: Re: Inner Hull
Next Topic: IDL hangs on futex_wait_private

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

Current Time: Sun Oct 12 02:38:52 PDT 2025

Total time taken to generate the page: 0.88081 seconds