[ncl-talk] NCL exit code on failure

Andrew Dawson dawson at atm.ox.ac.uk
Thu Jul 7 05:21:18 MDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160707/7a6baa1c/attachment.html 


More information about the ncl-talk mailing list