Ansys运行问题

ansys是一款有限元软件,我在安装后可以运行这款软件,但运行时总会报一些错误。比如其主程序ansys170在目录中:/ansys_inc/v170/ansys/bin。

这是一段shell程序,运行后在屏幕中显示:

./ansys170: 21: ./anssh.ini: Syntax error: Bad fd number ./ansys170: 21: ./anssh.ini: Syntax error: Bad fd number ./ansys170: 21: ./anssh.ini: Syntax error: Bad fd number

然后就会正常显示程序界面。现在我把ansys170的shell代码放在这,请大家帮我看看问题来自哪里。

[code]#!/bin/sh

revn=170
QR_PATH=“v${revn}”

Attempt to locate anssh.ini…

my_work_dir=pwd
calldir=echo $0 | sed 's!/[a-zA-Z0-9_\.]*$!!'
if “${calldir}” = “$0” ]; then
calldir=pwd
fi
cd “${my_work_dir}”

WHICHANSCRIPT=ansys;export WHICHANSCRIPT
if -f “${calldir}/anssh.ini” ]; then
. "${calldir}/anssh.ini"
else
ansdir=/ansys_inc/${QR_PATH}/ansys
. ${ansdir}/bin/anssh.ini
fi

printf “\n\n”

printf “minus_i: ${minus_i}\n”

printf “input_file: ${input_file}\n”

printf “minus_o: ${minus_o}\n”

printf “output_file: ${output_file}\n”

printf “minus_j: ${minus_j}\n”

printf “job_name: ${job_name}\n”

printf “minus_b: ${minus_b}\n”

printf “minus_m: ${minus_m}\n”

printf “cluster: ${cluster}\n”

printf “copy: ${copy}\n”

printf “upfmpifile: ${upfmpifile}\n”

printf “cluster_dir: ${cluster_dir}\n”

printf “server: ${server}\n”

ansysargs="$*"

upf='NO’
err=0
#printf “>>> START UPF <<<\n”

start /upf work

if “${server}” = “NO” ]; then
if “${minus_b}” = “YES” ]; then
if “${minus_i}” = “YES” ]; then
sh ${ANSYS_DIR}/bin/ansupf${revn} “${cluster}” “${cluster_dir}” “${upfmpifile}” “${input_file}” "${copy}“
err=$?
if ${err} -eq 13 ]; then
ANS_USER_PATH=pwd
LD_LIBRARY_PATH=”${ANS_USER_PATH}:${LD_LIBRARY_PATH}“
LD_LIBRARY_PATH_64=”${ANS_USER_PATH}:${LD_LIBRARY_PATH_64}“
SHLIB_PATH=”${ANS_USER_PATH}:${SHLIB_PATH}“
LIBPATH=”${ANS_USER_PATH}:${LIBPATH}"
export ANS_USER_PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_64 SHLIB_PATH LIBPATH
upf='YES’
else
if ${err} -ne 5 ]; then
exit 1
else
upf='NO’
fi
fi
else
# Test to see if running batch mode interactively (will appear to hang).
if -t 0 ]; then
printf “\n WARNING: Batch mode is not intended to read from a terminal. \n"
printf " >>>>>>> Program may appear to hang here until EOF is received. \n\n"
fi
if “${minus_j}” = “YES” ]; then
tmpfile=”${job_name}.$$"
else
tmpfile="stdin.$$"
fi
# Read stdin into a temporary file…
cat - > "${tmpfile}"
sh ${ANSYS_DIR}/bin/ansupf${revn} “${cluster}” “${cluster_dir}” “${upfmpifile}” ${tmpfile} "${copy}“
err=$?
if ${err} -eq 13 ]; then
ANS_USER_PATH=pwd
LD_LIBRARY_PATH=”${ANS_USER_PATH}:${LD_LIBRARY_PATH}“
LD_LIBRARY_PATH_64=”${ANS_USER_PATH}:${LD_LIBRARY_PATH_64}“
SHLIB_PATH=”${ANS_USER_PATH}:${SHLIB_PATH}“
LIBPATH=”${ANS_USER_PATH}:${LIBPATH}“
export ANS_USER_PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_64 SHLIB_PATH LIBPATH
upf='YES’
else
if ${err} -ne 5 ]; then
rm -rf ${tmpfile} 1>/dev/null 2>&1
exit 1
else
upf='NO’
fi
fi
ansysargs=”-i ${tmpfile} ${ansysargs}"
fi
else
if “${minus_i}” = “YES” ]; then
sh ${ANSYS_DIR}/bin/ansupf${revn} “${cluster}” “${cluster_dir}” “${upfmpifile}” “${input_file}” "${copy}“
err=$?
if ${err} -eq 13 ]; then
ANS_USER_PATH=pwd
LD_LIBRARY_PATH=”${ANS_USER_PATH}:${LD_LIBRARY_PATH}“
LD_LIBRARY_PATH_64=”${ANS_USER_PATH}:${LD_LIBRARY_PATH_64}“
SHLIB_PATH=”${ANS_USER_PATH}:${SHLIB_PATH}“
LIBPATH=”${ANS_USER_PATH}:${LIBPATH}"
export ANS_USER_PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_64 SHLIB_PATH LIBPATH
upf='YES’
else
if ${err} -ne 5 ]; then
exit 1
else
upf='NO’
fi
fi
fi
fi
fi

