-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild3.sh
executable file
·171 lines (149 loc) · 3.42 KB
/
build3.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
#!/bin/bash
#build script for CABLE
#Simplified from previous build script. Only set up for raijin
#Usage:
#> ./build3
# OR
#> ./build3 mpi
#builds MPI version of CABLE
## gadi.nci.org.au
host_gadi()
{
. /etc/bashrc
module purge
module add intel-compiler/2019.5.281
module add netcdf/4.6.3
export NCDIR=$NETCDF_ROOT'/lib/Intel'
export NCMOD=$NETCDF_ROOT'/include/Intel'
export CFLAGS='-O2 -fp-model precise '
export LDFLAGS='-L'$NCDIR' -O0'
export LD='-lnetcdf -lnetcdff'
if [[ $1 = 'mpi' ]]; then
module add intel-mpi/2019.5.281
export FC='mpif90'
else
export FC='ifort'
fi
if [[ $1 = 'MGK' ]]; then
export CFLAGS='-O2'
#export NCMOD=$NETCDF_ROOT'/include'
fi
if [[ $1 = 'debug' ]]; then
export CFLAGS='-O0 -traceback -g -fp-model precise -ftz -fpe0'
#export CFLAGS='-O0 -traceback -g -fp-model precise -ftz -fpe0 -check all,noarg_temp_created'
fi
if [[ $1 = 'mpi' ]]; then
build_build mpi
else
build_build
fi
cd ../
build_status
}
clean_build()
{
rm -fr .tmp
echo ''
echo 'cleaning up'
echo ''
echo 'Press Enter too continue buiding, Control-C to abort now.'
echo ''
read dummy
}
build_build()
{
if [[ ! -d .tmp ]]; then
mkdir .tmp
fi
if [[ -f cable ]]; then
echo ''
echo 'cable executable exists. copying to dated backup file'
echo ''
mv cable cable.`date +%d.%m.%y`
fi
# directories contain source code
ALB="../science/albedo"
RAD="../science/radiation"
CAN="../science/canopy"
CNP="../science/casa-cnp"
GWH="../science/gw_hydro"
MIS="../science/misc"
ROU="../science/roughness"
SOI="../science/soilsnow"
LUC="../science/landuse"
OFF="../offline"
UTI="../util"
PAR="../params"
SLI="../science/sli"
POP="../science/pop"
/bin/cp -p $ALB/*90 ./.tmp
/bin/cp -p $CAN/*90 ./.tmp
/bin/cp -p $CNP/*90 ./.tmp
/bin/cp -p $GWH/*90 ./.tmp
/bin/cp -p $MIS/*90 ./.tmp
/bin/cp -p $RAD/*90 ./.tmp
/bin/cp -p $ROU/*90 ./.tmp
/bin/cp -p $SOI/*90 ./.tmp
/bin/cp -p $SLI/*90 ./.tmp
/bin/cp -p $POP/*90 ./.tmp
/bin/cp -p $LUC/*90 ./.tmp
/bin/cp -p $OFF/*90 ./.tmp
/bin/cp -p $UTI/*90 ./.tmp
/bin/cp -p $PAR/*90 ./.tmp
/bin/cp -p Makefile ./.tmp
cd .tmp/
echo ''
echo "Build setup complete."
echo 'Compiling now ...'
echo ''
echo ''
echo 'Building from source common across serial and MPI applications'
echo ''
echo ''
echo 'Building drivers for either serial or MPI application'
echo ''
if [[ $1 = 'mpi' ]]; then
make mpi
else
make
fi
}
build_status()
{
if [[ -f .tmp/cable ]]; then
mv .tmp/cable .
echo ''
echo 'BUILD OK'
echo ''
elif [[ -f .tmp/cable-mpi ]]; then
mv .tmp/cable-mpi .
echo ''
echo 'BUILD OK'
echo ''
else
echo ''
echo 'Oooops. Something went wrong'
echo ''
echo 'Other than compiler messages, known build issues:'
echo 'Some systems require additional library. '
echo 'e.g. Edit Makefile; add -lnetcdff to LD = ...'
fi
exit
}
###########################################
## build.ksh - MAIN SCRIPT STARTS HERE ##
###########################################
if [[ $1 = 'clean' ]]; then
clean_build
fi
if [[ $1 = 'mpi' ]]; then
echo ''
echo "Building cable_mpi"
echo ''
host_gadi mpi
else
echo ''
echo "Building cable (serial)"
echo ''
host_gadi $1
fi