Skip to content

Commit

Permalink
Adds initial dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Sep 23, 2021
1 parent 407a345 commit f2cad7c
Show file tree
Hide file tree
Showing 3 changed files with 345 additions and 0 deletions.
133 changes: 133 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
FROM ubuntu:20.10 as cesm

ENV USER=root
ENV CIME_MODEL=cesm
ENV NETCDF_FORTRAN_VERSION=4.5.2
ENV PNETCDF_VERSION=1.12.1
ENV PATH=/build/local/bin:$PATH

ARG DEBIAN_FRONTEND=noninteractive

WORKDIR /build

RUN apt update && \
apt install -y --no-install-recommends \
python3 \
git \
vim \
build-essential \
gcc-9 \
g++-9 \
gfortran-9 \
openmpi-bin \
libopenmpi-dev \
libcurl4-openssl-dev \
libnetcdf-dev \
netcdf-bin \
libxml2-utils \
pylint \
cmake \
curl \
wget \
subversion \
ca-certificates \
pkg-config && \
rm -rf /var/lib/apt/lists && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 10 && \
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-9 10 && \
curl -L -k -o netcdf-fortran.tar.gz \
https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v${NETCDF_FORTRAN_VERSION}.tar.gz && \
mkdir "${PWD}/netcdf-fortran" && \
tar -xvf "${PWD}/netcdf-fortran.tar.gz" -C "${PWD}/netcdf-fortran" --strip-components=1 && \
cd "${PWD}/netcdf-fortran" && \
./configure --prefix=/build/local && \
make && \
make install && \
curl -L -k -o pnetcdf.tar.gz \
https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz && \
mkdir "${PWD}/pnetcdf" && \
tar -xvf "${PWD}/pnetcdf.tar.gz" -C "${PWD}/pnetcdf" --strip-components=1 && \
cd "${PWD}/pnetcdf" && \
./configure --prefix=/build/local --enable-shared --disable-cxx && \
make && \
make install && \
cd "/build/local/include" && \
ln -sf /usr/include/*netcdf* . && \
cd "/build/local/lib" && \
ln -sf `nc-config --libdir`/lib* .

WORKDIR /root

RUN git clone https://github.com/ESMCI/cime && \
cd cime && \
git clone https://github.com/ESCOMP/CMEPS components/cmeps && \
git clone https://github.com/ESCOMP/CDEPS components/cdeps && \
git clone https://github.com/ESCOMP/CESM_CPL7andDataComps components/cpl7 && \
git clone https://github.com/ESCOMP/CESM_share share/ && \
git clone https://github.com/MCSclimate/MCT libraries/mct && \
git clone https://github.com/NCAR/ParallelIO libraries/parallelio

RUN mkdir ~/.cime

WORKDIR /root/cime/scripts

COPY config_machines.xml /root/cime_config/machines/
COPY config_compilers.xml /root/cime_config/machines/

FROM condaforge/mambaforge:latest AS e3sm

ENV USER=root
ENV CIME_MODEL=e3sm
ENV PNETCDF_VERSION=1.12.1

WORKDIR /root

RUN git clone https://github.com/E3SM-Project/E3SM && \
cd E3SM && \
sed -i"" "s/git@github.com:/https:\/\/github.com\//g" .gitmodules && \
git submodule update --init

RUN mamba install -c conda-forge \
libnetcdf=*=*openmpi* \
netcdf-fortran=*=*openmpi* \
cmake \
make \
wget \
curl \
subversion \
m4 \
gcc_linux-64 \
gxx_linux-64 \
gfortran_linux-64 \
openmpi-mpifort

SHELL ["/bin/bash", "-c"]

RUN curl -L -k -o pnetcdf.tar.gz \
https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz && \
mkdir "${PWD}/pnetcdf" && \
tar -xvf "${PWD}/pnetcdf.tar.gz" -C "${PWD}/pnetcdf" --strip-components=1 && \
cd "${PWD}/pnetcdf" && \
source /opt/conda/etc/profile.d/conda.sh && \
conda activate base && \
./configure --prefix /opt/conda --disable-cxx --enable-shared \
MPICC=/opt/conda/bin/mpicc \
MPICXX=/opt/conda/bin/mpicxx \
MPIF77=/opt/conda/bin/mpif77 \
MPIF90=/opt/conda/bin/mpif90 && \
make -j4 && \
make install

RUN find /root/E3SM -type f -iname Makefile -exec grep -nH '$(AR) $@' {} \; | \
cut -d":" -f1 | \
xargs sed -i'' 's/$(AR) $@/$(AR) rc $@/g'

RUN ln -sf /opt/conda/bin/x86_64-conda-linux-gnu-ar /opt/conda/bin/ar && \
ln -sf /opt/conda/bin/x86_64-conda-linux-gnu-ranlib /opt/conda/bin/ranlib

WORKDIR /root/E3SM/cime/scripts

COPY config_machines.xml /root/.cime/
COPY config_compilers.xml /root/.cime/
130 changes: 130 additions & 0 deletions docker/config_compilers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<config_compilers version="2.0">
<compiler MACH="docker-mamba" COMPILER="gnu-mamba">
<AR>/opt/conda/bin/x86_64-conda-linux-gnu-ar</AR>
<CFLAGS>
<base> -mcmodel=medium </base>
<append compile_threaded="TRUE"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow</append>
<append DEBUG="FALSE"> -O </append>
<append COMP_NAME="csm_share"> -std=c99 </append>
</CFLAGS>
<CXXFLAGS>
<base> -std=c++14 </base>
<append compile_threaded="TRUE"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -fbacktrace </append>
<append DEBUG="FALSE"> -O </append>
</CXXFLAGS>
<CMAKE_OPTS>
<append COMP_NAME="cism"> -D CISM_GNU=ON </append>
<append> -D CMAKE_AR=/opt/conda/bin/x86_64-conda-linux-gnu-ar </append>
<append> -DCMAKE_Fortran_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib </append>
<append> -DCMAKE_C_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib </append>
<append> -DCMAKE_CXX_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib </append>
</CMAKE_OPTS>
<CPPDEFS>
<append> -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU</append>
<append DEBUG="TRUE"> -DYAKL_DEBUG </append>
</CPPDEFS>
<CXX_LIBS>
<base> -lstdc++ </base>
</CXX_LIBS>
<CXX_LINKER>FORTRAN</CXX_LINKER>
<FC_AUTO_R8>
<base> -fdefault-real-8 </base>
</FC_AUTO_R8>
<FFLAGS>
<base> -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none </base>
<append compile_threaded="TRUE"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow</append>
<append DEBUG="FALSE"> -O </append>
</FFLAGS>
<FFLAGS_NOOPT>
<base> -O0 </base>
</FFLAGS_NOOPT>
<FIXEDFLAGS>
<base> -ffixed-form </base>
</FIXEDFLAGS>
<FREEFLAGS>
<base> -ffree-form </base>
</FREEFLAGS>
<HAS_F2008_CONTIGUOUS>FALSE</HAS_F2008_CONTIGUOUS>
<LDFLAGS>
<append compile_threaded="TRUE"> -fopenmp </append>
<append> -L/opt/conda/lib -lnetcdff -lnetcdf </append>
</LDFLAGS>
<MPI_PATH>/opt/conda</MPI_PATH>
<MPICC>/opt/conda/bin/mpicc</MPICC>
<MPICXX>/opt/conda/bin/mpicxx</MPICXX>
<MPIFC>/opt/conda/bin/mpif90</MPIFC>
<NETCDF_C_PATH>/opt/conda</NETCDF_C_PATH>
<NETCDF_FORTRAN_PATH>/opt/conda</NETCDF_FORTRAN_PATH>
<PNETCDF_PATH>/opt/conda</PNETCDF_PATH>
<SCC>/opt/conda/bin/x86_64-conda-linux-gnu-gcc</SCC>
<SCXX>/opt/conda/bin/x86_64-conda-linux-gnu-g++</SCXX>
<SFC>/opt/conda/bin/x86_64-conda-linux-gnu-gfortran</SFC>
<SUPPORTS_CXX>TRUE</SUPPORTS_CXX>
</compiler>
<compiler MACH="docker" COMPILER="gnu">
<CFLAGS>
<base> -mcmodel=medium </base>
<append compile_threaded="TRUE"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow</append>
<append DEBUG="FALSE"> -O </append>
<append COMP_NAME="csm_share"> -std=c99 </append>
</CFLAGS>
<CXXFLAGS>
<base> -std=c++14 </base>
<append compile_threaded="TRUE"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -fbacktrace </append>
<append DEBUG="FALSE"> -O </append>
</CXXFLAGS>
<CMAKE_OPTS>
<append COMP_NAME="cism"> -D CISM_GNU=ON </append>
</CMAKE_OPTS>
<CPPDEFS>
<append> -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU</append>
<append DEBUG="TRUE"> -DYAKL_DEBUG </append>
</CPPDEFS>
<CXX_LIBS>
<base> -lstdc++ </base>
</CXX_LIBS>
<CXX_LINKER>FORTRAN</CXX_LINKER>
<FC_AUTO_R8>
<base> -fdefault-real-8 </base>
</FC_AUTO_R8>
<FFLAGS>
<base> -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none </base>
<append compile_threaded="TRUE"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow</append>
<append DEBUG="FALSE"> -O </append>
</FFLAGS>
<FFLAGS_NOOPT>
<base> -O0 </base>
</FFLAGS_NOOPT>
<FIXEDFLAGS>
<base> -ffixed-form </base>
</FIXEDFLAGS>
<FREEFLAGS>
<base> -ffree-form </base>
</FREEFLAGS>
<HAS_F2008_CONTIGUOUS>FALSE</HAS_F2008_CONTIGUOUS>
<LDFLAGS>
<append compile_threaded="TRUE"> -fopenmp </append>
</LDFLAGS>
<MPICC>mpicc</MPICC>
<MPICXX>mpicxx</MPICXX>
<MPIFC>mpif90</MPIFC>
<NETCDF_C_PATH>$ENV{NETCDF_C_PATH}</NETCDF_C_PATH>
<NETCDF_FORTRAN_PATH>$ENV{NETCDF_FORTRAN_PATH}</NETCDF_FORTRAN_PATH>
<PNETCDF_PATH>$ENV{PNETCDF_PATH}</PNETCDF_PATH>
<SCC>gcc</SCC>
<SCXX>g++</SCXX>
<SFC>gfortran</SFC>
<SLIBS>
<append>$SHELL{$ENV{NETCDF_FORTRAN_PATH}/bin/nf-config --flibs} -Wl,-rpath -Wl,$ENV{NETCDF_C_PATH}/lib</append>
<append>$SHELL{$ENV{NETCDF_C_PATH}/bin/nc-config --libs}</append>
</SLIBS>
<SUPPORTS_CXX>TRUE</SUPPORTS_CXX>
</compiler>
</config_compilers>
82 changes: 82 additions & 0 deletions docker/config_machines.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0"?>

<config_machines version="2.0">
<machine MACH="docker">
<DESC>Docker</DESC>
<NODENAME_REGEX>none</NODENAME_REGEX>
<OS>LINUX</OS>
<PROXY/>
<COMPILERS>gnu</COMPILERS>
<MPILIBS>openmpi</MPILIBS>
<SAVE_TIMING_DIR>/data/cime_testing/scratch/$CASE/timings</SAVE_TIMING_DIR>
<CIME_OUTPUT_ROOT>/data/cime_testing/scratch</CIME_OUTPUT_ROOT>
<DIN_LOC_ROOT>/data/cime_testing/inputdata</DIN_LOC_ROOT>
<DIN_LOC_ROOT_CLMFORC>/data/cime_testing/inputdata-clmforc</DIN_LOC_ROOT_CLMFORC>
<DOUT_S_ROOT>/data/cime_testing/scratch/$CASE/archive</DOUT_S_ROOT>
<BASELINE_ROOT>/data/cime_testing/baselines</BASELINE_ROOT>
<CCSM_CPRNC>/data/cime_testing/tools/cprnc</CCSM_CPRNC>
<GMAKE>make</GMAKE>
<GMAKE_J>8</GMAKE_J>
<TESTS>e3sm_developer</TESTS>
<BATCH_SYSTEM>none</BATCH_SYSTEM>
<SUPPORTED_BY>jasonb5</SUPPORTED_BY>
<MAX_TASKS_PER_NODE>20</MAX_TASKS_PER_NODE>
<MAX_MPITASKS_PER_NODE>20</MAX_MPITASKS_PER_NODE>
<mpirun mpilib="openmpi">
<executable>mpiexec</executable>
<arguments>
<arg name="ntasks"> -n {{ total_tasks }} </arg>
<arg name="oversubscribe"> --oversubscribe </arg>
</arguments>
</mpirun>
<module_system type="none"/>
<RUNDIR>/data/cime_testing/scratch/$CASE/run</RUNDIR>
<EXEROOT>/data/cime_testing/scratch/$CASE/bld</EXEROOT>
<environment_variables>
<env name="OMPI_ALLOW_RUN_AS_ROOT">1</env>
<env name="OMPI_ALLOW_RUN_AS_ROOT_CONFIRM">1</env>
<env name="NETCDF_C_PATH">/build/local</env>
<env name="NETCDF_FORTRAN_PATH">/build/local</env>
<env name="PNETCDF_PATH">/build/local</env>
</environment_variables>
</machine>
<machine MACH="docker-mamba">
<DESC>Docker</DESC>
<NODENAME_REGEX>none</NODENAME_REGEX>
<OS>LINUX</OS>
<PROXY/>
<COMPILERS>gnu-mamba</COMPILERS>
<MPILIBS>openmpi</MPILIBS>
<SAVE_TIMING_DIR>/data/cime_testing/scratch/$CASE/timings</SAVE_TIMING_DIR>
<CIME_OUTPUT_ROOT>/data/cime_testing/scratch</CIME_OUTPUT_ROOT>
<DIN_LOC_ROOT>/data/cime_testing/inputdata</DIN_LOC_ROOT>
<DIN_LOC_ROOT_CLMFORC>/data/cime_testing/inputdata-clmforc</DIN_LOC_ROOT_CLMFORC>
<DOUT_S_ROOT>/data/cime_testing/scratch/$CASE/archive</DOUT_S_ROOT>
<BASELINE_ROOT>/data/cime_testing/baselines</BASELINE_ROOT>
<CCSM_CPRNC>/data/cime_testing/tools/cprnc</CCSM_CPRNC>
<GMAKE>make</GMAKE>
<GMAKE_J>8</GMAKE_J>
<TESTS>e3sm_developer</TESTS>
<BATCH_SYSTEM>none</BATCH_SYSTEM>
<SUPPORTED_BY>jasonb5</SUPPORTED_BY>
<MAX_TASKS_PER_NODE>20</MAX_TASKS_PER_NODE>
<MAX_MPITASKS_PER_NODE>20</MAX_MPITASKS_PER_NODE>
<mpirun mpilib="openmpi">
<executable>mpiexec</executable>
<arguments>
<arg name="ntasks"> -n {{ total_tasks }} </arg>
<arg name="oversubscribe"> --oversubscribe </arg>
</arguments>
</mpirun>
<module_system type="none"/>
<RUNDIR>/data/cime_testing/scratch/$CASE/run</RUNDIR>
<EXEROOT>/data/cime_testing/scratch/$CASE/bld</EXEROOT>
<environment_variables>
<env name="OMPI_ALLOW_RUN_AS_ROOT">1</env>
<env name="OMPI_ALLOW_RUN_AS_ROOT_CONFIRM">1</env>
<env name="NETCDF_C_PATH">/build/local</env>
<env name="NETCDF_FORTRAN_PATH">/build/local</env>
<env name="PNETCDF_PATH">/build/local</env>
</environment_variables>
</machine>
</config_machines>

0 comments on commit f2cad7c

Please sign in to comment.