Centos system migration CESM2.1.3 solution

Tip: After the article is written, the table of contents can be automatically generated. How to generate it can refer to the help document on the right


1. Environment installation

For the steps before netcdf, please refer to the previous blog post
https://blog.csdn.net/weixin_43934886/article/details/130197311?spm=1001.2014.3001.5501

1. netcdf-4.8.1 installation

It is recommended to install netcdf-C above 4.8.1, fortran version netcdf can choose above 4.5
First download and decompress

wget  https://downloads.unidata.ucar.edu/netcdf-c/4.8.1/src/netcdf-c-4.8.1.tar.gz
tar -zxvf netcdf-c-4.8.1.tar.gz
cd netcdf-c-4.8.1.tar.gz

Next configure it

./configure --prefix=/path/to/NETCDF CPPFLAGS="-I/path/to/HDF5/include" LDFLAGS="-L/path/to/HDF5/lib" --enable-fortran --enable-static=yes --enable-parallel --enable-shared CFLAGS="-O3 -fPIC -Wno-incompatible-pointer-types-discards-qualifiers -Wno-non-literal-conversion" FCFLAGS="-O3 -fPIC" LDFLAGS="-Wl,--build-id" --enable-fortran --enable-netcdf4 --enable-parallel CC=mpicc FC=mpif90 CXX=mpicxx

Compile and install

make && make install

Remember to modify the environment variables after the installation is complete

export PATH=/path/to/NETCDF/bin:$PATH
export LD_LIBRARY_PATH=/path/to/NETCDF/lib:$LD_LIBRARY_PATH

check for success

nc-config --all

The following result should appear

test result

2.netcdf-fortran-4.5.3

Download and decompress first

wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.5.3/netcdf-fortran-4.5.3.tar.gz
tar -zxvf netcdf-fortran-4.5.3.tar.gz
cd  netcdf-fortran-4.5.3

Then configure it

./configure --prefix=/path/to/NETCDF CPPFLAGS="-I/path/to/HDF5/include                 -I/path/to/NETCDF/include" LDFLAGS=" -L/path/to/HDF5/lib -L/path/to/NETCDF/lib -lnetcdf" --enable-fortran --enable-static=yes --enable-parallel --enable-shared CFLAGS="-O3 -fPIC -Wno-incompa                tible-pointer-types-discards-qualifiers -Wno-non-literal-conversion" FCFLAGS="-O3 -fPIC" LDFLAGS="-Wl,--build-id" --en                able-fortran --enable-netcdf4 --enable-parallel CC=mpicc FC=mpif90 CXX=mpicxx F77=mpif77

*Note that you must remember to specify the compiler of F77 as mpif77, and the installation path should be consistent with that of netcdf-C

Compile and install

make && make install

Check to see if the installation was successful

nf-config --all

test result

3.Lapack 3.8.0

download and unzip

wget http://www.netlib.org/lapack/lapack-3.8.0.tar.gz
tar -zxvf lapack-3.8.0.tar.gz
cd lapack-3.8.0

Compile:

   cp make.inc.example make.inc
   make 

Copy the library files to a unified environment directory

cp *.a  /path/to/lapack

4.BLAS

download and unzip

wget http://www.netlib.org/blas/blas-3.8.0.tgz
tar -zxvf blas-3.8.0.tgz
cd blas-3.8.0

Compile:

   cp make.inc.example make.inc
   make 

Copy the library files to a unified environment directory

cp blas_LINUX.a  /path/to/BLAS/libblas.a

2. Example creation and configuration

1. File configuration

Enter the example directory
cd .../my_cesm_sandbox/
There are several files:
File Listenter cime

cd cime

Modify the machine configuration file

vim ./config/cesm/machines/config_machines.xml

Add the following content in the blank space: (the content marked in blue is –mach, which can be customized)

<machine MACH="User">
    <DESC>
      good luck~ 
    </DESC>
    <NODENAME_REGEX>regex.expression.matching.your.machine</NODENAME_REGEX>
    <OS>LINUX</OS>
    <PROXY> https://howto.get.out </PROXY>
    <COMPILERS>pgi</COMPILERS>
    <MPILIBS>openmpi</MPILIBS>
    <PROJECT>none</PROJECT>
    <SAVE_TIMING_DIR> </SAVE_TIMING_DIR>
  <CIME_OUTPUT_ROOT>/path/to/output/CESM/output-2.0/scratch</CIME_OUTPUT_ROOT>
<! -- 这是输出文件目录,包括输出结果,之后标黄的都是 -->
    <DIN_LOC_ROOT>/path/to/input</DIN_LOC_ROOT>
