first commit

This commit is contained in:
baol 2024-06-04 14:20:20 +08:00
commit d1f5c5656c
14 changed files with 389 additions and 0 deletions

0
.gitignore vendored Normal file
View File

123
Dockerfile Normal file
View File

@ -0,0 +1,123 @@
FROM ubuntu:22.04
## CLM5.0
MAINTAINER "SHUD"
WORKDIR /model
ENV DEBIAN_FRONTEND=noninteractive
ENV VERSION_CODENAME=jammy
RUN rm /etc/apt/sources.list \
&& echo "deb [trusted=yes] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${VERSION_CODENAME} main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb [trusted=yes] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${VERSION_CODENAME}-updates main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb [trusted=yes] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${VERSION_CODENAME}-backports main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb [trusted=yes] https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ ${VERSION_CODENAME}-security main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo 'Acquire::https { Verify-Peer "false"; Verify-Host "false"; }' >> /etc/apt/apt.conf.d/tuna.conf
# && echo "deb https://cloud.r-project.org/bin/linux/ubuntu cosmic-cran35/" >> /etc/apt/sources.list
RUN apt-get update \
&& apt install -y --no-install-recommends --assume-yes \
ca-certificates \
dejagnu \
sudo libtool \
vim git subversion gfortran cmake \
libxml2-utils libxml-libxml-perl \
python \
make m4 \
libcurl4-openssl-dev liblapack-dev libblas-dev mpich libmpich-dev \
gnupg wget curl \
&& apt-get clean
ADD pkgs/*.gz /usr/local/src/
ARG ZDIR=/usr/local/zlib
RUN cd /usr/local/src/zlib-1.2.11 \
&& CC=mpicc ./configure --prefix=${ZDIR} \
&& make \
# && make check \
&& make install \
&& rm -rf /usr/local/src/zlib-1.2.11
ENV CC=mpicc \
CXX=mpicxx \
FC=mpif90 \
F77=mpif90
ARG PNDIR=/usr/local/pnetcdf
RUN cd /usr/local/src/pnetcdf-1.11.0 \
&& FC=mpif90 MPICC=mpicc CFLAGS="-fPIC -g -O2" \
./configure --prefix=${PNDIR} --enable-shared --enable-profiling\
&& make \
# && make tests \
# && make check \
# && make ptests \
&& make install \
&& rm -rf /usr/local/src/pnetcdf-1.11.0
# Parallel OpenMPI-HDF5-NetCDF stack
# https://gist.github.com/milancurcic/3a6c1a97a99d291f88cc61dae6621bdf
ARG H5DIR=/usr/local/hdf5
RUN cd /usr/local/src/hdf5-1.10.4 \
&& CC=mpicc FC=mpif90 CFLAGS="-fPIC -w" ./configure --prefix=${H5DIR} \
--with-zlib=${ZDIR} --enable-parallel --enable-hl \
&& make \
# && make check \
&& make install \
&& rm -rf /usr/local/src/hdf5-1.10.4
#--enable-shared --enable-fortran
ARG NCDIR=/usr/local/netcdf4
RUN cd /usr/local/src/netcdf-c-4.6.2 \
&& CC=mpicc CPPFLAGS="-I${PNDIR}/include -I${H5DIR}/include -I${ZDIR}/include" \
LDFLAGS="-L${PNDIR}/lib -L${H5DIR}/lib -L${ZDIR}/lib" \
./configure --prefix=${NCDIR} --enable-parallel-tests \
&& make \
# && make check \
&& make install \
&& rm -rf /usr/local/src/netcdf-c-4.6.2
ARG NFDIR=/usr/local/netcdff4
RUN cd /usr/local/src/netcdf-fortran-4.4.5 \
&& CPPFLAGS=-I${NCDIR}/include LDFLAGS=-L${NCDIR}/lib \
./configure --prefix=${NFDIR} \
&& make \
# && make check \
&& make install \
&& rm -rf /usr/local/src/netcdf-fortran-4.4.5
RUN echo ${NCDIR}/lib > /etc/ld.so.conf.d/netcdf.conf \
&& echo ${NFDIR}/lib >> /etc/ld.so.conf.d/netcdf.conf \
&& echo ${ZDIR}/lib >> /etc/ld.so.conf.d/netcdf.conf \
&& echo ${H5DIR}/lib >> /etc/ld.so.conf.d/netcdf.conf \
&& echo ${PNDIR}/lib >> /etc/ld.so.conf.d/netcdf.conf \
&& ldconfig
ENV USER=clm
RUN useradd -m -G adm,sudo -s /bin/bash $USER \
&& echo "root:root" | chpasswd \
&& echo "clm:clm" | chpasswd \
&& apt-get remove wget -y
RUN git clone -b release-clm5.0 https://github.com/ESCOMP/ctsm \
&& cd ctsm && ./manage_externals/checkout_externals \
&& chown -R clm:clm /model/ctsm \
&& cd ..
VOLUME ["/inputdata"]
ENV PATH="/model/ctsm/cime/scripts:${NCDIR}/bin:${PATH}" \
LANG=C.UTF-8
COPY config/*.xml /home/${USER}/.cime/
COPY config /home/${USER}/cesm/config
COPY run_CLM50_example01.sh /home/${USER}/cesm/
WORKDIR /home/${USER}/cesm
RUN chown -R clm:clm /home /home/${USER} /home/${USER}/.cime /inputdata
# && chmod 755 -R /inputdata /home/${USER}/.cime /home/${USER} \
USER ${USER}
CMD bash

11
README.md Normal file
View File

@ -0,0 +1,11 @@
## container for CLM5.0(Community Land Surface Model)
### Usage
```bash
docker run -it --rm -v /data/cesm/inputdata:/inputdata -v ${PWD}:/home/clm/cesm -e USERID=$UID . bash
```
* Document of CLM5.0:
https://escomp.github.io/ctsm-docs/
https://github.com/ESCOMP/ctsm.

12
bin/findpkg Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# Dongdong Kong
# Find install related packages
for pkg in "$@"
do
echo "====================================================================="
echo $pkg
echo "====================================================================="
# dpkg --listfiles $pkg
dpkg --list | grep $pkg
done

11
bin/pkginfo Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# Dongdong Kong
# Show package detailed info
for pkg in "$@"
do
echo "====================================================================="
echo $pkg
echo "====================================================================="
dpkg --listfiles $pkg
done

135
config/config_compilers.xml Normal file
View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<config_compilers version="2.0">
<!--
========================================================================
This file defines compiler flags for building CESM. General flags are listed first
followed by flags specific to particular operating systems, followed by particular machines.
More general flags are replaced by more specific flags.
Attributes indicate that an if clause should be added to the Macros so that these flags are added
only under the conditions described by the attribute(s).
The env_mach_specific file may set environment variables or load modules which set environment variables
which are then used in the Makefile. For example the NETCDF_PATH on many machines is set by a module.
========================================================================
Serial/MPI compiler specification
========================================================================
SCC and SFC specifies the serial compiler
MPICC and MPICC specifies the mpi compiler
if $MPILIB is set to mpi-serial then
CC = $SCC
FC = $SFC
MPICC = $SCC
MPIFC = $SFC
INC_MPI = $(CIMEROOT)/src/externals/mct/mpi-serial
========================================================================
Options for including C++ code in the build
========================================================================
SUPPORTS_CXX (TRUE/FALSE): Whether we have defined all the necessary
settings for including C++ code in the build for this compiler (or
this compiler/machine combination). See below for a description of the
necessary settings.
The following are required for a compiler to support the inclusion of
C++ code:
SCXX: serial C++ compiler
MPICXX: mpi C++ compiler
CXX_LINKER (CXX/FORTRAN): When C++ code is included in the build, do
we use a C++ or Fortran linker?
In addition, some compilers require additional libraries or link-time
flags, specified via CXX_LIBS or CXX_LDFLAGS, as in the following
examples:
<CXX_LIBS> -L/path/to/directory -lfoo </CXX_LIBS>
or
<CXX_LDFLAGS> -cxxlib </CXX_LDFLAGS>
Note that these libraries or LDFLAGS will be added on the link line,
regardless of whether we are using a C++ or Fortran linker. For
example, if CXX_LINKER=CXX, then the above CXX_LIBS line should
specify extra libraries needed when linking C++ and fortran code using
a C++ linker. If CXX_LINKER=FORTRAN, then the above CXX_LDFLAGS line
should specify extra LDFLAGS needed when linking C++ and fortran code
using a fortran linker.
-->
<!-- Define default values that can be overridden by specific
compilers -->
<compiler COMPILER="gnu" MACH="shudmach">
<CFLAGS>
<base> -std=gnu99 </base>
<append compile_threaded="true"> -fopenmp </append>
<append DEBUG="TRUE"> -g -Wall -Og -fbacktrace -ffpe-trap=invalid,zero,overflow -fcheck=bounds </append>
<append DEBUG="FALSE"> -O </append>
</CFLAGS>
<CPPDEFS>
<!-- http://gcc.gnu.org/onlinedocs/gfortran/ -->
<append> -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU</append>
</CPPDEFS>
<CXX_LINKER>FORTRAN</CXX_LINKER>
<FC_AUTO_R8>
<base> -fdefault-real-8 </base>
</FC_AUTO_R8>
<FFLAGS>
<!-- -ffree-line-length-none and -ffixed-line-length-none need to be in FFLAGS rather than in FIXEDFLAGS/FREEFLAGS
so that these are passed to cmake builds (cmake builds don't use FIXEDFLAGS and FREEFLAGS). -->
<base> -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none </base>
<append compile_threaded="true"> -fopenmp </append>
<!-- Ideally, we would also have 'invalid' in the ffpe-trap list. But at
least with some versions of gfortran (confirmed with 5.4.0, 6.3.0 and
7.1.0), gfortran's isnan (which is called in cime via the
CPRGNU-specific shr_infnan_isnan) causes a floating point exception
when called on a signaling NaN. -->
<append DEBUG="TRUE"> -g -Wall -Og -fbacktrace -ffpe-trap=zero,overflow -fcheck=bounds </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>
<SCC> gcc </SCC>
<SCXX> g++ </SCXX>
<SFC> gfortran </SFC>
<!-- <NETCDF_PATH>/opt/netcdf</NETCDF_PATH> -->
<!-- <PNETCDF_PATH>/opt/pnetcdf</PNETCDF_PATH> -->
<SLIBS>
<append>-L/usr/local/netcdf4/lib -L/usr/local/netcdff4/lib -lnetcdff -lnetcdf</append>
<append>-llapack -lblas</append>
</SLIBS>
<!-- <SLIBS>
<append> -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="mpich"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="mpich2"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="mvapich"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="mvapich2"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="mpt"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="openmpi"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="impi"> -mkl=cluster -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
<append MPILIB="mpi-serial">-mkl -L/usr/lib/x86_64-linux-gnu -lnetcdff -lnetcdf </append>
</SLIBS> -->
<SUPPORTS_CXX>TRUE</SUPPORTS_CXX>
</compiler>
</config_compilers>

View File

@ -0,0 +1,57 @@
<?xml version="1.0"?>
<config_machines version="2.0">
<machine MACH="shudmach">
<DESC>
Example port to centos7 linux system with gcc, netcdf, pnetcdf and mpich
using modules from http://www.admin-magazine.com/HPC/Articles/Environment-
Modules
</DESC>
<NODENAME_REGEX>.*</NODENAME_REGEX>
<OS>LINUX</OS>
<!--<PROXY> http://172.17.0.1:1081 </PROXY>-->
<COMPILERS>gnu</COMPILERS>
<MPILIBS>mpich</MPILIBS>
<PROJECT>none</PROJECT>
<SAVE_TIMING_DIR>$ENV{HOME}/cesm</SAVE_TIMING_DIR>
<CIME_OUTPUT_ROOT>$ENV{HOME}/cesm</CIME_OUTPUT_ROOT>
<DIN_LOC_ROOT>/inputdata</DIN_LOC_ROOT>
<DIN_LOC_ROOT_CLMFORC>/inputdata/atm/datm7</DIN_LOC_ROOT_CLMFORC>
<DOUT_S_ROOT>$ENV{HOME}/cesm/$CASE/archive</DOUT_S_ROOT>
<BASELINE_ROOT>$ENV{HOME}/cesm/cesm_baselines</BASELINE_ROOT>
<CCSM_CPRNC>$ENV{HOME}/cesm/cprnc</CCSM_CPRNC>
<GMAKE>make</GMAKE>
<GMAKE_J>2</GMAKE_J>
<BATCH_SYSTEM>none</BATCH_SYSTEM>
<SUPPORTED_BY>admin@shud.xyz</SUPPORTED_BY>
<MAX_TASKS_PER_NODE>2</MAX_TASKS_PER_NODE>
<MAX_MPITASKS_PER_NODE>2</MAX_MPITASKS_PER_NODE>
<PROJECT_REQUIRED>FALSE</PROJECT_REQUIRED>
<mpirun mpilib="mpich">
<executable>mpirun</executable>
<arguments>
<arg name="ntasks"> -np {{ total_tasks }} </arg>
</arguments>
</mpirun>
<module_system type="none" />
<environment_variables>
<!-- <env name="HOME">/mnt/d/Github/model</env> -->
<!-- <env name="OMP_STACKSIZE">256M</env> -->
<env name="NETCDF_C_PATH">/usr/local/netcdf4</env>
<env name="NETCDF_FORTRAN_PATH">/usr/local/netcdff4</env>
<!-- <env name="NetCDF_Fortran_LIBRARY">$ENV{NETCDF_PATH}/lib</env> -->
<env name="PNETCDF_PATH">/usr/local/pnetcdf</env>
<!-- <env name="PnetCDF_Fortran_LIBRARY">/usr/local/pnetcdf/lib</env> -->
<!-- <env name="NetCDF_C_LIBRARY">$ENV{NETCDF_PATH}/lib</env>
<env name="NetCDF_C_INCLUDE_DIR">$ENV{NETCDF_PATH}/include</env>
<env name="NetCDF_Fortran_INCLUDE_DIR">$ENV{NETCDF_PATH}/include</env> -->
</environment_variables>
<resource_limits>
<resource name="RLIMIT_STACK">-1</resource>
</resource_limits>
</machine>
<!-- <default_run_suffix>
<default_run_exe>${EXEROOT}/cesm.exe </default_run_exe>
<default_run_misc_suffix> >> cesm.log.$LID 2>&amp;1
</default_run_misc_suffix>
</default_run_suffix> -->
</config_machines>

BIN
pkgs/hdf5-1.10.4.tar.gz Normal file

Binary file not shown.

BIN
pkgs/netcdf-c-4.6.2.tar.gz Normal file

Binary file not shown.

Binary file not shown.

BIN
pkgs/pio2_3_1.tar.gz Normal file

Binary file not shown.

BIN
pkgs/pnetcdf-1.11.0.tar.gz Normal file

Binary file not shown.

BIN
pkgs/zlib-1.2.11.tar.gz Normal file

Binary file not shown.

40
run_CLM50_example01.sh Normal file
View File

@ -0,0 +1,40 @@
# /bin/bash
## initial project
# git clone https://github.com/ESCOMP/cesm
# git clone https://github.com/ESCOMP/ctsm
casename=year2019 # test
dir_cime=/model/ctsm/cime
## 1. create_newcase
${dir_cime}/scripts/create_newcase --case $casename --res f19_g16 --compset I1850Clm50Bgc --run-unsupported \
--compiler gnu --mach shudmach
cd $casename # year2019
# # setup YR_START and YR_END
# ./xmlchange DATM_CLMNCEP_YR_START=2000,DATM_CLMNCEP_YR_END=2000
# ./xmlchange NTASKS=2
## CLM5 configure
# ROOT_INPUT=/inputdata # ${HOME}/cesm
# ROOT_CLMFORC=${ROOT_INPUT}/atm/datm7 # lmwg #
./xmlquery DATM_CLMNCEP_YR_START,DATM_CLMNCEP_YR_END
./xmlchange DATM_CLMNCEP_YR_START=2010,DATM_CLMNCEP_YR_END=2010
./xmlquery NTASKS
./xmlchange NTASKS=2 #[核心数]
./xmlquery DIN_LOC_ROOT,DIN_LOC_ROOT_CLMFORC
./xmlchange DIN_LOC_ROOT=${ROOT_INPUT},DIN_LOC_ROOT_CLMFORC=${ROOT_CLMFORC}
./xmlquery STOP_N
./xmlquery STOP_OPTION
./xmlchange STOP_N=14,STOP_OPTION=ndays
## build and submit task
./case.setup
./case.build
./case.submit