## 3.10. Terminating Execution from a User Subroutine

Sometimes you may wish to terminate execution of a calculation if an error is detected in a user subroutine. The easiest way to do this is to simply put a STOP statement in the user subroutine. This method will immediately terminate the program and return you to the operating system. However, if you do this, you may lose information contained in output buffers.

A better way to terminate execution is to call subroutine ADQUIT described in the previous section. This will return you to the operating system in an orderly manner.

If want to stop executing a problem without quitting Autodyn you can do this by setting the wrapup switch, NSWRAP equal to 99. A non-zero value of NSWRAP (found in module WRAPUP) will cause Autodyn to stop execution at the end of the current cycle and return the user to the main menu. If NSWRAP is set equal to 99, the message

    Problem terminated by user subroutine

is displayed upon wrapup. Since the calculation will continue to the end of the cycle, it is necessary to set the return parameters of your user subroutine to reasonable values so that they can be used, if necessary, without consequence for the current cycle.

Release 18.2 - © ANSYS, Inc. All rights reserved.