end /upf work

#printf “>>> END UPF <<<\n”
#exit

Check for zero-length input file in batch mode

if “${server}” = “NO” ]; then
if “${minus_b}” = “YES” ]; then
# Batch mode only
if “${tmpfile}” != “” ]; then
# Using < > redirect
if ! -s “${tmpfile}” ]; then
printf "\n ERROR: empty or invalid input file used in batch mode \n\n"
rm -f "${tmpfile}"
exit 1
fi
else
# Using an input file
if ! -s “${input_file}” ]; then
printf "\n ERROR: empty or invalid input file used in batch mode (${input_file}) \n\n"
exit 1
fi
fi
fi
fi

if -z “${exename}” ]; then
exename="ansys"
fi

if ${usecustom} -eq 0 ]; then
ansexe="${exename}${altansexe}${mpiexe}.e"

if “${exename}” = ‘lsdyna_sp’ ] || “${exename}” = ‘lsdyna_dp’ ] ||
“${exename}” = ‘lsdyna_sp_mpp’ ] || “${exename}” = ‘lsdyna_dp_mpp’ ]; then
ansexe="${exename}.e"
fi

if “${exename}” = “ansys” ]; then
ansexe="${exename}.e"
fi

MapdlaaS

if “${use_aaS}” = ‘YES’ ]; then
ansexe=“MapdlaaS.e"
ansexe=”${ANSYS_DIR}/bin/${ANSYS_SYSDIR}/${ansexe}"
if “${usemultmach}” -eq 1 ]; then
eval "${ansexe} ${ansysargs} -machines ${cluster}"
else
eval "${ansexe} ${ansysargs} -np ${mpinp}"
fi
exit
fi

ansexe="${ANSYS_DIR}/bin/${ANSYS_SYSDIR}/${ansexe}“
if ! -z “${ANS_SEE_RUN_COMMAND}” ]; then
case “${SYSDIR}” in
linx64 | linmic)
ldd “${ansexe}” | grep mpi
ldd “${ansexe}” | grep GPU
;;
esac
fi
else
if ${usecustomname} -eq 1 ]; then
ansexe=”${exename}“
else
ansexe=”${exename}${altansexe}${mpiexe}.e"
if -x “${my_work_dir}/${ansexe}” ]; then
ansexe="${my_work_dir}/${ansexe}“
else
ansexe=”${ANSYS_DIR}/bin/${ANSYS_SYSDIR}/${ansexe}"
fi
fi
if ! -z “${ANS_SEE_RUN_COMMAND}” ]; then
case “${SYSDIR}” in
linx64 | linmic)
ldd “${ansexe}” | grep mpi
ldd “${ansexe}” | grep GPU
;;
esac
fi
fi

