Skip to content

Commit

Permalink
Adds container definition files and README to the repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-robinson committed May 26, 2021
1 parent e9a0672 commit c624f00
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 1 deletion.
18 changes: 18 additions & 0 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM thomasrobinson/centos7-netcdff:4.5.3-c4.7.4-gcc-mpich-slurm
## Dockerfile used to create ESM4

## Set up spack
RUN . /opt/spack/share/spack/setup-env.sh
## Make the ESM4 directory
RUN mkdir -p /opt/ESM4
## Build the ESM4 from github
RUN git clone --recursive https://github.com/NOAA-GFDL/ESM4.git -b 2021.02 \
&& cd ESM4/exec \
&& make gcc=on HDF_INCLUDE=-I/opt/hdf5/include SH=sh CLUBB=off \
&& cp esm4.1.x /opt/ESM4 \
&& make clean_all
## Add the ESM4 executable to the path
ENV PATH=/opt/ESM4/:${PATH}
## Add permissions to the ESM4
RUN chmod 777 /opt/ESM4/esm4.1.x

18 changes: 18 additions & 0 deletions containers/Dockerfile.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM thomasrobinson/centos7-netcdff:4.5.3-c4.7.4-gcc-mpich-slurm
## Dockerfile used to create ESM4

## Set up spack
RUN . /opt/spack/share/spack/setup-env.sh
## Make the ESM4 directory
RUN mkdir -p /opt/ESM4
## Build the ESM4 from github
RUN git clone --recursive https://github.com/NOAA-GFDL/ESM4.git -b 2021.02 \
&& cd ESM4/exec \
&& make gcc=on HDF_INCLUDE=-I/opt/hdf5/include SH=sh CLUBB=off \
&& cp esm4.1.x /opt/ESM4 \
&& make clean_all
## Add the ESM4 executable to the path
ENV PATH=/opt/ESM4/:${PATH}
## Add permissions to the ESM4
RUN chmod 777 /opt/ESM4/esm4.1.x

123 changes: 123 additions & 0 deletions containers/Dockerfile.intel_sources
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
FROM intel/oneapi-hpckit:2021.2-devel-centos8 as builder
LABEL maintainer "Tom Robinson"

#-------------------------------------------------------------
## Set up packages needed
RUN yum update -y
RUN yum install -y git
RUN yum install -y patch
RUN yum install -y zlib
RUN yum install -y wget
RUN yum install -y curl
RUN yum install -y m4

## Set compilers
ENV FC=ifort
ENV CC=icc
ENV build=/opt
ENV IO_LIBS=${build}/io_libs
## Build zlib and szip and curl
RUN cd $build \
&& zlib="zlib-1.2.11" \
&& rm -rf zlib* \
&& wget http://www.zlib.net/zlib-1.2.11.tar.gz \
&& tar xzf zlib-1.2.11.tar.gz \
&& cd $zlib \
&& ./configure --prefix=${IO_LIBS} \
&& make \
&& make -j 20 install
ENV CC "icc -fPIC"
RUN cd $build \
&& szip="szip-2.1.1" \
&& rm -rf szip* \
&& wget https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz \
&& tar xzf szip-2.1.1.tar.gz \
&& cd $szip \
&& ./configure FC=ifort CC=icc --prefix=${IO_LIBS} CPPDEFS="-fPIC" \
&& make \
&& make -j 20 install
RUN cd $build \
&& curl="curl-7.74.0" \
&& rm -rf curl* \
&& wget https://curl.haxx.se/download/${curl}.tar.gz \
&& tar xzf ${curl}.tar.gz \
&& cd $curl \
&& ./configure FC=ifort CC=icc --prefix=${IO_LIBS} \
&& make \
&& make -j 20 install

ENV LD_LIBRARY_PATH=${IO_LIBS}/lib:${LD_LIBRARY_PATH}:/opt/io_libs/lib

## Set compilers
ENV FC=ifort
ENV CC=icc
## Install HDF5
RUN cd /opt \
&& hdf5="hdf5-1.12.0" \
&& wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/${hdf5}/src/${hdf5}.tar.gz \
&& tar xzf ${hdf5}.tar.gz \
&& cd $hdf5 \
&& hdf5_opts="FC=ifort CC=icc --prefix=/opt/hdf5 --enable-fortran --enable-hl" \
&& ./configure $hdf5_opts \
&& make -j 20 install \
&& echo "HDF5 finished building"

