CESM2环境搭建

该博客详细记录了在Linux环境下配置CESM2所需的各种软件包和库的过程,包括安装LAPACK、BLAS、mpich、subversion、python、git、netcdf、pnetcdf、gcc、icc、cmake和make等。遇到的问题和解决办法也被详尽地阐述,涉及到版本选择、源码编译、依赖关系和环境变量设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文章目录


目的:在学院超算上安装CESM2.1.3

1. 学院服务器自带

perl 5.26

cmake-2.8.12 gmake-3.8.1

gmake = GNU make = make

(base) [19fush@login sources]$ perl --version

This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

(base) [19fush@login sources]$ which perl
/usr/bin/perl
(base) [19fush@login sources]$ 

在这里插入图片描述
在这里插入图片描述

拷贝源码

前提条件

  • svn
  • git

downloading from Github

在这里插入图片描述

ERROR: subprocess call to  'svn' has exceeded timeout limit of 300 seconds. 
Timout errors typically occur when svn or git requires authentication to access a private repository. 
On some systems, svn and git requests for authentication information will not be displayed to the user.  
In this case, the program will appear to hang and generate a timeout error. 
Ensure you can run svn and git manually and access all repositories without entering your authentication information.

在这里插入图片描述

(python27) [xiaxsh3@login my_cesm_sandbox]$ svn ls https://svn-ccsm-models.cgd.ucar.edu/ww3/release_tags
Error validating server certificate for 'https://svn-ccsm-models.cgd.ucar.edu:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: *.cgd.ucar.edu
 - Valid: from Nov 18 00:00:00 2019 GMT until Nov 17 23:59:59 2021 GMT
 - Issuer: InCommon RSA Server CA, InCommon, Internet2, Ann Arbor, MI, US
 - Fingerprint: 1A:41:6E:31:C5:F7:99:DD:B7:72:CC:C6:30:B9:E1:C7:90:82:D3:C8
(R)eject, accept (t)emporarily or accept (p)ermanently? p
ww3_cesm2_0_rel_01/
ww3_cesm2_1_rel01/
ww3_cesm2_1_rel_01/

安装LAPACK和BLAS

1. install LAPACK and BLAS libraries

参考: https://www.jianshu.com/p/fe6c4f42aa0b

切换到sources目录下操作

cd ~/sources

1.1 安装BLAS

1、准备源码

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

2、编译

如果是32位系统,使用GNU的g77或gfortran编译器来编译:

g77 -O2 -fno-second-underscore -c *.f
gfortran -O2 -std=legacy -fno-second-underscore -c *.f

如果是64位系统,使用GNU的g77或gfortran编译器来编译:

g77 -O3 -m64 -fno-second-underscore -fPIC -c *.f
gfortran -O3 -std=legacy -m64 -fno-second-underscore -fPIC -c *.f   # 本次采用 gfortran --version

如果使用的是Intel的Fortran编译器,则:

ifort -FI -w90 -w95 -cm -O3 -unroll -c *.f

注意:

  • 请根据情况选择上述5个命令中的一个执行
  • 在编译BLAS、LAPACK、NumPy和SciPy的时候,所选择的Fortran编译器必须要保持一致
  • 在下述LAPACK的编译安装中,需要使用Fortran 90编译器,因此不应该使用g77来编译BLAS

3、后续工作

ar r libfblas.a *.o
ranlib libfblas.a
rm -rf *.o      # 清理文件

vi ~/.bash_profile
export BLAS=$HOME/sources/BLAS-3.8.0/libfblas.a # 导出BLAS环境变量
source ~/.bash_profile
echo $BLAS

1.2 安装LAPACK

1、准备源码

wget http://www.netlib.org/lapack/lapack.tgz
tar zxf lapack.tgz
cd lapack-3.9.0/

2、编译

cp INSTALL/make.inc.gfortran make.inc   # On Linux with lapack-3.2.1 or newer
vim make.inc
make lapacklib

注意:在执行make lapacklib之前,编辑make.inc文件,给OPTS和NOOPT这两个设置都加上-fPIC选项。如果是64位系统,还需要加上-m64选项。修改后,看起来像这样:

FORTRAN  = gfortran 
OPTS     = -O2 -frecursive -fPIC -m64
DRVOPTS  = $(OPTS)
NOOPT    = -O0 -frecursive -fPIC -m64
LOADER   = gfortran

在这里插入图片描述

3、后续工作

make clean      # 清理文件
export LAPACK=/wind1/home/19fush/sources/lapack-3.9.0/   # 导出LAPACK环境变量