if -x ${ansexe} ]; then
if “${usedis}” -eq 1 ]; then
use_prun=0
if “${usepcmpi}” -eq 1 ]; then
if -z “${ANS_HPMPI_ELAN_OFF}” ]; then
which prun 2> /dev/null 1> /dev/null
if $? -eq 0 ]; then
use_prun=1
fi
fi
fi
if “${usemultmach}” -eq 1 ] || “${usempifile}” -eq 1 ]; then
if “${usepcmpi}” -eq 1 ]; then
if “${exename}” = “mpitest” ]; then
mpi_additional_tests
fi
if “${usempifile}” -eq 0 ]; then
build_config_file_IBM
fi
if ! -f “${mpifile}” ]; then
printf “\n Error: MPI file not found: ${mpifile} \n\n"
exit 1
fi
if ${use_prun} -eq 0 ]; then
distcmd=”${distcmd} -f ${mpifile}“
else
distcmd=”${distcmd} -prun -f ${mpifile}"
fi
if ! -z “${ANS_SEE_RUN_COMMAND}” ]; then
printf "\n Running… ${distcmd} \n"
fi
eval "${distcmd}“
err=”$?"
elif “${useintelmpi}” -eq 1 ]; then
if “${exename}” = “mpitest” ]; then
mpi_additional_tests
fi
if “${usempifile}” -eq 0 ]; then
build_config_file_Intel
fi
if ! -f “${mpifile}” ]; then
printf “\n Error: MPI file not found: ${mpifile} \n\n"
exit 1
fi
if -z “${dir_name}” ]; then
dir_name=${thisdir}
fi
distcmd=”${distcmd} -r ${rshcmd} -configfile ${mpifile} "
if ! -z “${ANS_SEE_RUN_COMMAND}” ]; then
printf "\n Running… ${distcmd} \n"
fi
eval "${distcmd}“
err=”$?"
else
printf "\n MPI on this system with Multiple machines not supported yet. \n\n"
fi
else
if “${usepcmpi}” -eq 1 ]; then
if “${exename}” = “mpitest” ]; then
mpi_additional_tests
fi
if ! -z “${dir_name}” ]; then
setenv MPI_WORKDIR "${dir_name}“
fi
fi
command=”${distcmd} -np ${mpinp} ${dansys_script} ${ansysargs}“
if “${useintelmpi}” -eq 1 ]; then
if “${mpitest}” -eq 1 ]; then
command=”${distcmd} -r ${rshcmd} -np ${mpinp} ${dansys_script} ${ansysargs}“
else
if “echo \"${ansysargs}\" | grep -- \"-i \"” ]; then
if “${usempicheck}” -eq 1 ]; then
command=”${distcmd} -r ${rshcmd} -check-mpi -np ${mpinp} ${dansys_script} ${ansysargs}“
elif “${usempitrace}” -eq 1 ]; then
command=”${distcmd} -r ${rshcmd} -trace -np ${mpinp} ${dansys_script} ${ansysargs}“
else
command=”${distcmd} -r ${rshcmd} -np ${mpinp} ${dansys_script} ${ansysargs}“
fi
else
if “${usempicheck}” -eq 1 ]; then
command=”${distcmd} -r ${rshcmd} -check-mpi -np ${mpinp} ${dansys_script} ${ansysargs}“
elif “${usempitrace}” -eq 1 ]; then
command=”${distcmd} -r ${rshcmd} -trace -np ${mpinp} ${dansys_script} ${ansysargs}“
else
command=”${distcmd} -r ${rshcmd} -np ${mpinp} ${dansys_script} ${ansysargs}“
fi
fi
fi
fi
which sinfo 2> /dev/null 1> /dev/null
if $? -eq 0 ]; then
if “${usepcmpi}” -eq 1 ]; then
if -z “${ANS_HPMPI_SRUN_OPTIONS}” ]; then
ANS_HPMPI_SRUN_OPTIONS=”-n ${mpinp}“
fi
command=”${distcmd} -srun ${ANS_HPMPI_SRUN_OPTIONS} ${dansys_script} ${ansysargs}“
fi
fi
if ${use_prun} -eq 1 ]; then
if -z “${ANS_HPMPI_PRUN_OPTIONS}” ]; then
ANS_HPMPI_PRUN_OPTIONS=”-n ${mpinp}“
fi
command=”${distcmd} -prun ${ANS_HPMPI_PRUN_OPTIONS} ${dansys_script} ${ansysargs}"
fi
if ! -z “${ANS_SEE_RUN_COMMAND}” ]; then
printf "\n Running… ${command} \n"
fi
eval "${command}“
err=”$?"
fi
else
if ! -z “${ANS_SEE_RUN_COMMAND}” ]; then
printf "\n Running… ${ansexe} ${ansysargs} \n"
fi
eval "${ansexe} ${ansysargs}“
err=”$?"
fi
else
printf "\n The ANSYS program can not be found. \n\n"
printf " ${ansexe} \n\n"
printf " Check with your system administrator or your ANSYS \n"
printf " Channel Partner for information on availability. \n\n"
err=1
fi
test -f ${tmpfile} 1>/dev/null 2>&1
if $? -eq 0 ]; then
rm -f ${tmpfile} 1>/dev/null 2>&1
fi

remove any libansuser created by /upf

if ${upf} = ‘YES’ ]; then
test -f libansuser.so 1>/dev/null 2>&1
if $? -eq 0 ]; then
rm libansuser.so 1>/dev/null 2>&1
fi
test -f libansuser.sl 1>/dev/null 2>&1
if $? -eq 0 ]; then
rm libansuser.sl 1>/dev/null 2>&1
fi

restore any libansuser customer may have had before Ansys run

test -f libansuser.so.HOLD 1>/dev/null 2>&1
if $? -eq 0 ]; then
mv libansuser.so.HOLD libansuser.so
fi
test -f libansuser.sl.HOLD 1>/dev/null 2>&1
if $? -eq 0 ]; then
mv libansuser.sl.HOLD libansuser.sl
fi
fi

try to collect distributive crash dump information

if “${usedis}” -eq 1 ] && “${err}” -eq 33 ]; then
dist_crash_dump
fi

exit ${err}
[/code]

代码中提到一个文件anssh.ini,该文件在同级目录中,内容见:paste.ubuntu.com/19345149/

找到答案了,只要将ansys170中的#!/bin/sh 改为#!/bin/bash就可以了。