Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/40 build wrf container #72

Merged
merged 16 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Successfully built WRF v4.5.1.
  • Loading branch information
hahnd committed Sep 20, 2023

Verified

This commit was signed with the committer’s verified signature.
roeniss Roeniss Moon
commit 7f0e1f9a1d65aed27e648db949b08a08a4aa1609
79 changes: 79 additions & 0 deletions docker/iwrf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Cornell uses ubuntu 22.04
FROM ubuntu:22.04

# Update the OS
RUN apt -y update
RUN apt -y upgrade

# Install compilers
RUN apt -y install cmake pkg-config build-essential wget libcurl4-openssl-dev m4
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor > /usr/share/keyrings/oneapi-archive-keyring.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list
RUN apt -y update
RUN apt -y install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.1.0 intel-oneapi-compiler-fortran-2023.1.0 intel-oneapi-dpcpp-cpp-2023.1.0 intel-oneapi-mpi-2021.9.0 intel-oneapi-mpi-devel-2021.9.0
RUN apt -y --fix-broken install
RUN apt -y update

# Install other required packages
RUN apt -y install libexpat1 libexpat1-dev expat git csh file

# Install packages used for debugging
RUN apt -y install vim

# Add system user
RUN useradd -u 5000 wrfuser

# Configure bash
RUN echo 'export MPI="/opt/intel/oneapi/mpi/latest"' >> /etc/bashrc
RUN echo 'export OPENMPI="${MPI}"' >> /etc/bashrc
RUN echo 'export INTEL="/opt/intel/oneapi/compiler/latest/linux"' >> /etc/bashrc
RUN echo 'export PATH="${INTEL}/bin/intel64:${MPI}/bin:${PATH}"' >> /etc/bashrc
RUN echo 'export SCC="icx"' >> /etc/bashrc
RUN echo 'export SFC="ifort"' >> /etc/bashrc
RUN echo 'export I_MPI_CC="icx"' >> /etc/bashrc
RUN echo 'export I_MPI_CXX="icpx"' >> /etc/bashrc
RUN echo 'export I_MPI_FC="ifort"' >> /etc/bashrc
RUN echo 'export I_MPI_F90="ifort"' >> /etc/bashrc
RUN echo 'export FC="mpifc"' >> /etc/bashrc
RUN echo 'export F90="mpifc"' >> /etc/bashrc
RUN echo 'export F77="mpifc"' >> /etc/bashrc
RUN echo 'export CC="mpicc"' >> /etc/bashrc
RUN echo 'export CXX="mpicxx"' >> /etc/bashrc
RUN echo 'export CPP="${CC} -E"' >> /etc/bashrc
RUN echo 'export CC_FOR_BUILD="${CC}"' >> /etc/bashrc
RUN echo 'export CPP_FOR_BUILD="${CPP}"' >> /etc/bashrc
RUN echo 'export CXXCPP="${CXX} -E"' >> /etc/bashrc
RUN echo 'export ABI="64"' >> /etc/bashrc
RUN echo 'export FCFLAGS="-I${MPI}/include"' >> /etc/bashrc
RUN echo 'export CFLAGS="-I${MPI}/include"' >> /etc/bashrc
RUN echo 'export LDFLAGS="-L${MPI}/lib -L${MPI}/lib/release"' >> /etc/bashrc
RUN echo 'export LD_LIBRARY_PATH="${MPI}/lib/release:${MPI}/lib"' >> /etc/bashrc
RUN echo 'source /opt/intel/oneapi/setvars.sh --force > /dev/null' >> /etc/bashrc
RUN echo 'export PATH="/opt/intel/oneapi/mpi/latest/bin:${PATH}"' >> /etc/bashrc
RUN echo 'export WRFUSER="wrfuser"' >> /etc/bashrc
# TODO: This is not taking effect for the stack, we had to manually run: 'ulimit -s unlimited'
RUN echo '* hard stack unlimited' >> /etc/security/limits.conf
RUN echo '* soft stack unlimited' >> /etc/security/limits.conf

