BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / bin / tools / foamConfigurePaths
blobcf1093d456fa1c6813fd34cf4a18f56870380191
1 #!/bin/sh
2 #---------------------------------*- sh -*-------------------------------------
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 # foamConfigurePaths
28 # Description
29 # hardcode installation directory
31 #------------------------------------------------------------------------------
32 usage() {
33 exec 1>&2
34 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
35 cat<<USAGE
37 usage: ${0##*/}
38 --foamInstall dir specify installation directory (e.g. /opt)
39 --projectName name specify project name (e.g. openfoam170)
40 --projectVersion ver specify project version (e.g. 1.7.x)
41 --archOption arch specify architecture option (only 32 or 64 applicable)
42 --paraviewInstall dir specify ParaView_DIR (e.g. /opt/paraviewopenfoam380)
44 * hardcode paths to installation
46 USAGE
47 exit 1
51 # Function to do replacement on file. Checks if any replacement has been done.
52 # inlineSed <file> <sedCommand> <description>
53 _inlineSed()
55 [ -f "$1" ] || {
56 echo "Missing file: $1"
57 exit 1
60 backup="temp.$$"
61 cp $1 $backup
62 sed -i -e "$2" $1
64 if cmp $1 $backup > /dev/null 2>&1
65 then
66 echo "Failed: $3 in $1"
67 rm $backup 2>/dev/null
68 exit 1
69 else
70 echo "Okay: $3 in $1"
71 rm $backup 2>/dev/null
74 return 0
78 [ -f etc/bashrc ] || usage "Please run from top-level directory of installation"
80 unset foamInstall projectName projectVersion archOption paraviewInstall
82 # parse options
83 while [ "$#" -gt 0 ]
85 case "$1" in
86 -h | -help | --help)
87 usage
89 -foamInstall | --foamInstall)
90 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
91 foamInstall="$2"
92 # replace foamInstall=...
93 _inlineSed \
94 etc/bashrc \
95 '/^[^#]/s@foamInstall=.*@foamInstall='"$foamInstall@" \
96 "Replacing foamInstall setting by '$foamInstall'"
97 shift 2
99 -projectName | --projectName)
100 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
101 projectName="$2"
102 # replace WM_PROJECT_DIR=...
103 _inlineSed \
104 etc/bashrc \
105 '/^[^#]/s@WM_PROJECT_DIR=.*@WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName@" \
106 "Replacing WM_PROJECT_DIR setting by $projectName"
107 shift 2
109 --projectVersion)
110 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
111 projectVersion="$2"
112 # replace WM_PROJECT_VERSION=...
113 # No checking since might already be set.
114 echo "Replacing WM_PROJECT_VERSION setting by $projectVersion"
115 sed -i \
116 '/^[^#]/s@WM_PROJECT_VERSION=.*@WM_PROJECT_VERSION='"$projectVersion@" \
117 etc/bashrc
118 shift 2
120 -archOption | --archOption)
121 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
122 archOption="$2"
123 # replace WM_ARCH_OPTION=...
124 _inlineSed \
125 etc/bashrc \
126 '/^[^#]/s@WM_ARCH_OPTION=.*@WM_ARCH_OPTION='"$archOption@" \
127 "Replacing WM_ARCH_OPTION setting by '$archOption'"
128 shift 2
130 -paraviewInstall | --paraviewInstall)
131 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
132 paraviewInstall="$2"
133 # replace ParaView_DIR=...
134 _inlineSed \
135 etc/config/paraview.sh \
136 '/^[^#]/s@ParaView_DIR=.*@ParaView_DIR='"$paraviewInstall@" \
137 "Replacing ParaView_DIR setting by '$paraviewInstall'"
138 shift 2
141 usage "unknown option/argument: '$*'"
143 esac
144 done
146 [ -n "$foamInstall" -o -n "$projectName" -o -n "$projectVersion" -o -n "$archOption" -o -n "$paraviewInstall" ] || usage "Please specify at least one configure option"
148 #echo "Replacing WM_PROJECT setting by '$projectName'"
149 #sed -i -e 's@WM_PROJECT=.*@WM_PROJECT='"$projectName@" etc/bashrc
151 # Set WM_MPLIB=SYSTEMOPENMPI always
152 _inlineSed \
153 etc/bashrc \
154 '/^[^#]/s@export WM_MPLIB=.*@export WM_MPLIB=SYSTEMOPENMPI@' \
155 "Replacing WM_MPLIB setting by 'SYSTEMOPENMPI'"
157 ## set foamCompiler=system always
158 #_inlineSed \
159 # etc/bashrc \
160 # '/^[^#]/s@foamCompiler=.*@foamCompiler=system@' \
161 # "Replacing foamCompiler setting by 'system'"
163 #------------------------------------------------------------------------------