[ncl-talk] NCL exit code on failure

Dennis Shea shea at ucar.edu
Thu Jul 7 08:14:36 MDT 2016


Would the following do what you want?

http://www.ncl.ucar.edu/Document/Functions/Built-in/status_exit.shtml

On Thu, Jul 7, 2016 at 5:21 AM, Andrew Dawson <dawson at atm.ox.ac.uk> wrote:

> I'd like to know if it is possible to make NCL exit with a non-zero status
> when it encounters a fatal error such as a subscrip error while running a
> script? If not, could this be considered for a future version?
>
> Some background:
>
> We are running an NCL program in a batch job, and would like to detect if
> the NCL program has failed. Within the program we have error checking that
> calls status_exit with a non-zero status when we identify a fatal error,
> and we can detect these errors from the shell script that calls NCL via the
> process exit status $?. All fine so far.
>
> However, we discovered one of our programs may sometimes suffer a run-time
> error due to incomplete data files, the form of this error is a subscript
> out of range error, a fatal error that terminates the NCL process.
> Unfortunately when NCL terminates it returns exit status 0, so we cannot
> detect the failure directly in the shell. Instead we have to either capture
> the output of the program and search for error messages, or re-write the
> program so that this potential error condition is explicitly checked and
> use a manual call to status_exit.
>
> A simple program to reproduce this is:
>
> begin
>     a = (/ 1 /)
>     print(a(1))
>     print("I won't be printed")
> end
>
> When run this program will terminate with a fatal error on the second
> line, and the last line will not be executed, but the exit status of the
> ncl process will be 0. It would be super convenient if the exit status was
> non-zero in this case.
>
> I'm using NCL v6.3.0 on Linux x64
>
> Thanks
> Andrew
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160707/8f3639c0/attachment.html 


More information about the ncl-talk mailing list