4.1. Starting a Mechanical APDL Session from the Command Level

To start an interactive session in graphics mode on Linux systems, enter the following command at the prompt:

ansys242 -g

To start Mechanical APDL from the command prompt on a Windows system, type the following command:

ansys242

Always use the ansys242 command for running Mechanical APDL. User-written scripts for running Mechanical APDL products are not supported.

You can specify any of the following options for the Mechanical APDL execution command:

-aasEnables server mode. When enabling server mode, a custom name for the keyfile can be specified using the -iorFile option. For more information, see Mechanical APDL as a Server User's Guide.
-acc deviceEnables the use of GPU hardware to accelerate the analysis. See GPU Accelerator Capability in the Parallel Processing Guide for more information.
-amfgEnables the additive manufacturing capability (requires an additive manufacturing license). For general information about this feature, see Additive Simulation in Mechanical.
-ansexeIn the Ansys Workbench environment, activates a custom Mechanical APDL executable.
-apip onTo include usage data specific to your simulation in the Ansys Product Improvement Program.
-b list or nolistActivates the Mechanical APDL program in batch mode. The options -b list or -b by itself cause the input listing to be included in the output. The -b nolist option causes the input listing not to be included. For more information about running Mechanical APDL in batch mode, see Batch Mode.
-customCalls a custom Mechanical APDL executable. See Running Your Custom Executable in the Programmer's Reference for more information.
-d deviceSpecifies the type of graphics device. This option applies only to interactive mode. For Linux systems, graphics device choices are X11, X11C, or 3D. For Windows systems, graphics device options are WIN32 or WIN32C, or 3D.
-db valueDefines the portion of workspace (memory) to be used as the initial allocation for the database. The default is 1024 MB. Specify a negative number (-value) to force a fixed size throughout the run; useful on small memory systems.
-dirDefines the initial working directory. Using the -dir option overrides the ANSYS242_WORKING_DIRECTORY environment variable.
-disEnables distributed-memory parallel processing (DMP). See the Parallel Processing Guide for more information.
-dvtEnables Ansys DesignXplorer advanced task (add-on).
-g Launches the Mechanical APDL program with the Graphical User Interface (GUI) on. If you select this option, an X11 graphics device is assumed for Linux unless the -d option specifies a different device. This option is not used on Windows systems. To activate the GUI after Mechanical APDL has started, enter two commands in the input window: /SHOW to define the graphics device, and /MENU,ON to activate the GUI. The -g option is valid only for interactive mode.

Note:  If you start Mechanical APDL via the -g option, the program ignores any /SHOW command in the start.ans file and displays a splash screen briefly before opening the GUI windows.

-i inputnameSpecifies the name of the file to read input into Mechanical APDL for batch processing. On Linux, the preferred method to indicate an input file is <.
-iorFile keyfile_nameSpecifies the name of the server keyfile when enabling server mode. If this option is not supplied, the default name of the keyfile is aas_MapdlID.txt. For more information, see Mechanical APDL as a Server Keyfile in the Mechanical APDL as a Server User's Guide.
-j JobnameSpecifies the initial jobname, a name assigned to all files generated by the program for a specific model. If you omit the -j option, the jobname is assumed to be file.
-l languageSpecifies a language file to use other than US English. This option is valid only if you have a translated message file in an appropriately named subdirectory in /ansys_inc/v242/ansys/docu (or Program Files\ANSYS Inc\V242\ANSYS\docu on Windows systems).
-m workspaceSpecifies the total size of the workspace (memory) in megabytes used for the initial allocation. If you omit the -m option, the default is 2 GB (2048 MB). Specify a negative number (-value) to force a fixed size throughout the run.
-machinesSpecifies the machines on which to run a DMP analysis (see Starting a DMP Analysis in the Parallel Processing Guide).
-mpiSpecifies the type of MPI to use. See the Parallel Processing Guide for more information.
-mpifileSpecifies an existing MPI file (appfile) to be used in a DMP run. See Using MPI Files in the Parallel Processing Guide for more information.
-naSpecifies the number of GPU accelerator devices per machine or compute node when running with the GPU accelerator feature. See GPU Accelerator Capability in the Parallel Processing Guide for more information.
-name valueDefines Mechanical APDL parameters at program start-up. The parameter name must be at least two characters long. For details about parameters, see the Ansys Parametric Design Language Guide.
-npFor a shared-memory parallel processing (SMP) analysis, -np specifies the number of threads/process. Since there is only one process for SMP, -np is the number of threads or CPU cores to be used.

