Re: Exit code for NCL errors

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Aug 06 2012 - 08:26:17 MDT

Hi Dave,

I've added a ticket for this, NCL-1528. As you know, we have also had people report problems with NCL exiting in an odd fashion from other programs, like shell scripts. We have a ticket for that too, NCL-793.

--Mary

On Aug 5, 2012, at 4:09 PM, Dave Allured wrote:

> Okay, I found a partial solution that may be useful. This uses the
> behavior of code blocks defined by "begin" and "end" statements.
> Apparently, many kinds of statement errors halt execution within the
> block, but resume execution following the "end" statement. The
> documentation for begin/end should be updated to explain this.
>
> So you can catch anonymous fatal errors in main programs, with
> strategic placement of the exit and status_exit statements, like this:
>
> begin
> x = new (3, float)
> x(4) = 5 ; cause subscript error
> exit ; normal termination, shell exit code = 0
> end
> status_exit (1) ; abnormal termination, shell exit code = 1
>
> This is a fairly good solution because it does not need tricky
> external code in the shell wrapper to detect whether the program
> executed normally. However, apparently this method does not catch
> errors within NCL functions. For example, this very common "file not
> found" situation will print an NCL fatal error message, but fail to
> jump to the status_exit statement:
>
> begin
> f = addfile ("does-not-exist.nc","r")
> exit
> end
> status_exit (1)
>
> Of course there are ways to add code to detect this particular error
> under program control, but that is not the point. Better detection of
> unanticipated errors will be helpful when trying to use NCL within
> shell scripts. Thanks again for your consideration.
>
> --Dave
>
> On Sun, Aug 5, 2012 at 2:35 PM, Dave Allured <dave.allured@noaa.gov> wrote:
>> NCL support team,
>>
>> Please implement an exit code to the shell indicating failure, when
>> NCL terminates abnormally. Even a partial implementation for some
>> common errors, such as syntax error, subscript out of range, and file
>> not found, would be helpful. Thank you.
>>
>> --Dave
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Aug 6 08:26:26 2012

This archive was generated by hypermail 2.1.8 : Wed Aug 15 2012 - 08:12:08 MDT