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

Docker Container Improvements #3

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_output.txt
output_*_build.txt
*.swp
*.png

Expand Down
187 changes: 187 additions & 0 deletions Docker/Dockerfile-GNU
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
FROM ubuntu:18.04
# Ubuntu 18.04 base

MAINTAINER Peter Vaillancourt "[email protected]"

## Use bash for compile
## This Dockerfile compiles WRF from source during "docker build" step
SHELL ["/bin/bash","-c"]
ENV WRF_VERSION=4.2.2

## Ensuring only root user to prepare for singularity conversion
ARG USER=root
USER root
ARG HOME=/root

ARG DEBIAN_FRONTEND=noninteractive

RUN mkdir /opt/wrf
RUN set -eux

## Stacksize - WRF is greedy
## See https://forum.mmm.ucar.edu/phpBB3/viewtopic.php?t=133
## Setting OS stacksize to unlimited, setting OpenMP stacksize to 96GB
ENV OMP_STACKSIZE=96G

RUN ulimit -s unlimited && \
echo ulimit -s unlimited >> /etc/bashrc && \
echo export OMP_STACKSIZE=96G >> /etc/bashrc

## Set up some useful environment variables
ENV MAIN_DIR=/opt/wrf
ENV WRF_SRC_ROOT_DIR=${MAIN_DIR}/WRF
ENV DIR=${MAIN_DIR}/LIBRARIES
ENV CC=gcc
ENV FC=gfortran
ENV FCFLAGS=-m64
ENV F77=mpif90
ENV FFLAGS=-m64
ENV JASPERLIB=$DIR/grib2/lib
ENV JASPERINC=$DIR/grib2/include
ENV NETCDF=$DIR/NETCDF
ENV PNETCDF=$DIR/PNETCDF
ENV PHDF5=$DIR/PHDF5
ENV LDFLAGS=-L$DIR/grib2/lib
ENV CPPFLAGS="-I${PHDF5}/include -I${PNETCDF}/include -I${NETCDF}/include -I$DIR/grib2/include"
ENV PATH=${NETCDF}/bin:${PNETCDF}/bin:$PATH:$DIR/grib2
ENV LD_LIBRARY_PATH=$PHDF5/lib:$PNETCDF/lib:$NETCDF/lib:$LD_LIBRARY_PATH:$DIR/grib2/lib
ENV WRFIO_NCD_LARGE_FILE_SUPPORT=1
ENV WRF_EM_CORE=1

## Set environment for interactive container shells
RUN echo export MAIN_DIR=/opt/wrf >> /etc/bashrc && \
echo export WRF_SRC_ROOT_DIR=${DIR}/WRF >> /etc/bashrc && \
echo export DIR=${MAIN_DIR}/LIBRARIES >> /etc/bashrc && \
echo export CC=mpicc >> /etc/bashrc && \
echo export FC=mpif90 >> /etc/bashrc && \
echo export F77=mpif90 >> /etc/bashrc && \
echo export FFLAGS=-m64 >> /etc/bashrc && \
echo export JASPERINC=$DIR/grib2/include >> /etc/bashrc && \
echo export JASPERLIB=$DIR/grib2/lib >> /etc/bashrc && \
echo export NETCDF=$DIR/NETCDF >> /etc/bashrc && \
echo export PNETCDF=$DIR/PNETCDF >> /etc/bashrc && \
echo export PHDF5=$DIR/PHDF5 >> /etc/bashrc && \
echo export LDFLAGS=-L$DIR/grib2/lib >> /etc/bashrc && \
echo export CPPFLAGS="-I${PHDF5}/include -I${PNETCDF}/include -I${NETCDF}/include -I$DIR/grib2/include" >> /etc/bashrc && \
echo export PATH=$PATH:$DIR/grib2 >> /etc/bashrc && \
echo export LD_LIBRARY_PATH=$PHDF5/lib:$PNETCDF/lib:$NETCDF/lib:$LD_LIBRARY_PATH:$DIR/grib2/lib >> /etc/bashrc && \
echo export WRFIO_NCD_LARGE_FILE_SUPPORT=1 >> /etc/bashrc && \
echo export WRF_EM_CORE=1 >> /etc/bashrc

## Install tools, libraries, and dependencies
WORKDIR $DIR

### Tools
RUN apt-get update -y && apt-get install -y \
cmake \
tcsh \
wget \
unzip \
gawk \
time \
m4 \
rsync \
curl \
file \
gcc \
gfortran \
g++ \
gcc-multilib \
g++-multilib \
hostname \
make \
ncl-ncarg \
perl \
tar

### Libraries
#### zlib 1.2.7
RUN wget https://zlib.net/fossils/zlib-1.2.7.tar.gz && \
tar -xzf zlib-1.2.7.tar.gz && \
cd zlib-1.2.7 && \
./configure --prefix=$DIR/grib2 && \
make && make install

