diff --git a/.gitignore b/.gitignore index 7564616..0cfdd0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +libs *~ .vs /.DS_Store diff --git a/docker/iwrf/Dockerfile b/docker/iwrf/Dockerfile new file mode 100644 index 0000000..eb4c36c --- /dev/null +++ b/docker/iwrf/Dockerfile @@ -0,0 +1,107 @@ +# Cornell uses ubuntu 22.04 +FROM ubuntu:22.04 as wrfbuild + +# 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-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 'source /etc/bash.bashrc' >> /etc/bashrc +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="ifx"' >> /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="ifx"' >> /etc/bashrc +RUN echo 'export I_MPI_F90="ifx"' >> /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 WPS.patch /tmp/WPS.patch +COPY build_wrf.sh /tmp/build_wrf.sh +RUN bash /tmp/build_wrf.sh + + +FROM ubuntu:22.04 + +# Update the OS +RUN apt -y update +RUN apt -y upgrade + +COPY --from=wrfbuild /home/wrfuser /home/wrfuser +COPY --from=wrfbuild /opt/hdf5 /opt/hdf5 +COPY --from=wrfbuild /opt/jasper /opt/jasper +COPY --from=wrfbuild /opt/libpng /opt/libpng +COPY --from=wrfbuild /opt/netcdf /opt/netcdf +COPY --from=wrfbuild /opt/szip /opt/szip +COPY --from=wrfbuild /opt/udunits /opt/udunits +COPY --from=wrfbuild /opt/zlib /opt/zlib +COPY --from=wrfbuild /etc/bashrc /etc/bashrc + +# Install required runtime packages +# Note: To get a list of Intel OneAPI runtime packages, run the following: +# apt-cache pkgnames intel | grep intel-oneapi-runtime +RUN apt -y install cmake pkg-config build-essential wget libcurl4-openssl-dev m4 csh +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-runtime-mpi-2021 intel-oneapi-common-vars intel-oneapi-compiler-shared-runtime-2023.1.0 intel-oneapi-compiler-fortran-runtime-2023.1.0 + +WORKDIR /home/wrfuser diff --git a/docker/iwrf/WPS.patch b/docker/iwrf/WPS.patch new file mode 100644 index 0000000..c08d05d --- /dev/null +++ b/docker/iwrf/WPS.patch @@ -0,0 +1,136 @@ +--- WPS/ungrib/src/cio.c 2024-03-22 21:46:05.026504170 +0000 ++++ WPS-patch/ungrib/src/cio.c 2024-03-22 22:03:15.537543342 +0000 +@@ -48,8 +48,6 @@ + #endif + + /* ****************************************************************** */ +- +-c_open(unit, nunit, name, mode, err, oflag) + /* + * unit = Fortran unit number + * nunit = UNIX file descriptor associated with 'unit' +@@ -64,12 +62,15 @@ + = 1 : file name and unit number printed (and errors) + = -1 : no print at all (not even errors) + */ +- int *unit; +- int *nunit; +- int *mode; +- int *err; +- int *oflag; +- char name[FORT_FILE_LEN]; ++int ++c_open( ++ int *unit, ++ int *nunit, ++ char name[FORT_FILE_LEN], ++ int *mode, ++ int *err, ++ int *oflag ++ ) + { + int fd, i; + char fname[FORT_FILE_LEN]; +@@ -114,8 +115,6 @@ + } + + /* ****************************************************************** */ +-bn_seek(fd, bread, mode, iprint) +- + /* Move the read/write file pointer + fd : Unix file descriptor. + bread : Number of bytes to move the pointer. +@@ -128,9 +127,13 @@ + Location 0 [bn_seek(fd,0,-1,0)] puts us just before the first byte, + so the next bn_read will get byte 1. + */ +- +- int *fd, *bread, *mode, *iprint; +- ++int ++bn_seek( ++ int *fd, ++ int *bread, ++ int *mode, ++ int *iprint ++ ) + { + off_t i, offset; + int how_to_space; +@@ -151,8 +154,6 @@ + } + + /* ****************************************************************** */ +- +-bn_read(fd, buf, nbuf, bread, ios, idiag) + /* + * fd = UNIX file descriptor number (NOT a Fortran unit) + * buf = area into which to read +@@ -163,8 +164,15 @@ + 2 = Error in reading + * idiag : if non-zero, error and EOF messages will be printed + */ +- +- int *fd, *nbuf, buf[], *bread, *ios, *idiag; ++int ++bn_read( ++ int *fd, ++ int buf[], ++ int *nbuf, ++ int *bread, ++ int *ios, ++ int *idiag ++ ) + { + int bytesread; + +@@ -197,17 +205,21 @@ + } + + /* ****************************************************************** */ +- +-bnwrit_(fd, buf, nbuf, bwritten, err, idiag) +- int *fd, *nbuf, buf[], *bwritten, *err, *idiag; +- + /* + * fd = UNIX file descriptor number (NOT a Fortran unit) buf = area from + * which to write nbuf = number of bytes to write to fd bwritten = number + * actually written err = UNIX error number returned to FORTRAN idiag : if + * non-zero, error and EOF messages will be printed + */ +- ++int ++bnwrit_( ++ int *fd, ++ int buf[], ++ int *nbuf, ++ int *bwritten, ++ int *err, ++ int *idiag ++ ) + { + int byteswritten; + +@@ -231,8 +243,6 @@ + } + + /* ****************************************************************** */ +- +-c_close(nunit, iprint, err) + /* + Close a C (UNIX?) file descriptor: + nunit : (INPUT) : The C (UNIX?) file descriptor to close. +@@ -241,7 +251,12 @@ + err : (OUTPUT) : Error flag ( err = 0 : Successful close) + ( err = 1 : Error on close) + */ +- int *nunit, *iprint, *err; ++int ++c_close( ++ int *nunit, ++ int *iprint, ++ int *err ++ ) + { + extern int errno; /* I/O error return */ + int istat; diff --git a/docker/iwrf/build.sh b/docker/iwrf/build.sh new file mode 100644 index 0000000..607e0fa --- /dev/null +++ b/docker/iwrf/build.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +docker build --no-cache -f Dockerfile . 2>&1 | tee build.log diff --git a/docker/iwrf/build_wrf.sh b/docker/iwrf/build_wrf.sh new file mode 100644 index 0000000..d2eb09a --- /dev/null +++ b/docker/iwrf/build_wrf.sh @@ -0,0 +1,209 @@ +#! /bin/bash + +# +# If the given exit code is non-zero, the script will print the exit message and quit +# +# param - exit_code - Exit code to inspect +# param - message - Exit message +# +function check_errors +{ + exit_code=${1} + message="${2}" + + if [[ "${exit_code}" != "0" ]]; then + echo "${message}" +# exit ${exit_code} + fi +} + +# +# Check for expected files after the build +# +# param - expected_files +# +function check_expected_files +{ + expected_files=$1 + ok="1" + + for expected_file in ${expected_files}; do + if [[ ! -e "${expected_file}" ]]; then + echo "Failed to build file: ${expected_file}" + ok="0" + fi + done + + if [[ "${ok}" == "0" ]]; then + exit 1 + fi +} + +# 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 +#check_errors ${?} "Failed to build zlib" +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 clean +make -j 4 install 2>&1 | tee build.log +#check_errors ${?} "Failed to build szip" +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 hdf5-1.10.10 +./configure --prefix=/opt/hdf5 --enable-parallel --enable-fortran --with-zlib=${ZLIB} --with-szlib=${SZIP} 2>&1 | tee configure.log +check_errors ${?} "Failed to configure HDF5" +make -j 4 install 2>&1 | tee build.log +check_errors ${?} "Failed to build HDF5" +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 +#check_errors ${?} "Failed to build NetCDF" +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 +#check_errors ${?} "Failed to build NetCDF-Fortran" + +# 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 +#check_errors ${?} "Failed to build NetCDF-C++" + +# 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 +#check_errors ${?} "Failed to build libpng" +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 +#check_errors ${?} "Failed to build jasper" +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 +#check_errors ${?} "Failed to build udunits" +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.2 +# 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 +78 +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 +./compile em_real 2>&1 | tee build2.log +cd /home/${WRFUSER} +#chown -R ${WRFUSER}.${WRFUSER} WRF +chown -R root.root WRF +#check_expected_files "/home/wrfuser/WRF/main/wrf.exe /home/wrfuser/WRF/main/real.exe" + +# Build WPS +source /etc/bashrc +cd /home/${WRFUSER} +git clone https://github.com/wrf-model/WPS +cd WPS +git checkout v4.6.0 +cd ../ +#patch -ruN -p1 -d WPS < /tmp/WPS.patch +cd WPS +export JASPERLIB="-L${SZIP}/lib -L${LIBPNG}/lib -L${ZLIB}/lib -L${JASPER}/lib -L${G2C}/lib -ljasper -lpng -lz" +export JASPERINC="-I${SZIP}/include -I${LIBPNG}/include -I${ZLIB}/include -I${JASPER}/include" +export FCFLAGS="${FCFLAGS} ${JASPERINC}" +./clean +./configure << EOF +19 +EOF +cat configure.wps \ + | sed "s/SCC.*=.*icc/SCC = icx/g" \ + > configure.wps.icx +mv configure.wps.icx configure.wps +./compile 2>&1 | tee build.log +cd /home/${WRFUSER} +#chown -R ${WRFUSER}.${WRFUSER} WPS +chown -R root.root WPS +#check_expected_files "/home/wrfuser/WPS/geogrid/src/geogrid.exe /home/wrfuser/WPS/ungrib/src/ungrib.exe /home/wrfuser/WPS/metgrid/src/metgrid.exe" diff --git a/docker/lulc/Dockerfile b/docker/lulc/Dockerfile new file mode 100644 index 0000000..5fa47f7 --- /dev/null +++ b/docker/lulc/Dockerfile @@ -0,0 +1,107 @@ +# Cornell uses ubuntu 22.04 +FROM ubuntu:22.04 as wrfbuild + +# 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.29-iwrf-mods.tar.gz +RUN wget https://www.wrfcloud.com/libs/WPS-v4.4-iwrf-patch.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 + +FROM ubuntu:22.04 + +# Update the OS +RUN apt -y update +RUN apt -y upgrade + +COPY --from=wrfbuild /home/wrfuser /home/wrfuser +COPY --from=wrfbuild /opt/hdf5 /opt/hdf5 +COPY --from=wrfbuild /opt/jasper /opt/jasper +COPY --from=wrfbuild /opt/libpng /opt/libpng +COPY --from=wrfbuild /opt/netcdf /opt/netcdf +COPY --from=wrfbuild /opt/szip /opt/szip +COPY --from=wrfbuild /opt/udunits /opt/udunits +COPY --from=wrfbuild /opt/zlib /opt/zlib +COPY --from=wrfbuild /etc/bashrc /etc/bashrc + +# Install required runtime packages +# Note: To get a list of Intel OneAPI runtime packages, run the following: +# apt-cache pkgnames intel | grep intel-oneapi-runtime +RUN apt -y install cmake pkg-config build-essential wget libcurl4-openssl-dev m4 csh +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-runtime-mpi-2021 intel-oneapi-common-vars intel-oneapi-compiler-shared-runtime-2023.1.0 intel-oneapi-compiler-fortran-runtime-2023.1.0 + +WORKDIR /home/wrfuser diff --git a/docker/lulc/build.sh b/docker/lulc/build.sh new file mode 100644 index 0000000..607e0fa --- /dev/null +++ b/docker/lulc/build.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +docker build --no-cache -f Dockerfile . 2>&1 | tee build.log diff --git a/docker/lulc/build_wrf.sh b/docker/lulc/build_wrf.sh new file mode 100644 index 0000000..6932780 --- /dev/null +++ b/docker/lulc/build_wrf.sh @@ -0,0 +1,159 @@ +#! /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.29-iwrf-mods.tar.gz +cd jasper-1.900.29-iwrf-mods +./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 g2clib +source /etc/bashrc +mkdir -p /opt/src +cd /opt/src +tar -xzf g2clib-1.6.0-patch.tar.gz +cd g2clib-1.6.0-patch +cat makefile | sed "s/INC=.*/INC=-I\/opt\/jasper\/include -I\/opt\/libpng\/include -I\/opt\/zlib\/include/g" > makefile2 +make -f makefile2 2>&1 | tee build.log +mkdir -p /opt/g2clib/lib +cp -f libgrib2c.a /opt/g2clib/lib +echo 'export G2C=/opt/g2clib' | tee -a /etc/bashrc +echo 'export LD_LIBRARY_PATH=${G2C}/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.3.3 # v4.5.2 is latest +# 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 +./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.4 +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 +cd .. +tar -xvzf /opt/src/WPS-v4.4-iwrf-patch.tar.gz +cd WPS +./compile 2>&1 | tee build.log +cd /home/${WRFUSER} +chown -R ${WRFUSER}.${WRFUSER} WPS