2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
8 #-------------------------------------------------------------------------------
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software; you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation; either version 2 of the License, or (at your
15 # option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM; if not, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 # foamInstallationTest
30 # Checks the machine system, the installation of OpenFOAM, and the user's
31 # personal configuration for running OpenFOAM.
33 #------------------------------------------------------------------------------
37 SUPPLIED_VERSION_GCC
=4.3.1
49 USER_SHELL
=`basename $SHELL`
54 if [ ! -n $USER_NAME ]; then
58 #==============================================================================
60 #==============================================================================
63 echo "-------------------------------------------------------------------------------"
80 echo $1 |
tr -d " " |
wc -m |
tr -d " "
86 NOCHAR
=`expr $NOCHAR - 1`
87 if [ $NOCHAR -eq -1 ]; then
95 echo $1 |
wc -m |
tr -d " "
101 ONELEN
=`stringLength $1`
102 LDIFF
=`expr $ONELEN - $2`
103 if [ $LDIFF -le 1 ]; then
104 while [ $LDIFF -lt 0 ] ; do
106 LDIFF
=`expr $LDIFF + 1`
110 LDIFF
=`expr $LDIFF + 4`
111 WORD
=`echo "$WORD" | cut -c${LDIFF}-`
118 EXP_ENV
=`eval "echo $1"`
119 EXP_PATH
=`eval "echo $2"`
123 if [ `length $EXP_ENV` -gt 0 ] ; then
126 if /usr
/bin
/test -e $EXP_ENV ; then
128 if [ "$2" != "noPath" ]; then
137 -o "$e" = "${EXP_ENV}/bin" \
138 -o "${EXP_ENV}/lib" = "$e" \
150 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
153 if [ -e "$EXP_ENV" ] ; then
155 if [ "$2" != "noPath" ]; then
164 -o "$e" = "${EXP_ENV}/bin" \
165 -o "${EXP_ENV}/lib" = "$e" \
177 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
181 echo "`fixlen "$1" 21` --------- env variable not set --------- $3"
185 if [ "$EXISTS" = "no" ] ||
[ "$ON_PATH" = "no" ]; then
188 if [ "$3" = "yes" ] && [ "$ERROR" = "true" ]; then
189 CRITICALERROR
=`expr $CRITICALERROR + 1`
190 echo "WARNING: CRITICAL ERROR"
204 if /usr
/bin
/test ! -d "$d/$2" -a -x "$d/$2" ; then
211 if [ ! -d "$d/$2" -a -x "$d/$2" ]; then
224 reportExecutable
() {
226 APP_PATH
=`findExec $PATH $1`
228 if [ ! -n $APP_PATH ];then
229 echo "`fixlen "$1" 9`" "*** not installed ***"
233 echo " CRITICAL ERROR"
234 CRITICALERROR
=`expr $CRITICALERROR + 1`
237 echo " CRITICAL ERROR"
238 CRITICALERROR
=`expr $CRITICALERROR + 1`
251 | \grep ' Version:' \
252 | sed -e 's/.*Version:/Version:/' \
256 VERSION
=`$1 -v 2>&1 \
259 if [ ! "$VERSION" = "$SUPPLIED_VERSION_GCC" ]; then
260 echo "WARNING: gcc version does not match gcc supplied" \
261 "with this release of OpenFOAM"
262 echo " Supplied version: $SUPPLIED_VERSION_GCC"
263 echo " User version : $VERSION"
264 echo " Minimum required: $MIN_VERSION_GCC"
269 VERSION
=`$APP_PATH --version | head -1`
272 VERSION
=`$APP_PATH --version | head -1 | cut -d" " -f4`
277 VERSION
=`$1 --version 2>&1 | grep gzip | cut -d" " -f2`
280 VERSION
=`$1 --version | head -1 | cut -d" " -f2`
285 if [ "$APP_PATH" = "$APP_SPEC" ] ||
[ ! "$2" ]; then
286 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10` `fixlen "$APP_PATH" 58`"
288 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10`"
289 echo "WARNING: Conflicting installations:"
290 echo " OpenFOAM settings : $APP_SPEC"
291 echo " current path : $APP_PATH"
294 echo " CRITICAL ERROR"
295 CRITICALERROR
=`expr $CRITICALERROR + 1`
298 echo " CRITICAL ERROR"
299 CRITICALERROR
=`expr $CRITICALERROR + 1`
314 PINGTEST
=`/usr/sbin/ping $1 2>&1`
315 if [ "`echo $PINGTEST | grep "alive
"`" != "" ] ; then
317 elif [ "`echo $PINGTEST | grep "unknown
host"`" != "" ] ; then
318 RESULT
="No_entry_for_\"$1\"_in_/etc/hosts"
320 RESULT
="Networking_cannot_reach_$1"
324 PINGTEST
=`/bin/ping -w 3 -c 1 $1 2>&1`
325 if [ "`echo $PINGTEST | grep "1 received
"`" != "" ] ; then
327 elif [ "`echo $PINGTEST | grep "unknown
host"`" != "" ] ; then
328 RESULT
="No_entry_for_\"$1\"_in_/etc/hosts"
330 RESULT
="Networking_cannot_reach_$1"
335 echo "`fixlen "Pinging_
$1" 25` `fixlen "$RESULT" 45` `fixlen "$2" 5`"
337 if [ "$2" = "yes" ] && [ "$RESULT" != "Successful" ]; then
338 CRITICALERROR
=`expr $CRITICALERROR + 1`
339 echo "WARNING: CRITICAL ERROR"
346 telnet -e A
$1 $2 <<EOF
354 if [ -x "/usr/bin/telnet" ] ||
[ -x "/bin/telnet" ] ; then
355 RESULT
=`telnetPortTest $1 $2 2>&1 | egrep "onnect.* [t|r]"`
356 if [ "`echo $RESULT | grep 'Connected to'`" ] ; then
358 elif [ "`echo $RESULT | grep 'Connection refused'`" ] ; then
359 RESULT
='Unsuccessful_connection_refused*'
364 RESULT
='No_telnet_running:_cannot_check*'
370 checkTelnetPort
$HOST_NAME 222
371 echo "`fixlen "Test_rsh
:" 25` `fixlen "$RESULT" 45` "yes""
372 if [ "$RESULT" != 'Successful' ]; then
373 SSHRSHOK
=`expr $SSHRSHOK + 1`
379 checkTelnetPort
$HOST_NAME 22
380 echo "`fixlen "Test_ssh
:" 25` `fixlen "$RESULT" 45` "yes""
381 if [ "$RESULT" != 'Successful' ]; then
382 SSHRSHOK
=`expr $SSHRSHOK + 1`
387 checkOpenFOAMEnvironment
() {
388 if [ ! -d "$WM_PROJECT_INST_DIR" -o ! -d "$WM_THIRD_PARTY_DIR" ]; then
390 echo "FATAL ERROR: OpenFOAM environment not configured."
392 echo " Please refer to the installation section of the README file:"
393 echo " <OpenFOAM installation dir>/OpenFOAM-${FOAM_VERSION}/README"
394 echo " to source the OpenFOAM environment."
404 USER_CONFIG_TYPE
="cshrc"
405 echo "`fixlen "Shell
:" $WIDTH` ${USER_SHELL}"
408 USER_CONFIG_TYPE
="bashrc"
409 echo "`fixlen "Shell
:" $WIDTH` ${USER_SHELL}"
411 *) USER_CONFIG_TYPE
=""
412 echo "`fixlen "Shell
:" $WIDTH` ${USER_SHELL}"
413 echo "FATAL ERROR: Cannot identify the shell you are running."
414 echo " OpenFOAM ${FOAM_VERSION} is compatible with "
415 echo " csh, tcsh, ksh and bash."
417 FATALERROR
=`expr $FATALERROR + 1`;;
423 if [ ! "$HOST_NAME" ]; then
424 echo "`fixlen "Host
:" $WIDTH` ${HOST_NAME}"
425 echo "FATAL ERROR: Cannot stat hostname."
426 echo " Contact your system administrator, "
427 echo " OpenFOAM ${FOAM_VERSION} needs a valid "
428 echo " hostname to function."
430 FATALERROR
=`expr $FATALERROR + 1`
432 echo "`fixlen "Host
:" $WIDTH` ${HOST_NAME}"
438 if [ "$OS" = "Linux" ] ||
[ "$OS" = "LinuxAMD64" ] ||
[ "$OS" = "SunOS" ]; then
439 echo "`fixlen "OS
:" $WIDTH` ${OS} version ${OS_VERSION}"
441 echo "FATAL ERROR: Incompatible operating system \"$OS\"."
442 echo " OpenFOAM ${FOAM_VERSION} is currently "
443 echo " available for Linux and SunOS only."
445 FATALERROR
=`expr $FATALERROR + 1`
450 #==============================================================================
452 #==============================================================================
456 #------------------------------------------------------------------------------
457 heading
"Checking basic setup..."
459 checkOpenFOAMEnvironment
465 #------------------------------------------------------------------------------
466 heading
"Checking main OpenFOAM env variables..."
467 COL1
=`fixlen "Environment_variable" 21`
468 COL2
=`fixlen "Set_to_file_or_directory" 40`
473 echo "$COL1 $COL2 $COL3 $COL5"
475 reportEnv
'$WM_PROJECT_INST_DIR' 'noPath' "yes"
476 reportEnv
'$WM_PROJECT_USER_DIR' 'noPath' "no"
477 reportEnv
'$WM_THIRD_PARTY_DIR' 'noPath' "yes"
480 #------------------------------------------------------------------------------
481 heading
"Checking the OpenFOAM env variables set on the PATH..."
483 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
485 reportEnv
'$WM_PROJECT_DIR' '$PATH' "yes"
487 reportEnv
'$FOAM_APPBIN' '$PATH' "yes"
488 reportEnv
'$FOAM_USER_APPBIN' '$PATH' "no"
489 reportEnv
'$WM_DIR' '$PATH' "yes"
492 #------------------------------------------------------------------------------
493 heading
"Checking the OpenFOAM env variables set on the LD_LIBRARY_PATH..."
495 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
497 reportEnv
'$FOAM_LIBBIN' '$LD_LIBRARY_PATH' "yes"
498 reportEnv
'$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' "no"
499 reportEnv
'$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' "yes"
502 #------------------------------------------------------------------------------
503 heading
"Third party software"
504 COL1
=`fixlen "Software" 9`
505 COL2
=`fixlen "Version" 10`
506 COL3
=`fixlen "Location" 10`
508 echo "$COL1 $COL2 $COL3"
510 reportExecutable gcc
"${WM_COMPILER_DIR}/bin/gcc"
511 reportExecutable
gzip
512 if [ "$OS" = "Linux" ] ; then
515 reportExecutable gtar
517 reportExecutable icoFoam
"${FOAM_APPBIN}/icoFoam"
521 #------------------------------------------------------------------------------
522 heading
"Checking networking..."
523 COL1
=`fixlen "Action" 25`
524 COL2
=`fixlen "Result" 45`
525 COL3
=`fixlen "Crit" 5`
528 echo "$COL1 $COL2 $COL3"
531 pingTest
"$HOST_NAME" "yes"
532 pingTest
"localHost" "yes"
536 if [ $SSHRSHOK -eq 1 ]; then
537 echo "(*) Only one of rsh or ssh is required by the OpenFOAM enviroment."
538 elif [ $SSHRSHOK -gt 1 ]; then
539 echo "FATAL ERROR: No remote shell available."
540 echo " OpenFOAM ${FOAM_VERSION} enviroment requires either ssh and/or rsh."
541 echo " Contact your system administrator."
543 FATALERROR
=`expr $FATALERROR + 1`
548 if [ $FATALERROR -gt 0 ] ; then
549 echo "The system test has evoked $FATALERROR fatal error(s)."
551 echo "Base configuration ok."
554 if [ $CRITICALERROR -gt 0 ]; then
555 echo "The foam installation contains $CRITICALERROR critical error(s)."
557 echo "Critical systems ok."
560 if [ $CRITICALERROR -gt 0 ] ||
[ $FATALERROR -gt 0 ]; then
561 echo "Review the output for warning messages and consult "
562 echo "the installation guide for trouble shooting."
572 #------------------------------------------------------------------------------