-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup
executable file
·123 lines (98 loc) · 3.81 KB
/
setup
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
#!/usr/bin/env bash
# This script creates a build directory and sticks a config.sh script into it.
# Then config.sh can be edited and run within the build directory.
# Print usage info.
if [ "$1" = "" ]; then
echo "setup: Creates a build directory with a configuration file."
echo "Optional argument 2 is path to haero install location."
echo "Usage: setup build_dir [haero_dir]"
exit 1
fi
# assign optional argument 2 to DIR_HAERO if it exists
if [ -z "$2" ]; then
# if the optional arg isn't given, we print this placeholder
export DIR_HAERO=/path/to/haero
else
# expand arg to full path, in case it's relative
export DIR_HAERO=$(readlink -f $2)
fi
# Create the build directory if it doesn't exist.
if [ ! -d $1 ]; then
mkdir -p $1
fi
# Copy our template config script into place.
echo -e "#!/usr/bin/env bash\n" > $1/config.sh
echo "SOURCE_DIR=$PWD" >> $1/config.sh
cat <<EOT >> $1/config.sh
# ^^^^^^ location of mam4xx source code.
# config.sh -- A CMake configuration script.
# Edit this file to change the parameters in your build. Uncomment exactly one
# value for each parameter.
#-----------------------------------------------------------------------------
# Installation prefix
#-----------------------------------------------------------------------------
PREFIX=$PWD/$1
#-----------------------------------------------------------------------------
# HAERO
#-----------------------------------------------------------------------------
# To build MAM4xx, you must have HAERO installed. Set this variable to a path
# with include/, lib/, and share/ directories in which HAERO has been installed.
# For instructions on building HAERO, surf to
# https://github.com/eagles-project/haero
# and check out the README.md file there.
HAERO_DIR=$DIR_HAERO
#-----------------------------------------------------------------------------
# Aerosol parameterization settings
#-----------------------------------------------------------------------------
# the number of vertical levels in each column
NUM_VERTICAL_LEVELS=72
#-----------------------------------------------------------------------------
# Build features and parameters
#-----------------------------------------------------------------------------
# Set this to
# * 'Debug' for development (debugging symbols, no optimization)
# * 'Release' for production (no symbols, optimization).
BUILD_TYPE=Debug
# Uncomment this if you want really verbose builds.
#VERBOSE=ON
# Uncomment this to enable code coverage instrumentation.
#COVERAGE=ON
#-----------------------------------------------------------------------------
# Don't change anything below here.
#-----------------------------------------------------------------------------
# We use good old-fashioned UNIX makefiles.
GENERATOR="Unix Makefiles"
if [ "\$VERBOSE" = "ON" ]; then
OPTIONS="\$OPTIONS -DCMAKE_VERBOSE_MAKEFILE=ON"
fi
if [ "\$COVERAGE" = "ON" ]; then
OPTIONS="\$OPTIONS -DENABLE_COVERAGE=ON"
fi
# Clear the build cache.
rm -f CMakeCache.txt
# Configure the build.
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=\$PREFIX \
-DCMAKE_BUILD_TYPE=\$BUILD_TYPE \
-DMAM4XX_HAERO_DIR=\$HAERO_DIR \
-DNUM_VERTICAL_LEVELS=\$NUM_VERTICAL_LEVELS \
-DENABLE_SKYWALKER=ON \
-DCMAKE_CUDA_ARCHITECTURES=80 \
\$OPTIONS \
-G "\$GENERATOR" \
\$SOURCE_DIR
EOT
# Make config.sh executable.
chmod a+x $1/config.sh
# Give instructions.
echo "Your build directory '$1' is ready."
# assign optional argument 2 to DIR_HAERO if it exists
if [ ! -z "$2" ]; then
# expand arg to full path, in case it's relative
echo "You have given '$DIR_HAERO' as the HAERO library install location."
fi
echo "To configure your build:"
echo " 1. cd $1"
echo " 2. Edit config.sh"
echo " 3. ./config.sh"
echo " 4. Build using 'make -j'."