#*********************
## Install NetCDF-C
#*********************
ENV LD_LIBRARY_PATH=/opt/hdf5/lib:${LD_LIBRARY_PATH}
RUN cd /opt \
&& version="4.7.4" \
&& netcdfc="netcdf-c-"${version} \
&& rm -rf netcdf \
&& wget -O ${netcdfc}.tar.gz https://github.com/Unidata/netcdf-c/archive/v${version}.tar.gz \
&& tar xzf ${netcdfc}.tar.gz \
&& cd $netcdfc \
&& ./configure --prefix=/opt/netcdf-c CPPFLAGS='-I/opt/hdf5/include -I${IO_LIBS}/include' LDFLAGS='-L/opt/hdf5/lib -L${IO_LIBS}/lib' --disable-dap \
&& make \
&& make -j 20 install \
&& echo " NetCDF-C finished building"

ENV LD_LIBRARY_PATH=/opt/netcdf-c/lib:${LD_LIBRARY_PATH}
ENV PATH=/opt/netcdf-c/bin:${PATH}

## Install netcdf fortran
ENV LDFLAGS="-L/opt/netcdf-c/lib -lnetcdf"
RUN cd /opt \
&& nfversion=4.5.3 \
&& netcdff="netcdf-fortran-${nfversion}" \
&& rm -rf $netcdff \
&& wget -O ${netcdff}.tar.gz https://github.com/Unidata/netcdf-fortran/archive/v${nfversion}.tar.gz \
&& tar xzf ${netcdff}.tar.gz \
&& cd $netcdff \
&& ./configure CPPFLAGS="-I/opt/netcdf-c/include -I/opt/hdf5/include/" --prefix=/opt/netcdf-fortran \
&& make \
&& make -j20 install

ENV PATH=/opt/netcdf-fortran/bin:${PATH}

ENV LD_LIBRARY_PATH=/opt/netcdf-c/lib:/opt/hdf5/lib:/opt/netcdf-fortran/lib:${LD_LIBRARY_PATH}
ENV LIBRARY_PATH=${LD_LIBRARY_PATH}

## Build the model
RUN mkdir -p /opt/ESM4
RUN git clone --recursive https://github.com/NOAA-GFDL/ESM4.git -b 2021.02 \
&& cd ESM4/exec \
&& make HDF_INCLUDE=-I/opt/hdf5/include \
&& cp esm4.1.x /opt/ESM4 \
&& make clean_all

##############################################################################################################
# Stage 2 with the minimum
FROM intel/oneapi-runtime:centos8
RUN ls
COPY --from=builder /opt/netcdf-c /opt/netcdf-c
COPY --from=builder /opt/netcdf-fortran /opt/netcdf-fortran
COPY --from=builder /opt/hdf5 /opt/hdf5
COPY --from=builder /opt/ESM4 /opt/ESM4
ENV PATH=/opt/ESM4:/opt/netcdf-fortran/bin:/opt/netcdf-c/bin:${PATH}
ENV LD_LIBRARY_PATH=/opt/netcdf-c/lib:/opt/hdf5/lib:/opt/netcdf-fortran/lib:/opt/io_libs/lib${LD_LIBRARY_PATH}
ENV LIBRARY_PATH=${LD_LIBRARY_PATH}
## Add permissions to the ESM4
RUN chmod 777 /opt/ESM4/esm4.1.x

39 changes: 39 additions & 0 deletions containers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ESM4 containers
This is a very basic *0.1* version of a README for these containers. Please feel free to
add to it or open a GitHub issue if there is something missing.

## Building with Docker
The Dockerfiles are set up to build an ESM4 run using Docker. There are two Dockerfiles,
one to build with intel oneAPI 2021.2 and one to build with GCC 10.2.0

## Building with Singularity
The Singularity definition files are included to build using intel oneAPI 2021.2 compilers.
You can build using the singularity_build.sh script
```bash
./singularity_build.sh
```

## Running using singularity
The containers are all using mpich-compatible MPI, so if you run using singularity bind
or hybrid methods, make sure you are using some flavor of mpich and not openmpi.

## Disclaimer