#### libpng 1.2.50
RUN wget https://sourceforge.net/projects/libpng/files/libpng12/older-releases/1.2.50/libpng-1.2.50.tar.gz && \
tar -xzf libpng-1.2.50.tar.gz && \
cd libpng-1.2.50 && \
./configure --prefix=$DIR/grib2 && \
make && make install

#### Jasper 1.900.1
RUN wget https://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.1.zip && \
unzip jasper-1.900.1.zip && \
cd jasper-1.900.1 && \
./configure --prefix=$DIR/grib2 && \
make && make install

### Install Dependencies
#### Third-party EPEL builds of NetCDF and OpenMPI
RUN add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu xenial universe"
RUN apt-get install -y \
libnetcdf-dev \
libnetcdf11 \
libnetcdff-dev \
netcdf-bin \
libpnetcdf-dev \
libpnetcdf0d \
pnetcdf-bin \
libhdf5-openmpi-dev \
openmpi-bin \
libopenmpi-dev \
mpi-default-bin \
mpi-default-dev

RUN ln -sf /usr/include/pnetcdf* $PNETCDF/include && \
ln -sf /usr/include/netcdf* $NETCDF/include && \
ln -sf /usr/include/openmpi/ $NETCDF/include && \
ln -sf /usr/lib/openmpi/lib $NETCDF/lib

#TODO: Check versions of above
## Intel Version list for reference
### PHDF5 1.10.4
### PNetCDF 1.11.0
### NetCDF-C 4.6.2
### NetCDF-Fortran 4.5.3

ENV NETCDF4=1
RUN echo export export NETCDF4=1 >> /etc/bashrc

## Install WRF 4.2.2
WORKDIR $MAIN_DIR

#ENV LDFLAGS="-lm -lnetcdff -lnetcdf -lpnetcdf"
#RUN echo export LDFLAGS="-lm -lnetcdff -lnetcdf -lpnetcdf" >> /etc/bashrc
#
#### Get WRF v4.2.2 tar archive
#RUN wget https://github.com/wrf-model/WRF/archive/refs/tags/v4.2.2.tar.gz && \
# tar -zxf v4.2.2.tar.gz && \
# mv WRF-4.2.2/ WRF
#
#WORKDIR $WRF_SRC_ROOT_DIR
#
#### Configure WRF
#RUN ./clean -a && \
#TODO: Check config option... 66 is Intel
# echo '66\n1\n' | ./configure && \
# awk -v add=" -L${DIR}/zlib-1.2.7" '/^ZLIB/ {$0=$0add} 1' configure.wrf > temp && mv temp configure.wrf
#
#### Compile WRF
#RUN time ./compile em_real 2>&1 | tee compile_em_real.log


#TODO: Add a check that WRF installed correctly, error otherwise
#TODO: Install WPS?

## For development
#TODO: Comment these out for production
RUN apt-get install -y \
man \
bash-completion \
vim \
htop \
tmux

RUN ldconfig

25 changes: 19 additions & 6 deletions Docker/Dockerfile → Docker/Dockerfile-Intel
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ ARG HOME=/root

#ARG DEBIAN_FRONTEND=noninteractive # Intel Dockerfile does this

## Install tools
RUN apt-get update -y && apt-get install -y \
cmake \
tcsh \
wget \
unzip \
tar \
curl \
gawk \
time \
m4 \
Expand All @@ -31,6 +34,17 @@ RUN apt-get update -y && apt-get install -y \
RUN mkdir /opt/wrf
RUN set -eux

## Stacksize - WRF is greedy
## See https://forum.mmm.ucar.edu/phpBB3/viewtopic.php?t=133
## Setting OS stacksize to unlimited, setting OpenMP stacksize to 64GB (KMP_STACKSIZE is for Intel)
ENV OMP_STACKSIZE=96G
ENV KMP_STACKSIZE=96G

RUN ulimit -s unlimited && \
echo ulimit -s unlimited >> /etc/bashrc && \
echo export OMP_STACKSIZE=96G >> /etc/bashrc && \
echo export KMP_STACKSIZE=96G >> /etc/bashrc

## Set up some useful environment variables
ENV MAIN_DIR=/opt/wrf
ENV WRF_SRC_ROOT_DIR=${MAIN_DIR}/WRF
Expand All @@ -56,10 +70,10 @@ ENV PATH=${NETCDF}/bin:${PNETCDF}/bin:$PATH:$DIR/grib2
ENV LD_LIBRARY_PATH=$PHDF5/lib:$PNETCDF/lib:$NETCDF/lib:$LD_LIBRARY_PATH:$DIR/grib2/lib
ENV WRFIO_NCD_LARGE_FILE_SUPPORT=1
ENV WRF_EM_CORE=1
ENV KMP_STACKSIZE=512m