vi ~/.bash_profile
export LAPACK=$HOME/sources/lapack-3.9.0/   # 导出LAPACK环境变量
source ~/.bash_profile

2. 学院服务器上有,复制修改环境变量即可

# 1. 将/wind1/software/mathlib/blas-3.8.0/libblas.a复制到$HOME/app/blas/3.8.0/lib中,并修改权限
mkdir -p $HOME/app/blas/3.8.0/lib
cp /wind1/software/mathlib/blas-3.8.0/libblas.a $HOME/app/blas/3.8.0/lib
chmod 755 -R $HOME/app/blas/3.8.0/lib/

# 2. 将/wind1/software/mathlib/lapack/3.4.2/intel复制到$HOME/app/lapack/3.4.2/intel中,并修改权限
mkdir -p $HOME/app/lapack/3.4.2/
cp -r /wind1/software/mathlib/lapack/3.4.2/intel $HOME/app/lapack/3.4.2/
chmod 755 -R $HOME/app/lapack/3.4.2/

cp -r /wind1/software/mathlib/lapack/3.4.2/gnu $HOME/app/lapack/3.4.2/
chmod 755 -R $HOME/app/lapack/3.4.2/

# 3. lapack-3.4.2  and blas-3.8.0    environment variable begin
vim ~/.bash_profile
export LAPACK=$HOME/app/lapack/3.4.2/intel
export LD_LIBRARY_PATH=$LAPACK/lib:$LD_LIBRARY_PATH
export INCLUDE=$LAPACK/include:$INCLUDE
export BLAS=$HOME/app/blas/3.8.0
export LD_LIBRARY_PATH=$BLAS/lib:$LD_LIBRARY_PATH

source ~/.bash_profile

安装mpich

install MPICH

安装教程详细参考https://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2-README.txt
或者https://www.mpich.org/documentation/guides/

tar -zxf mpich-3.3.2.tar.gz
cd mpich-3.3.2
./configure --prefix=/wind1/home/19fush/app/mpich
make
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/mpich/bin:$PATH
source ~/.bash_profile
echo $PATH

mpich --version

在这里插入图片描述

./configure --prefix=$HOME/app/mpich/3.2.1 2>&1 | tee c.txt
make -j 48 2>&1 | tee m.txt
make install 2>&1 | tee mi.txt

# 加入环境变量
vi ~/.bash_profile
# MPICH
export MPICH_PATH=$HOME/app/mpich/3.2.1
export PATH=$MPICH_PATH/bin:$PATH
export LD_LIBRARY_PATH=$MPICH_PATH/lib:$LD_LIBRARY_PATH
export INCLUDE=$MPICH_PATH/include:$INCLUDE
export LDFLAGS="-Wl,-rpath -Wl,${MPICH_PATH}/lib"

source ~/.bash_profile

在这里插入图片描述

安装subversion

前提条件

    1. Apache Portable Runtime (APR) and the APR Utility (APR-util) libraries

1. 安装subversion-传统源码安装

reference: https://www.jianshu.com/p/90f818d8b8d9

1.1 install Apache Portable Runtime (APR) and the APR Utility (APR-util) libraries.

tar xzf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/wind1/home/19fush/app/apr
make 
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/apr/bin:$PATH
source ~/.bash_profile
echo $PATH
tar xzf apr-util-1.6.1.tar.gz
cd ../
cd apr-util-1.6.1
./configure --prefix=/wind1/home/19fush/app/apr-util --with-apr=/wind1/home/19fush/app/apr  # 注意,此处需要额外设置--with-apr选项,否则报错 Checking for APR... no    configure: error:
make 
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/apr-util/bin:$PATH
source ~/.bash_profile
echo $PATH

注意:当安装subversion时,因为使用的不是默认的apr和apr-util库,因此需要指定–with-apr=和–with-apr-util=选项。

If you want to specify the location of the APR library, you can use the “–with-apr=” option of “./configure”. It should be able to find the apr-config script in the standard location under that directory (e.g. ${prefix}/bin).

Similarly, you can specify the location of APR-util using the “–with-apr-util=” option to “./configure”. It will look for the apu-config script relative to that directory.

1.2 Zlib (REQUIRED)

tar zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
# 必须指定prefix选项,选择安装路径,没有root权限
./configure --prefix=/wind1/home/19fush/software/zlib-1.2.11-install
make 
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/zlib/bin:$PATH
source ~/.bash_profile
echo $PATH