# Download source
RUN mkdir -p /opt/src
WORKDIR /opt/src
RUN wget https://www.wrfcloud.com/libs/cmake-3.25.0-rc3.tar.gz
RUN wget https://www.wrfcloud.com/libs/eccodes-2.27.0.tar.gz
RUN wget https://www.wrfcloud.com/libs/g2clib-1.6.0-patch.tar.gz
RUN wget https://www.wrfcloud.com/libs/jasper-1.900.1.tar.gz
RUN wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.10/src/hdf5-1.10.10.tar.gz
RUN wget https://www.wrfcloud.com/libs/libaec-v1.0.6.tar.gz
RUN wget https://www.wrfcloud.com/libs/libpng-1.2.50.tar.gz
RUN wget https://www.wrfcloud.com/libs/ncview-2.1.7.tar.gz
RUN wget https://www.wrfcloud.com/libs/netcdf-4.7.3.tar.gz
RUN wget https://www.wrfcloud.com/libs/netcdf-cxx-4.3.1.tar.gz
RUN wget https://www.wrfcloud.com/libs/netcdf-fortran-4.5.2.tar.gz
RUN wget https://www.wrfcloud.com/libs/szip-2.1.1.tar.gz
RUN wget https://www.wrfcloud.com/libs/zlib-1.2.11.tar.gz
RUN wget https://downloads.unidata.ucar.edu/udunits/2.2.28/udunits-2.2.28.tar.gz

COPY build_wrf.sh /tmp/build_wrf.sh
RUN bash /tmp/build_wrf.sh

WORKDIR /home/wrfuser
145 changes: 145 additions & 0 deletions docker/iwrf/build_wrf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#! /bin/bash

# Make sure we have a value for a username. This should already be set
# in the /etc/bashrc, but use this default just in case it is not found.
if [[ -z "${WRFUSER}" ]]; then
WRFUSER="wrfuser"
fi

# Build zlib
source /etc/bashrc
cd /opt/src
tar -xzf zlib-1.2.11.tar.gz
cd /opt/src/zlib-1.2.11
./configure --prefix=/opt/zlib 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export ZLIB=/opt/zlib' >> /etc/bashrc
echo 'export LD_LIBRARY_PATH=${ZLIB}/lib:${LD_LIBRARY_PATH}' >> /etc/bashrc

# Build szip
source /etc/bashrc
cd /opt/src
tar -xzf szip-2.1.1.tar.gz
cd /opt/src/szip-2.1.1
./configure --prefix=/opt/szip 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export SZIP=/opt/szip' >> /etc/bashrc
echo 'export LD_LIBRARY_PATH=${SZIP}/lib:${LD_LIBRARY_PATH}' >> /etc/bashrc

# Build HDF5
source /etc/bashrc
cd /opt/src
tar -xzf hdf5-1.10.10.tar.gz
cd /opt/src/hdf5-1.10.10
./configure --prefix=/opt/hdf5 --enable-parallel --enable-fortran --with-zlib=${ZLIB} --with-szlib=${SZIP} 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export HDF5=/opt/hdf5' | tee -a /etc/bashrc
echo 'export PATH=${HDF5}/bin:${PATH}' | tee -a /etc/bashrc
echo 'export LD_LIBRARY_PATH=${HDF5}/lib:${LD_LIBRARY_PATH}' | tee -a /etc/bashrc

# Build NetCDF
source /etc/bashrc
cd /opt/src
tar -xzf netcdf-4.7.3.tar.gz
cd netcdf-c-4.7.3
export CPPFLAGS="-I${HDF5}/include -I${SZIP}/include -I${ZLIB}/include"
export LDFLAGS="-L${HDF5}/lib -L${SZIP}/lib -L${ZLIB}/lib"
./configure --prefix=/opt/netcdf --disable-dap-remote-tests --enable-mmap --enable-netcdf4 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export NETCDF=/opt/netcdf' | tee -a /etc/bashrc
echo 'export PATH=${NETCDF}/bin:${PATH}' | tee -a /etc/bashrc
echo 'export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH}' | tee -a /etc/bashrc

# Build NetCDF Fortran libraries
source /etc/bashrc
cd /opt/src
tar -xzf netcdf-fortran-4.5.2.tar.gz
cd netcdf-fortran-4.5.2
export CPPFLAGS="-I${HDF5}/include -I${SZIP}/include -I${NETCDF}/include"
export LDFLAGS="-L${HDF5}/lib -L${SZIP}/lib -L${NETCDF}/lib"
./configure --prefix=/opt/netcdf 2>&1 | tee configure.log
make install 2>&1 | tee build.log