## Set environment for interactive container shells
RUN echo export WRF_SRC_ROOT_DIR=${DIR}/WRF >> /etc/bashrc && \
RUN echo export MAIN_DIR=/opt/wrf >> /etc/bashrc && \
echo export WRF_SRC_ROOT_DIR=${DIR}/WRF >> /etc/bashrc && \
echo export DIR=${MAIN_DIR}/LIBRARIES >> /etc/bashrc && \
echo export I_MPI_CC=icc >> /etc/bashrc && \
echo export I_MPI_CXX=icpc >> /etc/bashrc && \
Expand All @@ -80,8 +94,7 @@ RUN echo export WRF_SRC_ROOT_DIR=${DIR}/WRF >> /etc/bashrc && \
echo export PATH=$PATH:$DIR/grib2 >> /etc/bashrc && \
echo export LD_LIBRARY_PATH=$PHDF5/lib:$PNETCDF/lib:$NETCDF/lib:$LD_LIBRARY_PATH:$DIR/grib2/lib >> /etc/bashrc && \
echo export WRFIO_NCD_LARGE_FILE_SUPPORT=1 >> /etc/bashrc && \
echo export WRF_EM_CORE=1 >> /etc/bashrc && \
echo export KMP_STACKSIZE=512m >> /etc/bashrc
echo export WRF_EM_CORE=1 >> /etc/bashrc

## Install Libraries
WORKDIR $DIR
Expand Down Expand Up @@ -159,7 +172,7 @@ RUN echo export export NETCDF4=1 >> /etc/bashrc
## Install WRF 4.2.2
WORKDIR $MAIN_DIR

ENV LDFLAGS="-lm -lnetcdf -lnetcdff -L${PNETCDF}/lib"
ENV LDFLAGS="-lm -lnetcdff -lnetcdf -L${PNETCDF}/lib"
RUN echo export LDFLAGS="-lm -lnetcdff -L${PNETCDF}/lib" >> /etc/bashrc

### Get WRF v4.2.2 tar archive
Expand All @@ -184,7 +197,7 @@ RUN time ./compile em_real 2>&1 | tee compile_em_real.log

## For development
#TODO: Comment these out for production
RUN apt install -y \
RUN apt-get install -y \
man \
bash-completion \
vim \
Expand Down
20 changes: 0 additions & 20 deletions Docker/docker-build.sh

This file was deleted.

20 changes: 20 additions & 0 deletions Docker/gnu-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# A simple script for building the GNU/OpenMPI version of the container

export BUILD_OUTPUT_FILE=./output_gnu_build.txt
echo "**WRF GNU Docker** Build started, output in ${BUILD_OUTPUT_FILE}"

# Save build output log instead of printing to the screen
#docker build --network=host --tag cornellcac/wrf:4.2.2-gnu - < Dockerfile-GNU 2>&1 > $BUILD_OUTPUT_FILE

# Uncomment below to save build output log AND print to screen
docker build --network=host --tag cornellcac/wrf:4.2.2-gnu - < Dockerfile-GNU 2>&1 | tee $BUILD_OUTPUT_FILE

# Some useful summary output
echo "-------------------------------------------------------------"
echo "Build complete. Check output file for final status. Possible Errors:"
cat $BUILD_OUTPUT_FILE | grep ERROR
cat $BUILD_OUTPUT_FILE | grep Error
echo "-------------------------------------------------------------"
echo "Tail of build output file:"
cat $BUILD_OUTPUT_FILE | tail
20 changes: 20 additions & 0 deletions Docker/intel-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# A simple script for building the Intel (with Intel MPI) container

export BUILD_OUTPUT_FILE=./output_intel_build.txt
echo "**WRF Intel Docker** Build started, output in ${BUILD_OUTPUT_FILE}"

# Save build output log instead of printing to the screen
#docker build --network=host --tag cornellcac/wrf:4.2.2-intel-7415915e0b8e - < Dockerfile-Intel 2>&1 > $BUILD_OUTPUT_FILE

# Uncomment below to save build output log AND print to screen
docker build --network=host --tag cornellcac/wrf:4.2.2-intel-7415915e0b8e - < Dockerfile-Intel 2>&1 | tee $BUILD_OUTPUT_FILE

# Some useful summary output
echo "-------------------------------------------------------------"
echo "Build complete. Check output file for final status. Possible Errors:"
cat $BUILD_OUTPUT_FILE | grep ERROR
cat $BUILD_OUTPUT_FILE | grep Error
echo "-------------------------------------------------------------"
echo "Tail of build output file:"
cat $BUILD_OUTPUT_FILE | tail