diff --git a/dockerfile/cime_config/config_compilers.xml b/dockerfile/cime_config/config_compilers.xml new file mode 100644 index 0000000..c701d7e --- /dev/null +++ b/dockerfile/cime_config/config_compilers.xml @@ -0,0 +1,15 @@ + + + + /usr + /usr + /usr + + -I/usr/lib64/gfortran/modules + + + -llapack -lblas + -lnetcdf -lnetcdff + + + \ No newline at end of file diff --git a/dockerfile/cime_config/config_machines.xml b/dockerfile/cime_config/config_machines.xml new file mode 100644 index 0000000..fe1cd09 --- /dev/null +++ b/dockerfile/cime_config/config_machines.xml @@ -0,0 +1,24 @@ + + + + + clmu container + clmu-app.* + LINUX + gnu + mpi-serial + $ENV{CESMDATAROOT}/CaseOutputs + $ENV{CESMDATAROOT}/inputdata + $ENV{CESMDATAROOT}/inputdata/atm/datm7 + $ENV{CESMDATAROOT}/Archive + $ENV{CESMDATAROOT}/BaselineTests + $CCSMROOT/tools/cprnc/build/cprnc + make + 32 + none + The_Uinversity_of_Manchester + 32 + 32 + + + \ No newline at end of file diff --git a/dockerfile/dockerfile b/dockerfile/dockerfile new file mode 100644 index 0000000..81fe712 --- /dev/null +++ b/dockerfile/dockerfile @@ -0,0 +1,77 @@ +# escape=` +FROM fedora:31 + +# This dockerfile is partly reference from https://github.com/HPSCTerrSys/dockerfiles/blob/master/clm5/Dockerfile + +# note: svn <=1.1 is not installed in this image, but is required for CESM installation +LABEL ` + org.label-schema.schema-version="1.0" ` + org.label-schema.name="clmu-app" ` + org.label-schema.version="1" ` + org.label-schema.build-date="20240202" ` + clm.version.major="5.0" ` + clm.env.compiler="GCC" ` + clm.env.compiler.version="9.3.1" ` + clm.env.cmake.version="3.18" ` + clm.env.netcdf-c.version="4.7.0-2" ` + clm.env.netcdf-fortran.version="4.5.2-3" ` + clm.env.python.version="3.7.9" ` + clm.env.svn.version="1.12" ` + clm.os.version="Fedora 31" + +# Import cime config +COPY cime_config/* /root/.cime/ + +# Install required packages from base repo + +RUN dnf update -y ` + && yum install dnf-plugins-core -y ` + && dnf group install -y "Development Tools" ` + && dnf install -y glibc-langpack-en libcurl-devel git wget autoconf perl-App-cpanminus ` + && dnf install -y hdf5-devel lapack-devel ncl nco netcdf-devel netcdf-fortran netcdf-fortran-devel openssl-devel` + && dnf clean all ` + && cpanm bigint && cpanm XML::LibXML + +# Install CMake +RUN mkdir -vp /tmp/download ` + && cd /tmp/download ` + && wget -c https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4.tar.gz ` + && tar zxf cmake-3.18.4.tar.gz && cd cmake-3.18.4 ` + && ./bootstrap && make && make install ` + ` +# Clean files + && cd /tmp && rm -rf /tmp/download + +# Add user account +WORKDIR /home + +RUN groupadd -g 1555 clmu-app ` + && sudo usermod -aG clmu-app root ` + ` +# Set compiler and library paths for CLM5 + && echo "" >> /root/.bashrc ` + && echo "# Set compiler and library paths for CLM5" >> /root/.bashrc ` + && echo "source /etc/profile.d/ncarg.sh" >> /root/.bashrc ` + ` +# Set CLM5 environment variables + && echo "" >> /root/.bashrc ` + && echo "# CLM5 environment variables" >> /root/.bashrc ` + && echo "" >> /root/.bashrc ` + && echo "export PROJECT=/p/project" >> /root/.bashrc ` + && echo "export SCRATCH=/p/scratch" >> /root/.bashrc ` + && echo "export CESMDATAROOT=/p/scratch/CESMDATAROOT" >> /root/.bashrc ` + && echo "export CSMDATA=$CESMDATAROOT/inputdata" >> /root/.bashrc ` + && echo "export CASESCRIPT=/p/project/clm5.0/cime/scripts" >> /root/.bashrc ` +# Set usr account + && echo "export USER=root" >> /root/.bashrc + +# case and inputdata dir +RUN mkdir -vp /p/project /p/scratch/CESMDATAROOT/inputdata/ForcingData p/pyscripts ` + && cd /p/project ` + && git clone -b release-clm5.0 https://github.com/ESCOMP/CTSM.git clm5.0 ` + && cd clm5.0 ` + && ./manage_externals/checkout_externals + +USER root +WORKDIR /root +CMD ["/bin/bash","-l"] \ No newline at end of file diff --git a/dockerfile/readme.md b/dockerfile/readme.md new file mode 100644 index 0000000..9576404 --- /dev/null +++ b/dockerfile/readme.md @@ -0,0 +1,78 @@ +# 1 installation CTSM-ENV-IMGANE +Junjie Yu, 2023-11-28, Manchester, UK + +``` +# into the work dir +cd to current dir with a dockerfile and cime_config +docker build -t clmu-app:1 . +``` + +``` +# case and inputdata dir +mkdir -vp p/project p/scratch/CESMDATAROOT/inputdata/ForcingData p/pyscripts +``` + +# 2 biuld container + +``` +docker run --hostname clmu-app --name clmu -it clmu-app:1.0 +``` + +# 3 install CTSM or CLM5.0 +``` +# in docker containls +cd /p/project +git clone -b release-clm5.0 https://github.com/ESCOMP/CTSM.git myclm +cd myclm +./manage_externals/checkout_externals +``` + +# [key notes for seting config_manchine.xml](https://bb.cgd.ucar.edu/cesm/threads/issue-installing-on-centos-8-with-slurm-and-lmod.5884/#post-39110) +The reference set it wrong. + +***This is the corret version*** +You have defined it here... + +common/contrib/cesm/inputdata/lmwg + +Change it so that it points to this... + +$DIN_LOC_ROOT/atm/datm7 + +that should then get the paths to line up so it can download the data. As we talk about in the first link I share above I recommend that you only download the forcing data a few years at a time. It's likely going to take days to download and as such you don't want to do it all once. + + +# 4 Singularity + +Singularity provides a mechanism to run containers where containers can be used to package entire scientific workflows, software and libraries, and even data. +Ref: https://ri.itservices.manchester.ac.uk/csf3/software/applications/singularity/ + +Using Singularity from docker image + +``` +# save image as tar file +docker save -o ~/docker/clm5docker.tar clm5docker:1 +# transport tar file +scp ~/docker/clm5docker.tar ... +# biuld image form tar +singularity build clm5docker.sif docker-archive://clm5docker.tar +scp /Users/user/Documents/GitHub/DRL_urban_climate_adaptation/2_CTSM_container/dockerfile/cime_config/config_machines.xml z47137jy@csf3.itservices.manchester.ac.uk:~/.cime +scp /Users/user/Documents/GitHub/DRL_urban_climate_adaptation/2_CTSM_container/dockerfile/cime_config/config_compilers.xml z47137jy@csf3.itservices.manchester.ac.uk:~/.cime +mkdir -vp p/project p/scratch/CESMDATAROOT/inputdata + +singularity run --hostname clm5-docker -B "$(pwd)"/p:/p clm5docker.sif # do not change hostname, either need to change cime.config file + +singularity run --net --network=none --hostname clm5-docker -B "$(pwd)"/p:/p clm5docker.sif + +# then in singularity, as singularity are not same as +# CLM5 environment variables + +export PROJECT=/p/project +export SCRATCH=/p/scratch +export BUDGET_ACCOUNTS=slts +export CESMDATAROOT=/p/scratch/CESMDATAROOT +export CSMDATA=/p/scratch/CESMDATAROOT/inputdata +export CASESCRIPT=/p/project/myclm/cime/scripts +export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 +export OMPI_ALLOW_RUN_AS_ROOT=1 +``` \ No newline at end of file