We are building WRF-Hydro from source code, using intel compilers. I also need to build R from source. Today we encountered a problem during compilation using Spack and we totally forget how it’s solved previously when we successfully build from source code(instead of using Spack). Therefore, I figure I’d better record the scripts and solutions for errors. Solutions can be found with google but it’s definitely more convenient to record them in a single place.

Building R

R scripts is used for generating inputs for the WRF-Hydro.

.bashrc

1
2
3
4
5
6
export LD_LIBRARY_PATH=/opt/bzip2/1.0.8/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/xz/5.2.4/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/pcre/10.40/lib:$LD_LIBRARY_PATH
export PATH=/opt/pcre/10.40/bin:$PATH
export PATH=/opt/R/4.1.3/bin:$PATH
export LD_LIBRARY_PATH=/opt/R/4.1.3/lib:$LD_LIBRARY_PATH

bzip-1.0.8

1
2
3
4
5
6
7
8
9
10
11
wget https://www.sourceware.org/pub/bzip2/bzip2-latest.tar.gz
tar xf bzip2-latest.tar.gz
cd bzip2-1.0.8
sudo make install PREFIX=/opt/local/bzip2/1.0.8
make clean
make -f Makefile-libbz2_so
sudo cp bzip2-shared /opt/bzip2/1.0.8/bin
sudo cp libbz2.so.1.0.8 /opt/bzip2/1.0.8/lib
sudo ln -s /opt/bzip2/1.0.8/lib/libbz2.so.1.0.8 /opt/bzip2/lib/libbz2.so.1.0
sudo ln -s /opt/bzip2/1.0.8/lib/libbz2.so.1.0.8 /opt/bzip2/lib/libbz2.so
# add LD_LIBRARY_PATH

xz-5.2.4

1
2
3
4
5
6
wget https://tukaani.org/xz/xz-5.2.4.tar.gz
tar xvfz xz-5.2.4.tar.gz
cd xz-5.2.4
./configure --prefix=/opt/xz/5.2.4
sudo make install
# add LD_LIBRARY_PATH

pcre2

1
2
3
4
5
6
7
wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.40/pcre2-10.40.tar.gz
tar xf pcre2-10.40.tar.gz
cd pcre2-10.40
./configure --prefix=/opt/pcre/10.40 --enable-jit
sudo make install
# add LD_LIBRARY_PATH
# add PATH

R

1
2
3
4
5
6
7
8
9
10
11
12
13
14
export R_VERSION=4.1.3
wget https://cran.rstudio.com/src/base/R-4/R-${R_VERSION}.tar.gz
tar xf R-${R_VERSION}.tar.gz
cd R-${R_VERSION}
./configure --prefix=/opt/R/${R_VERSION} \
--enable-memory-profiling --enable-R-shlib --with-blas \
--with-lapack --with-readline=no --with-x=no \
--with-libpth-prefix=/opt/ \
CPPFLAGS="-I/opt/bzip2/1.0.8/include -I/opt/xz/5.2.4/include -I/opt/pcre/10.40/include" \
LDFLAGS="-L/opt/bzip2/1.0.8/lib -L/opt/xz/5.2.4/lib -L/opt/pcre/10.40/lib"
sudo make -j
sudo make install
# add PATH
# add LD_LIBRARY_PATH

Building WRF-Hydro

1
2
# TODO, it's also a disaster.
# It takes 30 minutes to compile WRF, jeez...