BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / bin / foamInstallationTest
blob9d8c1545f23e9780cff8984c3607bb39506ddc8a
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your 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, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamInstallationTest
28 # Description
29 # Checks the machine system, the installation of OpenFOAM, and the user's
30 # personal configuration for running OpenFOAM.
32 #------------------------------------------------------------------------------
34 # Base settings
35 MIN_VERSION_GCC=4.3.2
37 # General
38 WIDTH=20
40 # Global variables
41 fatalError=0
42 criticalError=0
44 # System variables
45 HOST=`uname -n`
46 OSTYPE=`uname -s`
47 USER_NAME=$LOGNAME
48 : ${USER_NAME:=$USER}
50 # which OpenFOAM application to test for the Version
51 foamTestApp=icoFoam
53 #==============================================================================
54 # HELPER FUNCTIONS
55 #==============================================================================
57 hline()
59 echo "-------------------------------------------------------------------------------"
63 heading()
65 echo
66 echo
67 echo "$1"
71 lenBase()
73 echo $1 | tr -d " " | wc -m | tr -d " "
77 length()
79 NOCHAR=`lenBase $1`
80 NOCHAR=`expr $NOCHAR - 1`
81 [ $NOCHAR -ge 0 ] || NOCHAR=0
82 echo $NOCHAR
86 stringLength()
88 echo $1 | wc -m | tr -d " "
92 fixlen()
94 WORD=$1
95 ONELEN=`stringLength $1`
96 LDIFF=`expr $ONELEN - $2`
97 if [ $LDIFF -le 1 ]
98 then
99 while [ $LDIFF -lt 0 ]
101 WORD="$WORD "
102 LDIFF=`expr $LDIFF + 1`
103 done
104 echo "$WORD"
105 else
106 LDIFF=`expr $LDIFF + 4`
107 WORD=`echo "$WORD" | cut -c${LDIFF}-`
108 echo "...${WORD}"
113 reportEnv()
115 EXP_ENV=`eval "echo $1"`
116 EXP_PATH=`eval "echo $2"`
117 CRIT="$3"
118 EXISTS=" no "
119 ON_PATH=""
120 if [ `length $EXP_ENV` -gt 0 ]
121 then
122 case "$OSTYPE" in
123 SunOS)
124 if /usr/bin/test -e $EXP_ENV
125 then
126 EXISTS=" yes "
127 if [ "$2" != noPath ]
128 then
129 ON_PATH=" no "
130 oldIFS=$IFS
131 IFS=':'
132 for e in $EXP_PATH
134 case "$e" in
135 "$EXP_ENV" | "$EXP_ENV/bin" | "$EXP_ENV/lib")
136 ON_PATH="yes "
138 esac
139 done
140 IFS=$oldIFS
141 else
142 CRIT=" $3"
144 else
145 ON_PATH=" "
147 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
150 if [ -e "$EXP_ENV" ]
151 then
152 EXISTS=" yes "
153 if [ "$2" != noPath ]
154 then
155 ON_PATH=" no "
156 oldIFS=$IFS
157 IFS=':'
158 for e in $EXP_PATH
160 case "$e" in
161 "$EXP_ENV" | "$EXP_ENV/bin" | "$EXP_ENV/lib")
162 ON_PATH="yes "
164 esac
165 done
166 IFS=$oldIFS
167 else
168 CRIT=" $3"
170 else
171 ON_PATH=" "
173 echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
175 esac
176 else
177 echo "`fixlen "$1" 21` --------- env variable not set --------- $3"
180 ERROR="false"
181 if [ "$EXISTS" = no ] || [ "$ON_PATH" = no ]
182 then
183 ERROR="true"
185 if [ "$3" = yes ] && [ "$ERROR" = true ]
186 then
187 criticalError=`expr $criticalError + 1`
188 echo "WARNING: CRITICAL ERROR"
189 echo
195 findExec()
197 oldIFS=$IFS
198 IFS=':'
199 for d in $1
201 case "$OSTYPE" in
202 SunOS)
203 if /usr/bin/test ! -d "$d/$2" -a -x "$d/$2"
204 then
205 IFS=$oldIFS
206 echo "$d/$2"
207 return 0
211 if [ ! -d "$d/$2" -a -x "$d/$2" ]
212 then
213 IFS=$oldIFS
214 echo "$d/$2"
215 return 0
218 esac
219 done
220 IFS=$oldIFS
221 return 1
225 reportExecutable()
227 APP_PATH=""
228 APP_PATH=`findExec $PATH $1`
229 APP_SPEC="$2"
230 if [ ! -n $APP_PATH ]
231 then
232 echo "`fixlen "$1" 9`" "*** not installed ***"
233 VERSION=""
234 case "$1" in
235 gcc | $foamTestApp)
236 echo " CRITICAL ERROR"
237 criticalError=`expr $criticalError + 1`
239 esac
240 echo
241 return 1
243 case "$1" in
244 $foamTestApp)
245 VERSION=`$1 -case /dev/null 2>&1 \
246 | sed -ne 's/^.*Version: *\([^ ][^ ]*\).*/\1/p'`
248 flex)
249 VERSION=`$1 --version /dev/null 2>&1 \
250 | sed -ne 's/flex \([0-9][0-9.]*\).*/\1/p' `
252 gcc)
253 VERSION=`$1 -v 2>&1 \
254 | sed -ne 's/^gcc version \([0-9][0-9.]*\).*/\1/p' `
256 MINV1=`echo $MIN_VERSION_GCC | cut -d. -f1`
257 MINV2=`echo $MIN_VERSION_GCC | cut -d. -f2`
258 MINV3=`echo $MIN_VERSION_GCC | cut -d. -f3`
260 V1=`echo $VERSION | cut -d. -f1`
261 V2=`echo $VERSION | cut -d. -f2`
262 V3=`echo $VERSION | cut -d. -f3`
265 gccOK=""
266 pass=""
267 if [ $V1 -lt $MINV1 ]; then
268 gccOk="ERROR"
269 elif [ $V1 -gt $MINV1 ]; then
270 pass="yes"
273 if [ "$pass" = "" ] && [ "$gccOk" = "" ]; then
274 if [ $V2 -lt $MINV2 ]; then
275 gccOk="ERROR"
276 elif [ $V2 -gt $MINV2 ]; then
277 pass="yes"
281 if [ "$pass" = "" ] && [ "$gccOk" = "" ] && [ $V3 != "" ] && [ $MINV3 != "" ]; then
282 if [ $V3 -lt $MINV3 ]; then
283 gccOk="ERROR"
287 if [ "$gccOk" != "" ]; then
288 echo "ERROR: gcc version is too old for this release of OpenFOAM"
289 echo " User version : $VERSION"
290 echo " Minimum required: $MIN_VERSION_GCC"
291 echo ""
292 fatalError=`expr $fatalError + 1`
297 gtar)
298 VERSION=`$APP_PATH --version | head -1`
300 tar)
301 VERSION=`$APP_PATH --version | head -1 | cut -d" " -f4`
303 gzip)
304 case "$OSTYPE" in
305 SunOS)
306 VERSION=`$1 --version 2>&1 | grep gzip | cut -d" " -f2`
309 VERSION=`$1 --version | head -1 | cut -d" " -f2`
311 esac
313 esac
314 if [ "$APP_PATH" = "$APP_SPEC" ] || [ ! "$2" ]
315 then
316 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10` `fixlen "$APP_PATH" 58`"
317 else
318 echo "`fixlen "$1" 9` `fixlen "$VERSION" 10`"
319 echo "WARNING: Conflicting installations:"
320 echo " OpenFOAM settings : $APP_SPEC"
321 echo " current path : $APP_PATH"
322 case "$1" in
323 gcc | $foamTestApp)
324 echo " CRITICAL ERROR"
325 criticalError=`expr $criticalError + 1`
327 esac
328 echo ""
333 checkOpenFOAMEnvironment()
335 [ -d "$WM_PROJECT_INST_DIR" ] && [ -d "$WM_THIRD_PARTY_DIR" ] || {
336 echo ""
337 echo "FATAL ERROR: OpenFOAM environment not configured."
338 echo ""
339 echo " Please refer to the installation section of the README file:"
340 echo " <OpenFOAM installation dir>/OpenFOAM-${WM_PROJECT_VERSION}/README"
341 echo " to source the OpenFOAM environment."
342 echo ""
343 exit 1
348 checkUserShell()
350 echo "`fixlen Shell: $WIDTH` ${SHELL##*/}"
351 case $SHELL in
352 */csh | */tcsh | */bash | */ksh)
355 echo "FATAL ERROR: Cannot identify the shell you are running."
356 echo " OpenFOAM ${WM_PROJECT_VERSION} is compatible with "
357 echo " csh, tcsh, ksh and bash."
358 echo
359 fatalError=`expr $fatalError + 1`
361 esac
365 checkHostName()
367 echo "`fixlen Host: $WIDTH` $HOST"
368 if [ ! "$HOST" ]
369 then
370 echo "FATAL ERROR: Cannot stat hostname."
371 echo " Contact your system administrator, "
372 echo " OpenFOAM ${WM_PROJECT_VERSION} needs a valid "
373 echo " hostname to function."
374 echo
375 fatalError=`expr $fatalError + 1`
380 checkOS()
382 case "$OSTYPE" in
383 Linux | LinuxAMD64 | SunOS )
384 echo "`fixlen OS: $WIDTH` $OSTYPE version $(uname -r)"
387 echo "FATAL ERROR: Incompatible operating system \"$OSTYPE\"."
388 echo " OpenFOAM ${FWM_PROJECT_VERSION} is currently "
389 echo " available for Linux and SunOS only."
390 echo
391 fatalError=`expr $fatalError + 1`
393 esac
397 #==============================================================================
398 # MAIN SCRIPT
399 #==============================================================================
401 echo "Executing $0:"
403 #------------------------------------------------------------------------------
404 heading "Checking basic setup..."
405 hline
406 checkOpenFOAMEnvironment
407 checkUserShell
408 checkHostName
409 checkOS
410 hline
412 #------------------------------------------------------------------------------
413 heading "Checking main OpenFOAM env variables..."
414 COL1=`fixlen Environment_variable 21`
415 COL2=`fixlen Set_to_file_or_directory 40`
416 COL3="Valid"
417 COL4="Path"
418 COL5="Crit"
419 hline
420 echo "$COL1 $COL2 $COL3 $COL5"
421 hline
422 reportEnv '$WM_PROJECT_INST_DIR' 'noPath' "yes"
423 reportEnv '$WM_PROJECT_USER_DIR' 'noPath' "no"
424 reportEnv '$WM_THIRD_PARTY_DIR' 'noPath' "yes"
425 hline
427 #------------------------------------------------------------------------------
428 heading "Checking the OpenFOAM env variables set on the PATH..."
429 hline
430 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
431 hline
432 reportEnv '$WM_PROJECT_DIR' '$PATH' "yes"
433 echo ""
434 reportEnv '$FOAM_APPBIN' '$PATH' "yes"
435 reportEnv '$FOAM_SITE_APPBIN' '$PATH' "no"
436 reportEnv '$FOAM_USER_APPBIN' '$PATH' "no"
437 reportEnv '$WM_DIR' '$PATH' "yes"
438 hline
440 #------------------------------------------------------------------------------
441 heading "Checking the OpenFOAM env variables set on the LD_LIBRARY_PATH..."
442 hline
443 echo "$COL1 $COL2 $COL3 $COL4 $COL5"
444 hline
445 reportEnv '$FOAM_LIBBIN' '$LD_LIBRARY_PATH' "yes"
446 reportEnv '$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' "no"
447 reportEnv '$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' "no"
448 reportEnv '$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' "yes"
449 hline
451 #------------------------------------------------------------------------------
452 heading "Third party software"
453 COL1=`fixlen Software 9`
454 COL2=`fixlen Version 10`
455 COL3=`fixlen Location 10`
456 hline
457 echo "$COL1 $COL2 $COL3"
458 hline
459 reportExecutable flex
460 reportExecutable gcc
461 reportExecutable gzip
462 if [ "$OSTYPE" = Linux ]
463 then
464 reportExecutable tar
465 else
466 reportExecutable gtar
468 reportExecutable $foamTestApp "$FOAM_APPBIN/$foamTestApp"
470 hline
472 #------------------------------------------------------------------------------
473 heading "Summary"
474 hline
476 if [ $fatalError -gt 0 ]
477 then
478 echo "The system test has evoked $fatalError fatal error(s)."
479 else
480 echo "Base configuration ok."
482 if [ $criticalError -gt 0 ]
483 then
484 echo "The foam installation contains $criticalError critical error(s)."
485 else
486 echo "Critical systems ok."
488 if [ $criticalError -gt 0 ] || [ $fatalError -gt 0 ]
489 then
490 echo
491 echo "Review the output for warning messages and consult"
492 echo "the installation guide for troubleshooting."
495 echo
496 echo Done
497 echo
499 exit 0
501 #------------------------------------------------------------------------------