The United States Department of Commerce (DOC) GitHub project code is
provided on an 'as is' basis and the user assumes responsibility for
its use. DOC has relinquished control of the information and no
longer has responsibility to protect the integrity, confidentiality,
or availability of the information. Any claims against the Department
of Commerce stemming from the use of its GitHub project will be
governed by all applicable Federal law. Any reference to specific
commercial products, processes, or services by service mark,
trademark, manufacturer, or otherwise, does not constitute or imply
their endorsement, recommendation or favoring by the Department of
Commerce. The Department of Commerce seal and logo, or the seal and
logo of a DOC bureau, shall not be used in any manner to imply
endorsement of any commercial product or activity by DOC or the United
States Government.

This project code is made available through GitHub but is managed by
NOAA-GFDL at https://gitlab.gfdl.noaa.gov.

2 changes: 1 addition & 1 deletion containers/Singularity.esm4
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stage: build
# Install all the required software
. /opt/spack/share/spack/setup-env.sh
# Install ESM4
git clone --recursive -b 2021.01 https://github.com/NOAA-GFDL/ESM4.git && cd ESM4/exec
git clone --recursive -b 2021.02 https://github.com/NOAA-GFDL/ESM4.git && cd ESM4/exec
make gcc=on OPENMP=on SH=sh CLUBB=off
mkdir -p /opt/ESM4
cp esm4.1.x /opt/ESM4
Expand Down
39 changes: 39 additions & 0 deletions containers/Singularity.intel_esm4
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Bootstrap: localimage
From: intel_netcdf_ubuntu.sif
Stage: build
## Singularity def file used to create ESM4

%post
cd /opt
## Build the ESM4 from github
git clone --recursive https://github.com/NOAA-GFDL/ESM4.git -b 2021.02
cd ESM4/exec
make -j 20 HDF_INCLUDE=-I/opt/hdf5/include HDF_LIBS="-L/opt/hdf5/lib -lhdf5 -lhdf5_fortran -lhdf5_hl -lhdf5hl_fortran" SH=sh
cp esm4.1.x /opt/ESM4
make clean_all
chmod 777 /opt/ESM4/esm4.1.x


Bootstrap: docker
From: intel/oneapi-runtime:ubuntu18.04
Stage: final

%files from build
/opt/hdf5
/opt/netcdf-c
/opt/netcdf-fortran
/opt/ESM4/esm4.1.x
## Add the ESM4 executable to the path
%environment
PATH=/opt/ESM4:/opt/netcdf-c/bin:/opt/netcdf-fortran/bin:${PATH}
LD_LIBRARY_PATH=/opt/netcdf-c/lib:/opt/netcdf-fortran/lib:/opt/hdf5/lib:/opt/intel/oneapi/lib:/opt/intel/oneapi/lib/intel64/:/opt/intel/oneapi/lib/intel64/lib:/opt/intel/oneapi/lib/intel64/libfabric:${LD_LIBRARY_PATH}
export LIBRARY_PATH=/opt/netcdf-c/lib:/opt/netcdf-fortran/lib:/opt/hdf5/lib:/opt/intel/oneapi/lib:/opt/intel/oneapi/lib/intel64/:/opt/intel/oneapi/lib/intel64/lib:/opt/intel/oneapi/lib/intel64/libfabric
export KMP_STACKSIZE=512m
export NC_BLKSZ=1M
export F_UFMTENDIAN=big

## Run ESM4
%runscript
ulimit -s unlimited
/opt/ESM4/esm4.1.x

113 changes: 113 additions & 0 deletions containers/Singularity.intel_netcdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Bootstrap: docker
From: intel/oneapi-hpckit:devel-ubuntu18.04
Stage: build

%post
## Set up oneAPI
apt-get -yqq update
apt-get -yqq upgrade
apt-get -yqq install git make
apt-get -yqq install wget
apt-get -yqq install m4
# use wget to fetch the Intel repository public key
# cd /tmp
# wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
## add to your apt sources keyring so that archives signed with this key will be trusted.
# apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
## remove the public key
# rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
# echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list
# apt update -y
# apt install -y intel-basekit intel-hpckit
##
FC=ifort
CC=icc