# Build NetCDF C++ libraries
source /etc/bashrc
cd /opt/src
tar -xzf netcdf-cxx-4.3.1.tar.gz
cd netcdf-cxx4-4.3.1
export CPPFLAGS="-I${HDF5}/include -I${SZIP}/include -I${NETCDF}/include"
export LDFLAGS="-L${HDF5}/lib -L${SZIP}/lib -L${NETCDF}/lib"
./configure --prefix=/opt/netcdf 2>&1 | tee configure.log
make install 2>&1 | tee build.log

# Build libpng
source /etc/bashrc
cd /opt/src
tar -xzf libpng-1.2.50.tar.gz
cd libpng-1.2.50
export CPPFLAGS="-I${ZLIB}/include"
export LDFLAGS="-L${ZLIB}/lib"
./configure --prefix=/opt/libpng 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export LIBPNG=/opt/libpng' | tee -a /etc/bashrc
echo 'export PATH=${LIBPNG}/bin:${PATH}' | tee -a /etc/bashrc
echo 'export LD_LIBRARY_PATH=${LIBPNG}/lib:${LD_LIBRARY_PATH}' | tee -a /etc/bashrc

# Build jasper
source /etc/bashrc
cd /opt/src
tar -xzf jasper-1.900.1.tar.gz
cd jasper-1.900.1
export CFLAGS="--std=c89 -w -Wno-incompatible-pointer-types"
./configure --prefix=/opt/jasper 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export JASPER=/opt/jasper' | tee -a /etc/bashrc
echo 'export PATH=${JASPER}/bin:${PATH}' | tee -a /etc/bashrc
echo 'export LD_LIBRARY_PATH=${JASPER}/lib:${LD_LIBRARY_PATH}' | tee -a /etc/bashrc

# Build udunits
source /etc/bashrc
mkdir -p /opt/src
cd /opt/src
tar -xzf udunits-2.2.28.tar.gz
cd udunits-2.2.28
./configure --prefix=/opt/udunits 2>&1 | tee configure.log
make -j 4 install 2>&1 | tee build.log
echo 'export UDUNITS=/opt/udunits' | tee -a /etc/bashrc
echo 'export PATH=${UDUNITS}/bin:${PATH}' | tee -a /etc/bashrc
echo 'export LD_LIBRARY_PATH=${UDUNITS}/lib:${LD_LIBRARY_PATH}' | tee -a /etc/bashrc

# Build WRF
source /etc/bashrc
mkdir -p /home/${WRFUSER}
cd /home/${WRFUSER}
git clone https://github.com/wrf-model/WRF
cd WRF
git checkout v4.5.1
# TODO: configure complains that NetCDF was built without --enable-netcdf4, however, that flag is set in the NetCDF build. This was only a problem with WRF v4.5. Solution: export NETCDF_classic=1
export NETCDF_classic=1
./clean
./configure << EOF
15
1
EOF
cat configure.wrf | sed "s/-lz/-lz -L\/opt\/zlib\/lib/g" > configure.wrf.zlib
mv -f configure.wrf.zlib configure.wrf
./compile em_real 2>&1 | tee build.log
cd /home/${WRFUSER}
chown -R ${WRFUSER}.${WRFUSER} WRF

# Build WPS
source /etc/bashrc
cd /home/${WRFUSER}
git clone https://github.com/wrf-model/WPS
cd WPS
git checkout v4.5
export JASPERLIB="-L${SZIP}/lib -L${LIBPNG}/lib -L${ZLIB}/lib -L${JASPER}/lib -L${G2C}/lib -ljasper -lpng -lz -lgrib2c"
export JASPERINC="-I${SZIP}/include -I${LIBPNG}/include -I${ZLIB}/include -I${JASPER}/include"
export FCFLAGS="${FCFLAGS} ${JASPERINC}"
./clean
./configure << EOF
19
EOF
./compile 2>&1 | tee build.log
cd /home/${WRFUSER}
chown -R ${WRFUSER}.${WRFUSER} WPS
File renamed without changes.
1 change: 0 additions & 1 deletion docker/build_wrf_lulc.sh → docker/lulc/build_wrf.sh
Original file line number Diff line number Diff line change
@@ -128,7 +128,6 @@ cd WRF
git checkout v4.3.3
# TODO: configure complains that NetCDF was built without --enable-netcdf4, however, that flag is set in the NetCDF build. This was only a problem with WRF v4.5. Solution: export NETCDF_classic=1
./clean
mv arch/configure.iwrf.defaults arch/configure.defaults
./configure << EOF
15
1