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

Home » Public Forums » archive » Re: Silent errors in run-time
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: Silent errors in run-time [message #45821] Thu, 13 October 2005 05:30 Go to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1129198152.558737.98510@g44g2000cwa.googlegroups.com>,
otto.hyvarinen@fmi.fi wrote:

> Thank you for your answers, I didn't get the solution I was looking
> for, but at least I discovered a work-around.
>
> This time I try to be more clear: If I have a program like
>
> pro test
> openr,1,"nofile"
> close,1
> end
>
> and run it interactively. I get:
>
> IDL> .compile test
> % Compiled module: TEST.
> IDL> test
> % OPENR: Error opening file. Unit: 1, File: nofile
> No such file or directory
> % Execution halted at: TEST 2 /home/hyvarine/test.pro
> % $MAIN$
> IDL>
>
> No suprises here.
>
> If I compile it and then run it like this
>
> IDL> .compile test
> % Compiled module: TEST.
> IDL> resolve all
> % Compiled module: RESOLVE ALL.
> % Compiled module: PATH SEP.
> % Compiled module: UNIQ.
> IDL> save,/routines,filename='test.sav'
> IDL>
> [hyvarine@rokka somedir]$ idl -rt="test.sav"

Ah, so the runtime license sends error messages through DIALOG_MESSAGE, which
makes sense when there is no command line. Since you have a full license, can
you run it using that, or do you need to use the runtime license?

Such as,

idl -e "TEST" >& idl.log

Ken Bowman
Re: Silent errors in run-time [message #45823 is a reply to message #45821] Thu, 13 October 2005 03:09 Go to previous messageGo to next message
otto.hyvarinen is currently offline  otto.hyvarinen
Messages: 3
Registered: October 2005
Junior Member
Thank you for your answers, I didn't get the solution I was looking
for, but at least I discovered a work-around.

This time I try to be more clear: If I have a program like

pro test
openr,1,"nofile"
close,1
end

and run it interactively. I get:

IDL> .compile test
% Compiled module: TEST.
IDL> test
% OPENR: Error opening file. Unit: 1, File: nofile
No such file or directory
% Execution halted at: TEST 2 /home/hyvarine/test.pro
% $MAIN$
IDL>

No suprises here.

If I compile it and then run it like this

IDL> .compile test
% Compiled module: TEST.
IDL> resolve_all
% Compiled module: RESOLVE_ALL.
% Compiled module: PATH_SEP.
% Compiled module: UNIQ.
IDL> save,/routines,filename='test.sav'
IDL>
[hyvarine@rokka somedir]$ idl -rt="test.sav"

I will get a dialog box (by DIALOG_MESSAGE, I think) saying "The
following error was encountered: OPENR: Error opening file. Unit: 1,
File: nofile Please consult the supplier of the application.". My
problem was how to get rid of this box and get the error messages back
to stderr (or stdout). No one seems to know that. But at least now I
know how to change my program to

pro test2
catch, theError
if (theError ne 0) then begin
catch, /cancel
goto, theEnd
endif
openr,1,"nofile"
theEnd:
close,1
end

and this way get rid of the message for all. This is enough for me.

regards,
Otto Hyvärinen
Re: Silent errors in run-time [message #45828 is a reply to message #45823] Wed, 12 October 2005 14:09 Go to previous messageGo to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <dijp5c$3ui$1@news.nems.noaa.gov>,
Rick Towler <rick.towler@nomail.noaa.gov> wrote:

> Well, he says "needs to be clicked at" which makes me think he is
> talking about a dialog box. Possibly a component of his application
> reports errors via DIALOG_MESSAGE and in this case the application is
> probably already CATCHing errors so my approach wouldn't work.
>
> If the issue is a dialog box, you will need to modify your code such
> that they aren't displayed. Either by commenting the calls or by
> replacing them with a non-gui equivalent. You may want to look at David
> Fanning's ERROR_MESSAGE function.
>
> -Rick

Well, DIALOG_MESSAGE does open a graphics window (containing widgets), but that
may be quibbling. I guess the point is that IDL is not opening the window of
its own volition, but due to something explicit in the user's program.

Cheers, Ken
Re: Silent errors in run-time [message #45831 is a reply to message #45828] Wed, 12 October 2005 12:26 Go to previous messageGo to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Kenneth Bowman wrote:
> In article <1129101910.515866.264760@g47g2000cwa.googlegroups.com>,
> otto.hyvarinen@fmi.fi wrote:
>
>
>>> You need to "redirect output". Syntax varies slightly depending on which
>>> shell
>>> you are running. In csh (and tcsh) I do something like this
>>> idl >>& my idl log
>>
>> Unfortunately this doesn't help, because IDL opens a window , that
>> needs to be clicked at. I can redirect my stdout and stderr where ever
>> I want, but it doesn't make any difference. It is an IDL problem, not a
>> shell script problem, I sincerly believe.
>>
>> regards,
>> Otto Hyv�rinen
>
>
> I assume you mean a *graphics* window.

Well, he says "needs to be clicked at" which makes me think he is
talking about a dialog box. Possibly a component of his application
reports errors via DIALOG_MESSAGE and in this case the application is
probably already CATCHing errors so my approach wouldn't work.

If the issue is a dialog box, you will need to modify your code such
that they aren't displayed. Either by commenting the calls or by
replacing them with a non-gui equivalent. You may want to look at David
Fanning's ERROR_MESSAGE function.

-Rick
Re: Silent errors in run-time [message #45832 is a reply to message #45831] Wed, 12 October 2005 12:01 Go to previous messageGo to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1129101910.515866.264760@g47g2000cwa.googlegroups.com>,
otto.hyvarinen@fmi.fi wrote:

>> You need to "redirect output". Syntax varies slightly depending on which
>> shell
>> you are running. In csh (and tcsh) I do something like this
>> idl >>& my idl log
>
> Unfortunately this doesn't help, because IDL opens a window , that
> needs to be clicked at. I can redirect my stdout and stderr where ever
> I want, but it doesn't make any difference. It is an IDL problem, not a
> shell script problem, I sincerly believe.
>
> regards,
> Otto Hyv�rinen

I assume you mean a *graphics* window. IDL won't open a graphics window unless
your program asks it to. If you want to run in batch mode, you need to make
sure that your program doesn't issue any graphics commands. Check your startup
file for stray graphics commands or DEVICE calls.

There are a number of other workarounds, such as:

1. set the graphics device to PS
2. set the graphics device to Z
3. use the xvfb program to provide a virtual X-windows device
4. use the IDLgrBuffer for object graphics.

You can search the archives of this newsgroup for more on these options.

Cheers, Ken Bowman
Re: Silent errors in run-time [message #45833 is a reply to message #45832] Wed, 12 October 2005 09:28 Go to previous messageGo to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
otto.hyvarinen@fmi.fi wrote:
>> You need to "redirect output". Syntax varies slightly depending on which shell
>> you are running. In csh (and tcsh) I do something like this
>> idl >>& my_idl_log
>
>
> Unfortunately this doesn't help, because IDL opens a _window_, that
> needs to be clicked at. I can redirect my stdout and stderr where ever
> I want, but it doesn't make any difference. It is an IDL problem, not a
> shell script problem, I sincerly believe.

I thought you could simply turn off error reporting altogether but I
must be thinking of MATLAB since I can't find any reference to this in
the docs.

But you could insert a CATCH statement somewhere to handle the error,
maybe write some info to a file, then stop execution. All without IDL
reporting an error. You would also have to set !EXCEPT=0 to suppress
reporting of math errors (which CATCH doesn't catch). You may want to
structure it so you can easily report errors when you are debugging.


pro test_error

debug=0

if (debug) then begin
theError=0
catch, theError
if (theError ne 0) then begin
catch, /cancel
goto, theEnd
endif
endif

openr, lun, 'c:\nofile', /get_lun

theEnd:

end


-Rick
Re: Silent errors in run-time [message #45837 is a reply to message #45833] Wed, 12 October 2005 00:25 Go to previous messageGo to next message
otto.hyvarinen is currently offline  otto.hyvarinen
Messages: 3
Registered: October 2005
Junior Member
> You need to "redirect output". Syntax varies slightly depending on which shell
> you are running. In csh (and tcsh) I do something like this
> idl >>& my_idl_log

Unfortunately this doesn't help, because IDL opens a _window_, that
needs to be clicked at. I can redirect my stdout and stderr where ever
I want, but it doesn't make any difference. It is an IDL problem, not a
shell script problem, I sincerly believe.

regards,
Otto Hyvärinen
Re: Silent errors in run-time [message #45847 is a reply to message #45837] Tue, 11 October 2005 07:23 Go to previous messageGo to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1129035538.813436.242790@g43g2000cwa.googlegroups.com>,
otto.hyvarinen@fmi.fi wrote:

> I have a bunch of IDL scripts I want to run with cron in Linux. I have
> compiled and saved them, and now run them with 'idl
> -rt="somthing.sav"'.
>
> All is well, except when there is an error, IDL wants to open a window
> with the error message. That is not what I want. I would like to either
> put those messages to stderr or supress them altogether (I don't
> actually care what happens. If a script fails, it fails.). Is there
> some extra command line option, or something I can use?
>
> regards,
> Otto Hyv�rinen

You need to "redirect output". Syntax varies slightly depending on which shell
you are running.

In csh (and tcsh) I do something like this

idl >>& my_idl_log

to append both standard output and standard error to the file my_idl_log.

Ken Bowman
Re: Silent errors in run-time [message #45936 is a reply to message #45837] Tue, 18 October 2005 16:13 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
otto.hyvarinen@fmi.fi writes:
>> You need to "redirect output". Syntax varies slightly depending on which shell
>> you are running. In csh (and tcsh) I do something like this
>> idl >>& my_idl_log
>
> Unfortunately this doesn't help, because IDL opens a _window_, that
> needs to be clicked at. I can redirect my stdout and stderr where ever
> I want, but it doesn't make any difference. It is an IDL problem, not a
> shell script problem, I sincerly believe.

I'm coming into this a bit late, but here's a suggestion. If you
don't use graphics, why not do "unsetenv DISPLAY". IDL won't put up a
window if it doesn't know that a windowing system exists.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Format query
Next Topic: Re: declare variables

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

Current Time: Wed Oct 08 09:14:59 PDT 2025

Total time taken to generate the page: 0.00648 seconds