build=/opt
IO_LIBS=${build}/io_libs
## Build zlib and szip and curl
cd $build
zlib="zlib-1.2.11"
rm -rf zlib*
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar xzf zlib-1.2.11.tar.gz
cd $zlib
./configure --prefix=${IO_LIBS}
make
make -j 20 install
# CC "icc -fPIC"
cd $build
szip="szip-2.1.1"
rm -rf szip*
wget https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz
tar xzf szip-2.1.1.tar.gz
cd $szip
./configure FC=ifort CC=icc --prefix=${IO_LIBS} CPPDEFS="-fPIC"
make
make -j 20 install
cd $build
curl="curl-7.74.0"
rm -rf curl*
wget https://curl.haxx.se/download/${curl}.tar.gz
tar xzf ${curl}.tar.gz
cd $curl
./configure FC=ifort CC=icc --prefix=${IO_LIBS}
make
make -j 20 install

LD_LIBRARY_PATH=${IO_LIBS}/lib:${LD_LIBRARY_PATH}:/opt/io_libs/lib
#*********************
## Install hdf5 with fortran
#*********************
cd /opt
hdf5="hdf5-1.12.0"
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/${hdf5}/src/${hdf5}.tar.gz
tar xzf ${hdf5}.tar.gz
cd $hdf5
hdf5_opts="FC=ifort CC=icc LDFLAGS=-L/opt/io_libs/lib --prefix=/opt/hdf5 --enable-fortran --enable-hl --with-zlib=/opt/io_libs/lib"
./configure FC=ifort CC=icc LDFLAGS='-L/opt/io_libs/lib -lz' --prefix=/opt/hdf5 --enable-fortran --enable-hl --with-zlib=/opt/io_libs --with-szib=/opt/io_libs
make -j 20 install
echo "HDF5 finished building"

#*********************
## Install NetCDF-C
#*********************
LD_LIBRARY_PATH=/opt/hdf5/lib:${LD_LIBRARY_PATH}
cd /opt
version="4.7.4"
netcdfc="netcdf-c-"${version}
rm -rf netcdf
wget -O ${netcdfc}.tar.gz https://github.com/Unidata/netcdf-c/archive/v${version}.tar.gz
tar xzf ${netcdfc}.tar.gz
cd $netcdfc
./configure --prefix=/opt/netcdf-c CPPFLAGS='-I/opt/hdf5/include -I${IO_LIBS}/include' LDFLAGS='-L/opt/hdf5/lib -L/opt/io_libs/lib -lz' --disable-dap
make
make -j 20 install
echo " NetCDF-C finished building"

LD_LIBRARY_PATH=/opt/netcdf-c/lib:${LD_LIBRARY_PATH}
PATH=/opt/netcdf-c/bin:${PATH}

## Install netcdf fortran
LDFLAGS="-L/opt/netcdf-c/lib -lnetcdf"
LIBS="-L/opt/netcdf-c/lib -lnetcdf"
cd /opt
nfversion=4.5.3
netcdff="netcdf-fortran-${nfversion}"
rm -rf $netcdff
wget -O ${netcdff}.tar.gz https://github.com/Unidata/netcdf-fortran/archive/v${nfversion}.tar.gz
tar xzf ${netcdff}.tar.gz
cd $netcdff
./configure CPPFLAGS="-I/opt/netcdf-c/include -I/opt/hdf5/include/" LDFLAGS="-L/opt/netcdf-c/lib -lnetcdf" --prefix=/opt/netcdf-fortran
make
make -j20 install

PATH=/opt/netcdf-fortran/bin:${PATH}

LD_LIBRARY_PATH=/opt/netcdf-c/lib:/opt/hdf5/lib:/opt/netcdf-fortran/lib:${LD_LIBRARY_PATH}
LIBRARY_PATH=${LD_LIBRARY_PATH}


%environment
PATH=/opt/netcdf-fortran/bin:/opt/netcdf-c/bin:/opt/intel/oneapi/mpi/latest/bin:/opt/intel/oneapi/compiler/latest/linux/bin/intel64:${PATH}
LD_LIBRARY_PATH=/opt/netcdf-c/lib:/opt/hdf5/lib:/opt/netcdf-fortran/lib:/opt/io_libs/lib:${LD_LIBRARY_PATH}
4 changes: 4 additions & 0 deletions containers/singularity_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

singularity build -f intel_netcdf_ubuntu.sif Singularity.intel_netcdf
singularity build -f esm4_2021.02_ubuntu_intel.sif Singularity.intel_esm4

0 comments on commit c624f00

Please sign in to comment.