For a DMP analysis, -np specifies the number of processes or CPU cores to be used.

For a hybrid parallel processing analysis,-np specifies the number of processes to be used. Along with the -nt value, this option relates how many CPU cores will be used.

See the Parallel Processing Guide for more information.

-ntFor a hybrid parallel processing analysis, -nt specifies the number of threads/process to be used. Along with the -np value, this option relates to how many CPU cores will be used. See the Parallel Processing Guide for more information.
-o outputnameSpecifies the name of the file to store the output from a batch execution of Mechanical APDL. On Linux, the preferred method to indicate an output file is >.
-p productnameDefines which Ansys product will run during the session. For more detailed information about the -p option, see Selecting an Ansys Product via the Command Line.
-ppf license feature nameSpecifies which HPC license to use during a parallel processing run. See HPC Licensing in the Parallel Processing Guide for more information.
-rcopyOn a Linux cluster, specifies the full path to the program used to perform remote copy of files. The default value is /usr/bin/scp.
-s read or noreadSpecifies whether the program reads the start.ans file at start-up. If you omit the -s option, Mechanical APDL reads the start.ans file in interactive mode and not in batch mode.
-schost host name Specifies the host machine on which the coupling service is running (to which the co-simulation participant/solver must connect) in a System Coupling analysis.
-scid valueSpecifies the licensing ID of the System Coupling analysis.
-sclic port@hostSpecifies the licensing port@host to use for the System Coupling analysis.
-scname name of the solverSpecifies the unique name used by the co-simulation participant to identify itself to the coupling service in a System Coupling analysis. For Linux systems, you need to quote the name to have the name recognized if it contains a space:

ansys242 -scname "Solution 1"

-scport port number Specifies the port on the host machine upon which the coupling service is listening for connections from co-simulation participants in a System Coupling analysis.
-smpEnables shared-memory parallelism. See the Parallel Processing Guide for more information.
-usershDirects the MPI software (used in DMP or hybrid parallel processing) to use the remote shell (rsh) protocol instead of the default secure shell (ssh) protocol. See Configuration Requirements for DMP Processing in the Parallel Processing Guide for more information.
-vReturns the Mechanical APDL release number, update number, copyright date, customer number, and license manager version number.

4.1.1. Mechanical APDL Exit Codes

There may be times when Mechanical APDL exits abnormally. Check the file.err file to see if Mechanical APDL wrote an exit code to the file before ending. These error codes may help you to understand what caused the abnormal program exit:

Table 4.1: Mechanical APDL Exit Codes

CodeExplanation
0Normal exit
1Indicated error
5Command line argument error
7Licensing failure
8End of run
11Error in user routine
12Macro stop command
14Untrapped geometry kernel error
15Fatal error
16Possible full disk
17Possible corrupted or missing file
18Possible corrupted database
21Unauthorized feature accessed
25Unable to open x11 server
30Quit signal
31Failure to get signal in max time
33Crash signal (bus error, seg vi, FPE, etc.)
35Fatal error on another MPI process (DMP)
100Job already running (.lock file error)
134[a]Job aborted by the program.
137[b]Job killed by user or operating system.

[a] This exit code, specifically for Linux, occurs when the program aborts the job. An unexpected error may be the cause, and sending the data leading to the unexpected abort to your technical support provider can enable ANSYS, Inc. to improve the program.

[b] This exit code, specifically for Linux, occurs when either the user or the OS kills the job. The OS may kill the simulation process(es) if the simulation consumes too much memory, and thus reducing the model size or running on a system with more RAM may achieve a successfully completed simulation.