Skip to content

Commit 5a610f8

Browse files
committed
Merge branch 'build_script' into 'main'
Renamed tacc_build.sh to libra_build.sh See merge request ardg/libra!150
2 parents 3c106fb + 063c2ca commit 5a610f8

File tree

2 files changed

+138
-63
lines changed

2 files changed

+138
-63
lines changed

scripts/libra_build.sh

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/bin/bash
2+
# Copyright (C) 2025
3+
# Associated Universities, Inc. Washington DC, USA.
4+
#
5+
# This library is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU Library General Public License as published by
7+
# the Free Software Foundation; either version 2 of the License, or (at your
8+
# option) any later version.
9+
#
10+
# This library is distributed in the hope that it will be useful, but WITHOUT
11+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13+
# License for more details.is
14+
#
15+
# You should have received a copy of the GNU Library General Public License
16+
# along with this library; if not, write to the Free Software Foundation,
17+
# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18+
#
19+
# Correspondence concerning this should be addressed as follows:
20+
# Postal address: National Radio Astronomy Observatory
21+
# 1003 Lopezville Road,
22+
# Socorro, NM - 87801, USA
23+
#
24+
# $Id$
25+
26+
#=================================================================================
27+
# This script sets up variables for an out-of-tree build.
28+
# It also assumes that the CMakeLists.txt is in ".."
29+
#
30+
# Following two lines are needed only if the spack env isn't activated
31+
#
32+
# Note that ". <SPACK INSTALL LOCATION>/share/spack/setup-env.sh" is
33+
# still required. This defines the $SPACK_ROOT (plus some more).
34+
#
35+
#SPACK_ENV_NAME=LibRA_Build_1
36+
#SPACK_ENV=$SPACK_ROOT/var/spack/environments/$SPACK_ENV_NAME
37+
38+
#
39+
# The list of packages required in SPACK are checked-for below.
40+
#
41+
# For CPU-only build, use "-DLIBRA_ENABLE_CUDA_BACKEND=OFF" as a commandline arg.
42+
# For GPU+CPU build, use "-DKokkos_CUDA_ARCH_NAME=<GPU ARCH NAME>" as a commandline arg.
43+
#
44+
45+
# Additional commands required on stampede3 before running this script:
46+
# . <PATH_TO_SPACK_PACKAGE>/share/spack/setup-env.sh
47+
# spacktivate -p <LIBRA_ENV_NAME>
48+
# module unload python/3.9.18 intel/24.0
49+
50+
function in_spack_env() {
51+
if [[ -v SPACK_ROOT ]]; then
52+
return 0; # True is bash!
53+
else
54+
return 1; # False in bash!
55+
fi
56+
}
57+
# This function checks if a given package is installed in the spack env.
58+
function is_installed_in_spack() {
59+
if in_spack_env; then
60+
if spack find --format "{name}" "$1" > /dev/null 2>&1; then
61+
return 1;
62+
else
63+
echo "$1 "
64+
fi
65+
# else
66+
# echo "is_installed_in_spack: Not in an SPACK env.";
67+
fi
68+
}
69+
70+
export CMAKE=`which cmake`
71+
72+
#
73+
# Setup and checks for build in an SPACK env
74+
#
75+
if in_spack_env; then
76+
# $SPACK_ENV gets defined in an activated env.
77+
SPACK_ENV_ROOT=$SPACK_ENV/.spack-env/view/
78+
79+
#---------------------------------------------------------
80+
echo "Checking required packages in SPACK ($SPACK_ROOT)"...
81+
#
82+
# Required dependencies
83+
#
84+
tt=$(is_installed_in_spack "cfitsio")
85+
tt+=$(is_installed_in_spack "wcslib")
86+
tt+=$(is_installed_in_spack "gsl")
87+
tt+=$(is_installed_in_spack "ncurses")
88+
tt+=$(is_installed_in_spack "readline")
89+
tt+=$(is_installed_in_spack "cmake")
90+
91+
if [[ -z "$tt" ]]; then
92+
echo -n "";
93+
else
94+
echo "###Error: Following required dependencies not found: "$tt;
95+
exit;
96+
fi
97+
98+
#---------------------------------------------------------
99+
# Maybe required
100+
#
101+
tt=$(is_installed_in_spack "openblas")
102+
tt+=$(is_installed_in_spack "python")
103+
104+
if [[ -z "$tt" ]]; then
105+
echo -n "";
106+
else
107+
echo;
108+
echo "WARNING: Following dependencies not found but may be required later in the build process: "$tt;
109+
echo;
110+
fi
111+
#
112+
#---------------------------------------------------------
113+
#
114+
export GSL_ROOT=$(spack location -i gsl)
115+
export WCSLIB_ROOT=$(spack location -i wcslib)
116+
117+
export LD_LIBRARY_PATH=/lib64:/lib:$SPACK_ENV_ROOT/lib64:$SPACK_ENV_ROOT/lib:$LD_LIBRARY_PATH
118+
119+
export CMAKE=$(spack location -i cmake)/bin/cmake
120+
fi
121+
122+
#
123+
# NOTE: HPG does not build with the GCC 11.4 and CUDA 12.x combo
124+
# GCC 11.4 with CUDA 11.x works.
125+
# Not clear what other combinations work/not work.
126+
#
127+
export CXX=/usr/bin/g++
128+
export CC=/usr/bin/gcc
129+
export FC=/usr/bin/gfortran
130+
# GNU configure script uses the env variable F77 (for building FFTW package)
131+
export F77=${FC}
132+
133+
#
134+
# Use -DLIBRA_ENABLE_CUDA_BACKEND=OFF for CPU-only build.
135+
# Use -DKokkos_CUDA_ARCH_NAME=<GPU ARCH NAME> to build for GPU and CPU.
136+
#
137+
$CMAKE -S .. -B ../build -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} -DCMAKE_Fortran_COMPILER=${FC} "$@"
138+
$CMAKE --build ../build

scripts/tacc_build.sh

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)