1.3 OpenSSL (OPTIONAL)

  • 安装包地址:https://www.openssl.org/source/
  • reference: https://www.tecmint.com/install-openssl-from-source-in-centos-ubuntu/
tar -zxf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/wind1/home/19fush/app/openssl
make
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/openssl/bin:$PATH
source ~/.bash_profile
echo $PATH

在这里插入图片描述

1.4 serf 安装失败

mkdir scons
tar -zxf scons-local-2.3.0.tar.gz -C ./scons
cd scons
# When installed privately, simply create a symlink for 'scons' in your PATH to /path/to/scons/scons.py.
ln -s scons.py scons

~/sources/scons-4/scons APR=/wind1/home/19fush/app/apr/bin APU=/wind1/home/19fush/app/apr-util/bin OPENSSL=/wind1/home/19fush/app PREFIX=/wind1/home/19fush/app/serf

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

1.4.1 先安装anaconda,利用anaconda安装serf

  • anaconda的安装方法参考:https://linuxize.com/post/how-to-install-anaconda-on-centos-7/#:~:text=Perform%20the%20following%20steps%20to%20install%20Anaconda%20on,to%20display%20information%20about%20current%20conda%20…%20
  • anaconda的基础教程:https://www.jianshu.com/p/8e366a3eb53e
  • https://developer.aliyun.com/article/603000
# anaconda的安装及基本使用
sha256sum Anaconda3-2020.07-Linux-x86_64.sh
bash Anaconda3-2020.07-Linux-x86_64.sh
source ~/.bashrc
conda create -n python36 python=3.6
conda activate python36
conda deactivate
利用anaconda安装scons和serf
conda search scons
conda search serf
conda install scons
conda install serf

1.5 install sqlite

tar -zxf sqlite-autoconf-3330000.tar.gz
cd sqlite-autoconf-3330000
./configure --prefix=/wind1/home/19fush/app/sqlite
make
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/sqlite/bin:$PATH
source ~/.bash_profile
echo $PATH

1.6 install subversion

官网下载sqlite-autoconf-3290000.tar.gz ,解压后将里面的所有文件复制到subversion-1.19.0/sqlite-amalgamation路径中,没有sqlite-amalgamation这个文件夹就自己创建

tar -zxf cd subversion-1.8.17.tar.gz
cd subversion-1.8.17
# 复制文件夹
cp -a /wind1/home/19fush/sources/sqlite-autoconf-3330000/* /wind1/home/19fush/app/sqlite-amalgamation

./configure --prefix=/wind1/home/19fush/app/subversion
make
make install

# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/subversion/bin:$PATH
source ~/.bash_profile
echo $PATH

2. 安装subversion 的简单方法-anaconda

  • 安装anaconda
  • 创建Python3.6环境
  • 激活Python3.6环境,并安装svn 1.10
conda install -n python36 svn
source activate python36
python --version

安装python与git

1. python 3.7.9

tar -zxf Python-3.7.9.tgz   # 解压缩
cd Python-3.7.9   # 三部曲
./configure --prefix=/wind1/home/19fush/app/python
make
make install
# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/python/bin:$PATH
source ~/.bash_profile
echo $PATH

2. git-2.3.2

tar -zxf git-2.3.2.tar.gz   # 解压缩
cd git-2.3.2   # 三部曲
./configure --prefix=/wind1/home/19fush/app/git
make
make install
# 加入环境变量
vi ~/.bash_profile
export PATH=/wind1/home/19fush/app/git/bin:$PATH
source ~/.bash_profile
echo $PATH

安装netcdf与pnetcdf

背景:自NetCDF库4.2版本以后,Fortran的库和C的库就要分开build啦!而且要装Fortran的库必须先装好C的库。
建议:将依赖库都安装在同一目录下,避免添加过多的环境变量

1. install netcdf

1.1 install netcdf

前提条件

  • For netCDF-4 support
    • HDF5 1.8.9 or later.
    • HDF5 1.10.1 or later. (必须)
  • zlib 1.2.5 or later (for netCDF-4 compression) 必须
  • curl 7.18.0 or later (for DAP remote access client support)
  • For parallel I/O support on classic netCDF files
    • PnetCDF 1.6.0 or later

备注:不支持szip和并行,没有安装szip和pnetcdf

NCDIR=$HOME/app/netcdf
# zlib
./configure --prefix=$NCDIR
make check
make install


# hdf5
./configure --with-zlib=${NCDIR} --prefix=$NCDIR
make
make check
make install
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值