To call the Mechanical APDL program, use the following:
program ansys
For multiple calls to subroutine ansys, you must open and close
standard input in the calling subroutine. (Usually, input and output are FORTRAN units 5
and 6, respectively.) The calling subroutine cannot use the database access subroutines;
however, other user-programmable features can use the database access subroutines
freely.
Exit codes are primarily used by workflow automation tools, scripts, and job schedulers to identify the outcome of a Mechanical APDL run. You may encounter exit codes when troubleshooting job failures or unexpected termination.
If the Mechanical APDL application exits unexpectedly, an exit code may be reported by the operating system, displayed by a job scheduler, written to terminal output, or available in diagnostic files. Exit codes can help explain why the application terminated and aid in troubleshooting.
Table 2.25: Mechanical APDL Exit Codes
| Code | Name | Typical Cause(s) | Troubleshooting |
|---|---|---|---|
| 0 | Normal exit | Run completed successfully. | N/A |
| 1 | Indicated error | Indicates that one or more errors were recorded and listed by the application. The application may return this code even when the application encounters and automatically resolves certain error conditions during execution.[a] | If you obtained a valid solution and completed the analysis successfully, the application may have remediated the reported errors automatically. Review the file.err file to determine whether corrective action is required. |
| 5 | Command line argument error | Invalid, unsupported, or incorrectly formatted command line arguments. May also result from missing required parameters. | Review the launch command and verify that all arguments are valid and correctly formatted. Correct any syntax errors or unsupported options before rerunning. |
| 7 | Licensing failure | The required license is unavailable, expired, or cannot be accessed, often due to license server connectivity issues or insufficient tokens. | Verify that the license server is reachable and properly configured and confirm that the necessary licenses are available. Check environment variables and license settings and then retry the run. |
| 8 | End of run | The end of the current input file has been reached without a defined program exit. Indicates an otherwise error-free run. | Add /EXIT to the end of the input file. |
| 11 | Error in user routine | A user-defined routine fails because of coding issues, invalid memory access, or incompatibility with the current version. | Review and debug the user routine code, ensuring proper memory handling and compatibility. Recompile the routine and test with simplified inputs to isolate the issue. |
| 12 | Macro stop command | A macro issues a stop command, intentionally terminating execution based on defined logic or conditions. | Examine the macro to identify the condition triggering termination and determine whether it is expected. Modify the macro logic if the termination is unintended. |
| 14 | Untrapped geometry kernel error | A crash signal occurred while the geometry kernel was active, such as in Boolean operations. | N/A |
| 15 | Fatal error | An unrecoverable fatal error was detected, and the program execution terminates. | Look through the output file and/or error file for more information. If needed, send data leading to this operation to your Ansys technical support provider for additional troubleshooting. |
| 16 | Possible full disk | Insufficient disk space prevents the program from writing required files. | Check available disk space in the working and scratch directories and remove unnecessary files, if needed. Redirect the run to a location with sufficient storage capacity. |
| 17 | Possible corrupted or missing file | A required file is missing, inaccessible, or corrupted, preventing normal execution. | Verify that all required files exist and have appropriate permissions and then retransfer or regenerate any suspect files. Check for file system issues that may have caused corruption. |
| 18 | Possible corrupted database | The Mechanical APDL database file becomes corrupted, often due to interrupted runs or I/O failures. | Restore the database from a backup, if available, or restart the simulation from a known good state. Avoid interrupting runs to reduce the risk of corruption. |
| 21 | Unauthorized feature accessed | The input requests a feature that is not included in the current license configuration. | Review the requested features and confirm that the appropriate licenses are available. Modify the input or obtain the required licenses before rerunning. |
| 25 | Unable to open X11 server | A graphical session is requested but no X11 display is available or properly configured. | Ensure that X11 forwarding is enabled and that the DISPLAY environment variable is correctly set. If a GUI is not required, run the application in batch mode. |
| 30 | Quit signal | The application receives a quit signal from the user, operating system, or job scheduler. | Check for user interruptions or external signals from the job scheduler or operating system. Avoid sending termination signals during execution unless intended. |
| 33 | Crash signal | The program encounters a low-level runtime failure, such as a segmentation fault, floating point exception, or bus error. | Review the output file and/or error file along with any available stack trace to identify the failure point. Check the model for invalid inputs or extreme values and rerun with reduced complexity or parallel settings, if needed. |
| 35 | Fatal error on another MPI process | An MPI process fails, causing all other processes in a distributed (DMP) run to terminate. | Examine the output files and/or error files from all MPI ranks to identify the failing process and underlying issue. Check cluster health and rerun with fewer processes to isolate the problem. |
| 100 | Job already running | A .lock file indicates that another instance of the job is already running or was not properly cleaned up after termination. | Confirm that no active job is running and remove the stale .lock file if it is safe to do so. Ensure proper job termination practices to prevent recurrence. |
| 134 | Job aborted by the program | The program aborts due to an unexpected internal error. Applies only to Linux systems. | Review the error file for details surrounding the abort and capture the relevant data for analysis. Provide this information to to your Ansys technical support to assist with diagnosing the issue. |
| 137 | Job killed by user or operating system | The job is terminated by the user or operating system, often due to excessive resource usage. Applies only to Linux systems. | Check system logs and resource usage to determine why the job was terminated. Reduce model size or run on a system with more available memory to prevent recurrence. |
[a] In release 2026 R1 and earlier, exit code 1 does not necessarily indicate analysis failure. Some recoverable conditions, such as physics or modeling errors, may generate error messages and produce exit code 1 even when the application successfully resolves the condition and completes the analysis.
For example, during a nonlinear analysis, the Mechanical APDL application may encounter convergence difficulties and perform automatic bisection to reduce the time increment and continue the solution. Similar conditions may arise that report excessive element distortion, transient loss of constraints, or other solution difficulties. These types of conditions may generate an error message and cause the analysis to return exit code 1, even if the application successfully resolves the issue and completes the analysis.