<!-- 这是输入文件目录,主要用于存放需要的输入数据,之后标绿的都是 -->
<DIN_LOC_ROOT_CLMFORC>/CESMroot/CESM/INPUTDAT/inputdata/lmwg</DIN_LOC_ROOT_CLMFORC>
    <DOUT_S_ROOT>/path/to/output/output-2.0/archive/$CASE</DOUT_S_ROOT>
    <BASELINE_ROOT>/path/baseline/cesm_baselines2.0</BASELINE_ROOT>
<CCSM_CPRNC>...../my_cesm_sandbox/cime/tools/cprnc</CCSM_CPRNC>
<!-- 这是性能工具,可有可无 -->
    <GMAKE>make</GMAKE>
    <GMAKE_J>4</GMAKE_J>
    <BATCH_SYSTEM>none</BATCH_SYSTEM>
    <SUPPORTED_BY>xzw~</SUPPORTED_BY>
    <!-- 这是我哈哈哈 -->
    <MAX_TASKS_PER_NODE>8</MAX_TASKS_PER_NODE>
    <MAX_MPITASKS_PER_NODE>8</MAX_MPITASKS_PER_NODE>
    <PROJECT_REQUIRED>FALSE</PROJECT_REQUIRED>
    <mpirun mpilib="default">
      <executable>mpirun</executable>
      <arguments>
        <arg name="ntasks"> -np {
    
    {
    
     total_tasks }} </arg>
      </arguments>
      </mpirun>
      <module_system type="none">
      </module_system>
    <environment_variables>
      <env name="OMP_STACKSIZE">512M</env>
    </environment_variables>
    <resource_limits>
      <resource name="RLIMIT_STACK">-1</resource>
 </resource_limits>
  </machine>

2. Create a calculation example and run it

Enter the scripts directory and create a calculation example

./create_newcase --case Xtest --res f19_g16 --compset X --mach User
cd Xtest

initialization study

./case.setup

After initialization, open Macros.make

Clear the original content and change it to the following content: (The place marked in blue is the directory where you need to pay attention to the software installation)

ifeq ($(COMPILER),gnu)
  CPPDEFS := $(CPPDEFS)  -DFORTRANUNDERSCORE -DNO_R16 -DNO_SHR_VMATH  -DCPRPGI
  FC_AUTO_R8 :=  -fdefault-real-8
  HAS_F2008_CONTIGUOUS := FALSE
  FFLAGS_NOOPT :=  -O0
  LDFLAGS := -Wl,--allow-multiple-definition  -L/path/to/BLAS/lib -lblas
  SUPPORTS_CXX := TRUE
  CFLAGS += -O2 -g
  FFLAGS := -O2 -g -fconvert=big-endian -ffixed-line-length-132 -Kieee -Mextend -byteswapio -Mflushz
  FIXEDFLAGS :=  -Mfixed
  SCC :=  clang
  SFC :=  flang
  MPICC := mpicc
  MPIFC := mpif90
  MPICXX := mpicxx
  FREEFLAGS :=  -Mfreeform
  CXX_LINKER := FORTRAN
  SCXX :=  clang++
  NETCDF_PATH := /path/to/netcdf
endif
ifeq ($(MODEL),pop)
  CPPDEFS := $(CPPDEFS)  -D_USE_FLOW_CONTROL
endif
ifeq ($(COMPILER),gnu)
  ifeq ($(compile_threaded),true)
    FFLAGS := $(FFLAGS)  -mp
    CFLAGS := $(CFLAGS)  -mp
  endif
  ifeq ($(DEBUG),TRUE)
    FFLAGS := $(FFLAGS)  -g   -fbounds-check
    CFLAGS := $(CFLAGS)  -g   -fbounds-check
  endif
  ifeq ($(DEBUG),FALSE)
    FFLAGS := $(FFLAGS)  -O
    CFLAGS := $(CFLAGS)  -O
  endif
  ifeq ($(compile_threaded),true)
    LDFLAGS := $(LDFLAGS)  -mp
  endif
endif

After saving and exiting, submit and compile

./case.build

Wait for the compilation to complete. If there is a problem with the compilation, you need to recompile first. ./case.build --clean-all
After ./case.build
the compilation is completed, it will prompt sucess (as shown in the figure)

CompiledSubmit to run

./case.submit

Wait for the operation to complete (as shown in the figure below)
run successfully


Summarize

The above is the summary of the transplantation method of cesm2.1.3 version. The source code can be directly checked from the official cesm, or downloaded from Baidu Netdisk.
Link: https://pan.baidu.com/s/14unOhxSJKq4MrSnEht_obQ?pwd=h3bc
Code: h3bc
input data will be downloaded automatically after compiling, friends with slow internet speed need to be patient~ If it doesn’t work, download directly from here
Link: https://pan.baidu.com/s/1Kxx-A5xXVoKrc2IL3VA3vw?pwd =b6ez
extraction code: b6ez

Guess you like

Origin blog.csdn.net/weixin_43934886/article/details/130301744