Email notification of completed jobs
The APDL /MAIL command is a useful feature to include email notification within an ANSYS input file. For example, one can use /MAIL to notify oneself when the analysis is complete.
Since /MAIL emails the contents of a file, use /OUTPUT or *CFOPEN to write information to a temporary file to be used as the body of the email.
There is an issue with /MAIL, however; if the ANSYS job aborts or the solution does not converge, the /MAIL command would not be processed. In these cases, one can use a shell script with the Linux “mail” command to send email notification as an alternative to using /MAIL.
A sample bash shell script to run Distributed ANSYS is below, where the input filename is assumed to be “ds.dat” with the output file as “solve.out”:
#!/bin/bash cd `dirname $0` export MPI_WORKDIR=`pwd` export ANSYS_LIST=hostname1:2:hostname2:2 export ANSYS_EMAIL=email@example.com echo "job submitted on $ANSYS_LIST in $MPI_WORKDIR" | \ mail -s "DANSYS job submitted on $ANSYS_LIST" $ANSYS_EMAIL ansys120 -b nolist -dis -machines $ANSYS_LIST -i ds.dat -o solve.out if [ $? == 0 ] then echo "job completed on $ANSYS_LIST in $MPI_WORKDIR" | \ mail -s "DANSYS job completed on $ANSYS_LIST" $ANSYS_EMAIL else echo "error occurred on $ANSYS_LIST in $MPI_WORKDIR" | \ mail -s "DANSYS job error on $ANSYS_LIST" $ANSYS_EMAIL fi
Here is a sample script for tcsh:
#!/bin/tcsh cd `dirname $0` setenv MPI_WORKDIR `pwd` setenv ANSYS_LIST hostname1:2:hostname2:2 setenv ANSYS_EMAIL email@example.com echo "job submitted on $ANSYS_LIST in $MPI_WORKDIR" | \ mail -s "DANSYS job submitted on $ANSYS_LIST" $ANSYS_EMAIL ansys120 -b nolist -dis -machines $ANSYS_LIST -i ds.dat -o solve.out if ($status) then echo "error occurred on $ANSYS_LIST in $MPI_WORKDIR" | \ mail -s "DANSYS job error on $ANSYS_LIST" $ANSYS_EMAIL else echo "job completed on $ANSYS_LIST in $MPI_WORKDIR" | \ mail -s "DANSYS job completed on $ANSYS_LIST" $ANSYS_EMAIL endif
Edit the script in a text editor, changing the list of machine names and email address accordingly. The script should be placed in the same directory as the ANSYS input file “ds.dat”. An email will be sent when the job is initiated as well as when it completes — if the solution does not converge, an “error” email is sent instead, using the ANSYS exit status. Note that since the “ansys120” command accepts additional arguments, the script can be modified further to your liking — these scripts are just meant to serve as a possible starting point.
Comments are closed.