32
32
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
33
# POSSIBILITY OF SUCH DAMAGE.
34
34
35
+ # This file is organized into three sections:
36
+ # 1. Command-line argument processor.
37
+ # 2. Function definitions.
38
+ # 3. Main body.
39
+ # The script depends on several external programs, including a second script that
40
+ # builds prerequisite software. Building prerequisites requires network access
41
+ # unless tar balls of the prerequisites are present.
42
+
43
+ # ___________________ Process command-line arguments ___________________
44
+
35
45
this_script=` basename $0 `
36
46
47
+ # Interpret the first command-line argument, if present, as the OpenCoarrays installation path.
48
+ # Otherwise, install in a subdirectory of the present working directory.
49
+ if [[ -z $1 ]]; then
50
+ install_path=${PWD} /opencoarrays-installation
51
+ else
52
+ install_path=$1
53
+ fi
54
+
55
+
56
+ # Interpret the second command-line argument, if present, as the number of threads for 'make'.
57
+ # Otherwise, default to single-threaded 'make'.
58
+ if [[ -z $2 ]]; then
59
+ num_threads=1
60
+ else
61
+ num_threads=$2
62
+ fi
63
+
64
+ # ___________________ Define functions for use in the main body ___________________
65
+
37
66
usage ()
38
67
{
39
68
echo " "
@@ -55,25 +84,6 @@ usage()
55
84
exit 1
56
85
}
57
86
58
- # Interpret the first command-line argument, if present, as the installation path.
59
- # Otherwise, install in a subdirectory of the present working directory.
60
- default_install_path=${PWD} /opencoarrays-installation
61
- if [[ -z $1 ]]; then
62
- install_path=$default_install_path
63
- else
64
- install_path=$1
65
- fi
66
-
67
- build_path=${PWD} /opencorrays-build
68
-
69
- # Interpret the second command-line argument, if present, as the number of threads for 'make'.
70
- # Otherwise, default to single-threaded 'make'.
71
- if [[ -z $2 ]]; then
72
- num_threads=1
73
- else
74
- num_threads=$2
75
- fi
76
-
77
87
find_or_install ()
78
88
{
79
89
package=$1
@@ -153,7 +163,12 @@ find_or_install()
153
163
if [[ $proceed == " y" ]]; then
154
164
printf " Downloading, building, and installing $package \n"
155
165
cd install_prerequisites &&
156
- FC=gfortran CC=gcc CXX=g++ ./build $package &&
166
+ if [[ $package == " gcc" ]]; then
167
+ FC=gfortran CC=gcc CXX=g++ ./build flex --default $num_threads
168
+ flex_install_path=` ./build flex --default --query` &&
169
+ PATH=$flex_install_path /bin:$PATH
170
+ fi
171
+ FC=gfortran CC=gcc CXX=g++ ./build $package --default $num_threads &&
157
172
package_install_path=` ./build $package --default --query` &&
158
173
if [[ -f $package_install_path /bin/$executable ]]; then
159
174
printf " Installation successful."
@@ -165,9 +180,8 @@ find_or_install()
165
180
elif [[ $package == " mpich" ]]; then
166
181
MPICC=$package_install_path /bin/mpicc
167
182
MPIFC=$package_install_path /bin/mpif90
168
- else
169
- PATH=$package_install_path /bin:$PATH
170
183
fi
184
+ PATH=$package_install_path /bin:$PATH
171
185
return
172
186
else
173
187
printf " Installation unsuccessful."
@@ -182,7 +196,7 @@ find_or_install()
182
196
exit 1
183
197
}
184
198
185
- # ##### Main Body ##########
199
+ # ___________________ Define functions for use in the main body ___________________
186
200
187
201
if [[ $1 == ' --help' || $1 == ' -h' ]]; then
188
202
# Print usage information if script is invoked with --help or -h argument
@@ -201,23 +215,25 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
201
215
echo " "
202
216
else
203
217
218
+
204
219
# Find or install prerequisites and install OpenCoarrays
220
+ build_path=${PWD} /opencoarrays-build
205
221
installation_record=install-opencoarrays.log
206
222
time \
207
223
{
208
- # Find or install GCC first to ensure we build MPICH with an acceptable version of GCC
209
- find_or_install gcc &&
210
- find_or_install mpich &&
211
- find_or_install cmake &&
212
- mkdir -p opencoarrays-build &&
213
- cd opencoarrays-build &&
224
+ # Building OpenCoarrays with CMake requires MPICH and GCC; MPICH requires GCC.
225
+ find_or_install gcc &&
226
+ find_or_install mpich &&
227
+ find_or_install cmake &&
228
+ mkdir -p $build_path &&
229
+ cd $build_path &&
214
230
if [[ -z $MPICC || -z $MPIFC ]]; then
215
231
echo " Empty MPICC=$MPICC or MPIFC=$MPIFC "
216
232
exit 1
217
233
else
218
234
CC=$MPICC FC=$MPIFC cmake .. -DCMAKE_INSTALL_PREFIX=$install_path &&
219
- make &&
220
- make install &&
235
+ make -j $num_threads &&
236
+ make install &&
221
237
make clean
222
238
fi
223
239
} >&1 | tee $installation_record
0 commit comments