intersection with triangle plane for miss
[OpenFOAM-1.5.x.git] / bin / foamInstallationTest
blobe7d8a6eaaed6f44c38c6d393ff70f45041c61cd2
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
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
20 # for more details.
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
26 # Script
27 # foamInstallationTest
29 # Description
30 # Checks the machine system, the installation of OpenFOAM, and the user's
31 # personal configuration for running OpenFOAM.
33 #------------------------------------------------------------------------------
35 # Base settings
36 FOAM_VERSION=1.5
37 SUPPLIED_VERSION_GCC=4.3.1
38 MIN_VERSION_GCC=4.2.0
40 # General
41 WIDTH=20
43 # Global variables
44 FATALERROR=0
45 CRITICALERROR=0
46 SSHRSHOK=0
48 # System variables
49 USER_SHELL=`basename $SHELL`
50 HOST_NAME=`uname -n`
51 OS=`uname -s`
52 OS_VERSION=`uname -r`
53 USER_NAME=$LOGNAME
54 if [ ! -n $USER_NAME ]; then
55 USER_NAME=$USER
58 #==============================================================================
59 # HELPER FUNCTIONS
60 #==============================================================================
62 hline () {
63 echo "-------------------------------------------------------------------------------"
67 expenv () {
68 eval "echo $1"
72 heading () {
73 echo ""
74 echo ""
75 echo "$1"
79 lenBase () {
80 echo $1 | tr -d " " | wc -m | tr -d " "
84 length () {
85 NOCHAR=`lenBase $1`
86 NOCHAR=`expr $NOCHAR - 1`
87 if [ $NOCHAR -eq -1 ]; then
88 NOCHAR=0
90 echo $NOCHAR
94 stringLength () {
95 echo $1 | wc -m | tr -d " "
99 fixlen () {
100 WORD=$1
101 ONELEN=`stringLength $1`
102 LDIFF=`expr $ONELEN - $2`
103 if [ $LDIFF -le 1 ]; then
104 while [ $LDIFF -lt 0 ] ; do
105 WORD="$WORD "
106 LDIFF=`expr $LDIFF + 1`
107 done
108 echo "$WORD"
109 else
110 LDIFF=`expr $LDIFF + 4`
111 WORD=`echo "$WORD" | cut -c${LDIFF}-`
112 echo "...${WORD}"
117 reportEnv () {
118 EXP_ENV=`eval "echo $1"`
119 EXP_PATH=`eval "echo $2"`
120 CRIT="$3"
121 EXISTS=" no "
122 ON_PATH=""
123 if [ `length $EXP_ENV` -gt 0 ] ; then
124 case $OS in
125 SunOS)
126 if /usr/bin/test -e $EXP_ENV ; then
127 EXISTS=" yes "
128 if [ "$2" != "noPath" ]; then
129 ON_PATH=" no "
130 OLD_IFS=$IFS
131 IFS=':'
132 for e in $EXP_PATH
134 if \
136 "$e" = "$EXP_ENV" \
137 -o "$e" = "${EXP_ENV}/bin" \
138 -o "${EXP_ENV}/lib" = "$e" \
139 ] ; then
140 ON_PATH="yes "
142 done
143 IFS=$OLD_IFS
144 else
145 CRIT=" $3"
147 else
148 ON_PATH=" "
150 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
153 if [ -e "$EXP_ENV" ] ; then
154 EXISTS=" yes "
155 if [ "$2" != "noPath" ]; then
156 ON_PATH=" no "
157 OLD_IFS=$IFS
158 IFS=':'
159 for e in $EXP_PATH
161 if \
163 "$e" = "$EXP_ENV" \
164 -o "$e" = "${EXP_ENV}/bin" \
165 -o "${EXP_ENV}/lib" = "$e" \
166 ] ; then
167 ON_PATH="yes "
169 done
170 IFS=$OLD_IFS
171 else
172 CRIT=" $3"
174 else
175 ON_PATH=" "
177 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
179 esac
180 else
181 echo "`fixlen "$1" 21` --------- env variable not set --------- $3"
184 ERROR="false"
185 if [ "$EXISTS" = "no" ] || [ "$ON_PATH" = "no" ]; then
186 ERROR="true"
188 if [ "$3" = "yes" ] && [ "$ERROR" = "true" ]; then
189 CRITICALERROR=`expr $CRITICALERROR + 1`
190 echo "WARNING: CRITICAL ERROR"
191 echo
197 findExec() {
198 OLD_IFS=$IFS
199 IFS=':'
200 for d in $1
202 case $OS in
203 SunOS)
204 if /usr/bin/test ! -d "$d/$2" -a -x "$d/$2" ; then
205 IFS=$OLD_IFS
206 echo "$d/$2"
207 return 0
211 if [ ! -d "$d/$2" -a -x "$d/$2" ]; then
212 IFS=$OLD_IFS
213 echo "$d/$2"
214 return 0
217 esac
218 done
219 IFS=$OLD_IFS
220 return 1
224 reportExecutable () {
225 APP_PATH=""
226 APP_PATH=`findExec $PATH $1`
227 APP_SPEC="$2"
228 if [ ! -n $APP_PATH ];then
229 echo "`fixlen "$1" 9`" "*** not installed ***"
230 VERSION=""
231 case $1 in
232 icoFoam)
233 echo " CRITICAL ERROR"
234 CRITICALERROR=`expr $CRITICALERROR + 1`
236 gcc)
237 echo " CRITICAL ERROR"
238 CRITICALERROR=`expr $CRITICALERROR + 1`
240 tar) ;;
241 gtar) ;;
242 gzip) ;;
243 dx) ;;
244 esac
245 echo
246 return 1
248 case $1 in
249 icoFoam)
250 VERSION=`$1 2>&1 \
251 | \grep ' Version:' \
252 | sed -e 's/.*Version:/Version:/' \
253 | cut -d" " -f3`
255 gcc)
256 VERSION=`$1 -v 2>&1 \
257 | grep 'version' \
258 | cut -d" " -f3`
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"
265 echo ""
268 gtar)
269 VERSION=`$APP_PATH --version | head -1`
271 tar)
272 VERSION=`$APP_PATH --version | head -1 | cut -d" " -f4`
274 gzip)
275 case $OS in
276 SunOS)
277 VERSION=`$1 --version 2>&1 | grep gzip | cut -d" " -f2`
280 VERSION=`$1 --version | head -1 | cut -d" " -f2`
282 esac
284 esac
285 if [ "$APP_PATH" = "$APP_SPEC" ] || [ ! "$2" ]; then
286 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10` `fixlen "$APP_PATH" 58`"
287 else
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"
292 case $1 in
293 icoFoam)
294 echo " CRITICAL ERROR"
295 CRITICALERROR=`expr $CRITICALERROR + 1`
297 gcc)
298 echo " CRITICAL ERROR"
299 CRITICALERROR=`expr $CRITICALERROR + 1`
301 gtar) ;;
302 gzip) ;;
303 dx) ;;
304 esac
305 echo ""
310 pingTest () {
311 RESULT=""
312 case $OS in
313 SunOS)
314 PINGTEST=`/usr/sbin/ping $1 2>&1`
315 if [ "`echo $PINGTEST | grep "alive"`" != "" ] ; then
316 RESULT="Successful"
317 elif [ "`echo $PINGTEST | grep "unknown host"`" != "" ] ; then
318 RESULT="No_entry_for_\"$1\"_in_/etc/hosts"
319 else
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
326 RESULT="Successful"
327 elif [ "`echo $PINGTEST | grep "unknown host"`" != "" ] ; then
328 RESULT="No_entry_for_\"$1\"_in_/etc/hosts"
329 else
330 RESULT="Networking_cannot_reach_$1"
333 esac
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"
340 echo
345 telnetPortTest () {
346 telnet -e A $1 $2 <<EOF
348 quit
353 checkTelnetPort () {
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
357 RESULT='Successful'
358 elif [ "`echo $RESULT | grep 'Connection refused'`" ] ; then
359 RESULT='Unsuccessful_connection_refused*'
360 else
361 RESULT="Not_active*"
363 else
364 RESULT='No_telnet_running:_cannot_check*'
369 checkRsh () {
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`
378 checkSsh () {
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
389 echo ""
390 echo "FATAL ERROR: OpenFOAM environment not configured."
391 echo ""
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."
395 echo ""
396 exit 1
401 checkUserShell() {
402 case $USER_SHELL in
403 csh | tcsh)
404 USER_CONFIG_TYPE="cshrc"
405 echo "`fixlen "Shell:" $WIDTH` ${USER_SHELL}"
407 bash | ksh)
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."
416 echo
417 FATALERROR=`expr $FATALERROR + 1`;;
418 esac
422 checkHostName() {
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."
429 echo
430 FATALERROR=`expr $FATALERROR + 1`
431 else
432 echo "`fixlen "Host:" $WIDTH` ${HOST_NAME}"
437 checkOS () {
438 if [ "$OS" = "Linux" ] || [ "$OS" = "LinuxAMD64" ] || [ "$OS" = "SunOS" ]; then
439 echo "`fixlen "OS:" $WIDTH` ${OS} version ${OS_VERSION}"
440 else
441 echo "FATAL ERROR: Incompatible operating system \"$OS\"."
442 echo " OpenFOAM ${FOAM_VERSION} is currently "
443 echo " available for Linux and SunOS only."
444 echo
445 FATALERROR=`expr $FATALERROR + 1`
450 #==============================================================================
451 # MAIN SCRIPT
452 #==============================================================================
454 echo "Executing $0:"
456 #------------------------------------------------------------------------------
457 heading "Checking basic setup..."
458 hline
459 checkOpenFOAMEnvironment
460 checkUserShell
461 checkHostName
462 checkOS
463 hline
465 #------------------------------------------------------------------------------
466 heading "Checking main OpenFOAM env variables..."
467 COL1=`fixlen "Environment_variable" 21`
468 COL2=`fixlen "Set_to_file_or_directory" 40`
469 COL3="Valid"
470 COL4="Path"
471 COL5="Crit"
472 hline
473 echo "$COL1 $COL2 $COL3 $COL5"
474 hline
475 reportEnv '$WM_PROJECT_INST_DIR' 'noPath' "yes"
476 reportEnv '$WM_PROJECT_USER_DIR' 'noPath' "no"
477 reportEnv '$WM_THIRD_PARTY_DIR' 'noPath' "yes"
478 hline
480 #------------------------------------------------------------------------------
481 heading "Checking the OpenFOAM env variables set on the PATH..."
482 hline
483 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
484 hline
485 reportEnv '$WM_PROJECT_DIR' '$PATH' "yes"
486 echo ""
487 reportEnv '$FOAM_APPBIN' '$PATH' "yes"
488 reportEnv '$FOAM_USER_APPBIN' '$PATH' "no"
489 reportEnv '$WM_DIR' '$PATH' "yes"
490 hline
492 #------------------------------------------------------------------------------
493 heading "Checking the OpenFOAM env variables set on the LD_LIBRARY_PATH..."
494 hline
495 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
496 hline
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"
500 hline
502 #------------------------------------------------------------------------------
503 heading "Third party software"
504 COL1=`fixlen "Software" 9`
505 COL2=`fixlen "Version" 10`
506 COL3=`fixlen "Location" 10`
507 hline
508 echo "$COL1 $COL2 $COL3"
509 hline
510 reportExecutable gcc "${WM_COMPILER_DIR}/bin/gcc"
511 reportExecutable gzip
512 if [ "$OS" = "Linux" ] ; then
513 reportExecutable tar
514 else
515 reportExecutable gtar
517 reportExecutable icoFoam "${FOAM_APPBIN}/icoFoam"
519 hline
521 #------------------------------------------------------------------------------
522 heading "Checking networking..."
523 COL1=`fixlen "Action" 25`
524 COL2=`fixlen "Result" 45`
525 COL3=`fixlen "Crit" 5`
527 hline
528 echo "$COL1 $COL2 $COL3"
529 hline
531 pingTest "$HOST_NAME" "yes"
532 pingTest "localHost" "yes"
533 checkRsh
534 checkSsh
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."
542 echo ""
543 FATALERROR=`expr $FATALERROR + 1`
545 echo ""
546 hline
547 echo ""
548 if [ $FATALERROR -gt 0 ] ; then
549 echo "The system test has evoked $FATALERROR fatal error(s)."
550 else
551 echo "Base configuration ok."
553 echo ""
554 if [ $CRITICALERROR -gt 0 ]; then
555 echo "The foam installation contains $CRITICALERROR critical error(s)."
556 else
557 echo "Critical systems ok."
559 echo ""
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."
564 echo ""
566 echo "done."
568 echo ""
570 exit 0
572 #------------------------------------------------------------------------------