<div dir="ltr"><div>The NCL function <b>status_exit</b> allows the user program to set the integer exit status code, which can be read by the shell. This is probably what you want. See the example and discussion on that function's doc page.</div><div><br></div><div>I can think of four kinds of NCL fatal errors:</div><div><br></div><div>* NCL reports a "fatal error" to the console, but the program keeps running and does not exit. This happens more often than I would like.</div><div>* NCL internally detects some kind of fatal error, and exits to the shell.</div><div>* NCL has an uncontrolled crash and exits to the shell.</div><div>* An NCL user program detects a problem and exits to the shell using the <b>status_exit</b> function.</div><div><br></div><div>Unfortunately the exit status code is undefined in the first three cases. This is why it is best for user programs to manually check for predictable errors, and handle their own error exits in an intelligent way. One example is to check for missing input files with functions like <b>isfilepresent</b> before blindly trying to open them with <b>addfile</b>, <b>cbinread</b>, etc.</div><div><br></div><div>Also I usually use an <b>if</b> statement in C shell to check the exit code. Not being a bash expert, I do not understand the double pipe syntax in your example. If you think your NCL program is emitting proper exit codes, you might check your bash code to make sure it is doing what you think.</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 12, 2020 at 10:57 AM Micah Sklut via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, <div><br></div><div>I run a bunch of ncl script operationally in bash scripts. I'd like to be able to detect if NCL encounters a fatal error. Any suggestions on this? </div><div><br></div><div>I've tried this without success: </div><div><br></div><div>
ncl nam_file.ncl || {<br> echo 'failure'<br> exit<br> }<br><div><br></div><div>Thanks. </div>-- <br><div dir="ltr">Micah Sklut</div></div></div></blockquote></div></div>