-
Notifications
You must be signed in to change notification settings - Fork 50
/
configure.sh
executable file
·325 lines (300 loc) · 10.9 KB
/
configure.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#!/bin/bash
#################################################################################
## ##
## c o n f i g u r e . s h ##
## ##
## configure script to copy appropriate Makefile.$osname ##
## ##
## Usage: configure.sh [-h] [-v] [-l] [-prefix dir] [-debug] [-check] ##
## [-nompi] [-noerror] [-Dmacro[=value] ...] ##
## ##
## (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file ##
## authors, and contributors see AUTHORS file ##
## This file is part of LPJmL and licensed under GNU AGPL Version 3 ##
## or later. See LICENSE file or go to http://www.gnu.org/licenses/ ##
## Contact: https://github.com/PIK-LPJmL/LPJmL ##
#################################################################################
USAGE="Usage: $0 [-h] [-v] [-l] [-prefix dir] [-debug] [-nompi] [-check] [-noerror] [-Dmacro[=value] ...]"
debug=0
nompi=0
prefix=$PWD
macro=""
warning="-Werror"
while(( "$#" )); do
case "$1" in
-h|--help)
echo $0 - configure LPJmL $(cat VERSION)
echo
echo $USAGE
echo
echo Arguments:
echo "-h,--help print this help text"
echo "-v,--version print version"
echo "-l,--license print license"
echo "-prefix dir set installation directory for LPJmL. Default is current directory"
echo "-debug set debug flags and disable optimization"
echo "-check set debug flags, enable pointer checking and disable optimization"
echo "-noerror do not stop compilation on warnings"
echo "-nompi do not build MPI version"
echo "-Dmacro[=value] define macro for compilation"
echo
echo After successfull completion of $0 LPJmL can be compiled by make all
echo Invoke make clean after change in configuration
echo -e "\nSee LICENSE file or invoke $0 -l to print license"
echo -e "\n(C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file"
exit 0
;;
-l|--license)
more LICENSE
exit 0
;;
-v|--version)
cat VERSION
exit 0
;;
-prefix)
if [ $# -lt 2 ]
then
echo >&2 Error: prefix directory missing
echo >&2 $USAGE
exit 1
fi
prefix=$2
shift 2
;;
-debug)
debug=1
shift 1
;;
-check)
debug=2
shift 1
;;
-noerror)
warning=""
shift 1
;;
-nompi)
nompi=1
shift 1
;;
-D*)
macro="$macro $1"
shift 1
;;
-*)
echo >&2 Invalid option $1
echo >&2 $USAGE
exit 1
;;
*)
echo >&2 Invalid argument $1
echo >&2 $USAGE
exit 1
;;
esac
done
echo Configuring LPJmL $(cat VERSION)...
osname=$(uname)
if test -d /p ;
then
inpath=/p/projects/lpjml/input/historical
else
inpath=""
echo >&2 No input directory found, LPJINPATH has to be set
fi
if [ "$osname" = "Linux" ] || [ "$osname" = "CYGWIN_NT-5.1" ]
then
echo Operating system is $osname
if [ "$nompi" = "1" ]
then
if which icx >/dev/null 2>/dev/null ;
then
cp config/Makefile.icx Makefile.inc
elif which icc >/dev/null 2>/dev/null ;
then
warning=""
cp config/Makefile.intel Makefile.inc
elif which gcc >/dev/null 2>/dev/null ;
then
cp config/Makefile.gcc Makefile.inc
else
echo >&2 Error: No gcc found
exit 1
fi
else
if which mpiicx >/dev/null 2>/dev/null ;
then
echo New Intel MPI found
cp config/Makefile.hpc2024 Makefile.inc
if which sbatch >/dev/null 2>/dev/null ;
then
echo SLURM found
ln -sf lpjsubmit_hpc bin/lpjsubmit
else
echo >2 No batch system found
fi
elif which mpiicc >/dev/null 2>/dev/null ;
then
echo Intel MPI found
warning=""
cp config/Makefile.cluster2015 Makefile.inc
if which llsubmit >/dev/null 2>/dev/null ;
then
echo LoadLeveler found
ln -sf lpjsubmit_intel bin/lpjsubmit
elif which sbatch >/dev/null 2>/dev/null ;
then
echo SLURM found
ln -sf lpjsubmit_slurm bin/lpjsubmit
else
echo >2 No batch system found
fi
elif which mpicc >/dev/null 2>/dev/null ;
then
cp config/Makefile.mpich Makefile.inc
ln -sf lpjsubmit_mpich bin/lpjsubmit
echo MPICH found
elif which icc >/dev/null 2>/dev/null ;
then
warning=""
cp config/Makefile.intel Makefile.inc
elif which gcc >/dev/null 2>/dev/null ;
then
cp config/Makefile.gcc Makefile.inc
else
echo >&2 Error: No gcc found
exit 1
fi
fi
echo Create executables with make all
elif [ "$osname" = "Darwin" ]
then
echo Operating system is $osname
if [ "$nompi" = "1" ]
then
if which icc >/dev/null 2>/dev/null ;
then
cp config/Makefile.intel Makefile.inc
elif which gcc >/dev/null 2>/dev/null ;
then
cp config/Makefile.gcc Makefile.inc
else
echo >&2 Error: No gcc found
exit 1
fi
else
if which mpicc >/dev/null 2>/dev/null ;
then
cp config/Makefile.darwin_mpich Makefile.inc
echo MPICH found
elif which gcc >/dev/null 2>/dev/null ;
then
cp config/Makefile.darwin_cc Makefile.inc
else
echo >&2 Error: No gcc found
exit 1
fi
fi
echo Create executables with make all
elif [ "$osname" = "AIX" ]
then
echo Operating system is AIX
if [ "$nompi" = "1" ]
then
cp config/Makefile.aix Makefile.inc
elif which mpcc >/dev/null 2>/dev/null ;
then
echo IBM MPI found
cp config/Makefile.aix_mpi Makefile.inc
ln -sf lpjsubmit_aix bin/lpjsubmit
else
cp config/Makefile.aix Makefile.inc
fi
echo Create executables with make all
else
echo >&2 Warning: unsupported operating system, Makefile.$osname created
cp config/Makefile.gcc Makefile.$osname
cp config/Makefile.$osname Makefile.inc
fi
if [ "$debug" = "1" ]
then
echo "CFLAGS = \$(WFLAG) \$(LPJFLAGS) $macro $warning \$(DEBUGFLAGS)" >>Makefile.inc
echo "LNOPTS = \$(WFLAG) \$(DEBUGFLAGS) -o " >>Makefile.inc
elif [ "$debug" = "2" ]
then
echo "CFLAGS = \$(WFLAG) \$(LPJFLAGS) $macro $warning \$(CHECKFLAGS)" >>Makefile.inc
echo "LNOPTS = \$(WFLAG) \$(CHECKFLAGS) -o " >>Makefile.inc
else
echo "CFLAGS = \$(WFLAG) \$(LPJFLAGS) $macro $warning \$(OPTFLAGS)" >>Makefile.inc
echo "LNOPTS = \$(WFLAG) \$(OPTFLAGS) -o " >>Makefile.inc
fi
echo LPJROOT = $prefix >>Makefile.inc
cat >bin/lpj_paths.sh <<EOF
#################################################################################
## ##
## l p j _ p a t h s . s h ##
## ##
## sh script to set environment variables for LPJmL. A call to this ##
## script has to be put in ~/.profile in the following way: ##
## ##
## . \$LPJROOT/bin/lpj_paths.sh ##
## ##
## LPJROOT has to be set to your root directory of LPJmL ##
## ##
## (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file ##
## authors, and contributors see AUTHORS file ##
## This file is part of LPJmL and licensed under GNU AGPL Version 3 ##
## or later. See LICENSE file or go to http://www.gnu.org/licenses/ ##
## Contact: https://github.com/PIK-LPJmL/LPJmL ##
## ##
## Created: $(date +"%d.%m.%Y") ##
## ##
#################################################################################
export LPJROOT=$prefix # change here to your directory
# set search path for LPJmL commands
export PATH=\$LPJROOT/bin:\$PATH
# set path for input files
export LPJINPATH=$inpath
# include manpages of LPJmL
export MANPATH=\$LPJROOT/man:\$MANPATH
# define alias
alias printheader="printclm -data"
alias soil2cdf="clm2cdf -notime -raw -byte"
alias lpjml='lpjml.sh'
EOF
chmod +x bin/lpj_paths.sh
cat >bin/lpj_paths.csh <<EOF
#################################################################################
## ##
## l p j _ p a t h s . c s h ##
## ##
## csh script to set environment variables for LPJmL. A call to this ##
## script has to be put in ~/.cshrc in the following way: ##
## ##
## source \$LPJROOT/bin/lpj_paths.csh ##
## ##
## LPJROOT has to be set to your root directory of LPJmL ##
## (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file ##
## authors, and contributors see AUTHORS file ##
## This file is part of LPJmL and licensed under GNU AGPL Version 3 ##
## or later. See LICENSE file or go to http://www.gnu.org/licenses/ ##
## Contact: https://github.com/PIK-LPJmL/LPJmL ##
## ##
## Created: $(date +"%d.%m.%Y") ##
## ##
#################################################################################
setenv LPJROOT $prefix # change here to your directory
# set search path for LPJmL commands
setenv PATH \$LPJROOT/bin\:\$PATH
# set path for input files
setenv LPJINPATH $inpath
# include manpages of LPJmL
setenv MANPATH \$LPJROOT/man\:\$MANPATH
# define alias
alias printheader "printclm -data"
alias soil2cdf "clm2cdf -notime -raw -byte"
alias lpjml 'lpjml.sh'
EOF
chmod +x bin/lpj_paths.csh
echo Put . $prefix/bin/lpj_paths.sh in your ~/.profile