forked from C2SM-RCM/buildenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.castor.sh
239 lines (216 loc) · 6.84 KB
/
env.castor.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
# This script contains functions for setting up machine specific compile
# environments for the dycore and the Fortran parts. Namely, the following
# functions must be defined in this file:
#
# setupDefaults setup global default options for this platform
# setCppEnvironment setup environment for dycore compilation
# unsetCppEnvironment restore environment after dycore compilation
# setFortranEnvironment setup environment for Fortran compilation
# unsetFortranEnvironment restore environment after Fortran compilation
# Setup global defaults and variables
#
# upon exit, the following global variables need to be set:
# targets list of possible targets (e.g. gpu, cpu)
# compilers list of possible compilers for Fortran parts
# target default target
# compiler default compiler to use for Fortran parts
# debug build in debugging mode (yes/no)
# cleanup clean before build (yes/no)
# cuda_arch CUDA architecture version to use (e.g. sm_35, use blank for CPU target)
#
setupDefaults()
{
# available options
targets=(cpu gpu)
compilers=(gnu pgi)
fcompiler_cmds=(mpif90)
# default options
if [ -z "${target}" ] ; then
target="gpu"
fi
if [ -z "${compiler}" ] ; then
compiler="pgi"
fi
if [ -z "${cuda_arch}" ] ; then
cuda_arch="sm_20"
fi
# fortran compiler command
if [ -z "${fcompiler_cmd}" ] ; then
fcompiler_cmd="mpif90"
fi
}
# This function loads modules and sets up variables for compiling in C++
#
# upon entry, the following global variables need to be set:
# compiler Compiler to use to compile the Fortran parts of the code
#
# upon exit, the following global variables need to be set:
# old_prgenv Default PrgEnv-XXX module loaded on Cray machines
# dycore_gpp C++ compiler for dycore
# dycore_gcc C compiler for dycore
# cuda_gpp C++ used by nvcc as backend
# boost_path path to the Boost installation to use
# use_mpi_compiler use MPI compiler wrappers?
# mpi_path path to the MPI installation to use
#
setCppEnvironment()
{
# switch to programming environment (only on Cray)
old_prgenv=" "
#old_prgenv=`module list -t 2>&1 | grep 'PrgEnv-'`
#if [ -z "${old_prgenv}" ] ; then
# module load PrgEnv-gnu
#else
# module swap ${old_prgenv} PrgEnv-gnu
#fi
# standard modules (part 1)
module load cmake
# Fortran compiler specific modules and setup
case "${compiler}" in
pgi )
module load mvapich2/1.9-pgi
module load gcc/4.8.1
;;
gnu )
module load mvapich2/1.9-gcc-4.8.1
module load gcc/4.8.1
;;
* )
echo "ERROR: Unsupported compiler encountered in setCppEnvironment" 1>&2
exit 1
esac
# standard modules (part 2)
module load boost
module load cuda/5.5
# set global variables
if [ "${compiler}" == "gnu" ] ; then
dycore_openmp=ON # OpenMP only works if GNU is also used for Fortran parts
else
dycore_openmp=OFF # Otherwise, switch off
fi
dycore_gpp='g++'
dycore_gcc='gcc'
cuda_gpp='g++'
boost_path=/apps/castor/boost_1_54_0/
use_mpi_compiler=ON
mpi_path=${MPI_ROOT}
}
# This function unloads modules and removes variables for compiling in C++
#
# upon entry, the following global variables need to be set:
# compiler Compiler to use to compile the Fortran parts of the code
# old_prgenv Default PrgEnv-XXX module loaded on Cray machines
#
unsetCppEnvironment()
{
# remove standard modules (part 2)
module unload cuda
module unload boost
# remove Fortran compiler specific modules
case "${compiler}" in
pgi )
module unload gcc/4.8.1
module unload mvapich2/1.9-pgi
;;
gnu )
module unload gcc/4.8.1
module unload mvapich2/1.9-gcc-4.8.1
;;
* )
echo "ERROR: Unsupported compiler encountered in unsetCppEnvironment" 1>&2
exit 1
esac
# remove standard modules (part 1)
module unload cmake
## restore programming environment (only on Cray)
#if [ -z "${old_prgenv}" ] ; then
# module unload PrgEnv-gnu
#else
# module swap PrgEnv-gnu ${old_prgenv}
#fi
unset old_prgenv
# unset global variables
unset dycore_openmp
unset dycore_gpp
unset dycore_gcc
unset cuda_gpp
unset boost_path
unset use_mpi_compiler
unset mpi_path
}
# This function loads modules and sets up variables for compiling the Fortran part
#
# upon entry, the following global variables need to be set:
# compiler Compiler to use to compile the Fortran part of the code
#
# upon exit, the following global variables need to be set:
# old_prgenv Default PrgEnv-XXX module loaded on Cray machines
#
setFortranEnvironment()
{
# switch to GNU programming environment (only on Cray machines)
old_prgenv=" "
#old_prgenv=`module list -t 2>&1 | grep 'PrgEnv-'`
#if [ -z "${old_prgenv}" ] ; then
# module load PrgEnv-${compiler}
#else
# module swap ${old_prgenv} PrgEnv-${compiler}
#fi
# standard modules (part 1)
module load cmake
# compiler specific modules
case "${compiler}" in
pgi )
module load mvapich2/1.9-pgi
module load pgi/14.10
module load netcdf/4.2.1.1-pgi
;;
gnu )
module load mvapich2/1.9-gcc-4.8.1
module load gcc/4.8.1
module load netcdf/4.1.3-gcc
;;
* )
echo "ERROR: Unsupported compiler encountered in setFortranEnvironment" 1>&2
exit 1
esac
# standard modules (part 2)
module load cuda/5.5
}
# This function unloads modules and removes variables for compiling the Fortran parts
#
# upon entry, the following global variables need to be set:
# compiler Compiler to use to compile the Fortran parts of the code
# old_prgenv Default PrgEnv-XXX module loaded on Cray machines
#
unsetFortranEnvironment()
{
# remove standard modules (part 2)
module unload cuda
# remove compiler specific modules
case "${compiler}" in
pgi )
module unload netcdf/4.2.1.1-pgi
module unload pgi/14.10
module unload mvapich2/1.9-pgi
;;
gnu )
module unload netcdf/4.1.3-gcc
module unload gcc/4.8.1
module unload mvapich2/1.9-gcc-4.8.1
;;
* )
echo "ERROR: Unsupported compiler encountered in unsetFortranEnvironment" 1>&2
exit 1
esac
# remove standard modules (part 1)
module unload cmake
# swap back to original programming environment (only on Cray machines)
#if [ -z "${old_prgenv}" ] ; then
# module unload PrgEnv-${compiler}
#else
# module swap PrgEnv-${compiler} ${old_prgenv}
#fi
unset old_prgenv
}