目录
1. 环境配置
1.1 Supported Platforms
1.2 Prerequisites
2.下载SIB-CROP代码
3. SIB-CROP模型编译
4. 下载驱动数据
5. SIB-CROP模型运行
主要参考
[1]官方文档:http://sib.atmos.colostate.edu/
[2]LAPACK安装:https://blog.csdn.net/kiy__/article/details/60868238
1. 环境配置
1.1 Supported Platforms
Compilers(编译器):
GCC Gfortran,
Portland Group (pgf90),
Intel Fortran (ifort)
Operating Systems(操作系统):
Linux,
OS X
We work with SiB on Linux and OS X with Gfortran, and Portland Group’s pgf90. Sometimes we test with Intel’s ifort. Other Fortran 90 compilers and POSIX operating systems may work, but you’re on your own. If some simple changes will make SiB run on your platform of choice, consider sending them to us for inclusion in our source code repository.
上面是官方文档上说的是运行模型对编译器和操作系统的要求,我是在服务器上运行该模型的,下面先来检查一下操作系统的发行版本和有无对应的编译器。
• Linux内核版本和发行版本(系统版本)
查看Linux内核版本命令:uname -a
查看Linux发行版本命令:cat /etc/issue
查看编译器版本命令:ifort -v
这样看来,我已经有ifort编译器,操作系统也是linux,就满足上述文档里的两个要求啦。要是你没有对应的编译器,需要自己装。
1.2 Prerequisites
You will need the libraries(需要安装的库):
NetCDF version 3,
LAPACK,
BLAS
All versions of SiB depend on NetCDF version 3, LAPACK and BLAS libraries. LAPACK and BLAS may come with your compiler, and on OS X the routines are in the vecLib framework. Otherwise, you will need to compile them yourself. We recommend building the ATLAS implementation of BLAS with netlib.org’s LAPACK distribution.
上面是官方文档上说的是模型运行依赖的库,因为服务器上已经装好了 NetCDF version 3,所以这里我就只介绍一下我 LAPACK库的安装过程,这里需要注意两点:(1)装好了LAPACK库,BLAS库其实也已经装好了,不用再单独安装一次;(2)编译依赖库和编译模型的编译器要一致,比如现在我用ifort编译器编译好LAPACK和 NetCDF,则之后编译SIB-CROP模型也只能用ifort编译器,否则会报错啦。
1.2.1 LAPACK安装过程
1. 从网站下载安装包
官网:http://www.netlib.org/lapack/
这里我下载的是LAPACK,version 3.8.0
2. 解压安装包:tar zxf lapack-3.8.0.tar.gz
3. 将解压得到的make.inc.example 改名为 make.inc:cp make.inc.example make.inc
4. 用gedit编辑make.inc: gedit make.inc(这里你也可以用vim编辑器编辑)
5. 用gedit编辑Makefile: gedit Makefile(这里你也可以用vim编辑器编辑)
6.编译:make
这个过程大概需要5分钟,出现下面的内容就说明你编译成功啦!
7.要是你遇到这样的错误,输入:ulimit -s 100000, 然后再次make
参考: https://blog.csdn.net/chishuideyu/article/details/78351063
8.make之后会产生 liblapack.a, librefblas.a, libtmglib.a 3个静态链接库
将liblapack.a, librefblas.a,libtmglib.a所在路径加入到加入到LD_LIBRARY_PATH环境变量
9. 测试
该博主提供了一段测试代码:http://blog.sciencenet.cn/home.php?mod=space&uid=271986&do=blog&id=280793%E3%80%82
test.f90源文件:
program test_sgesv
implicit none
real :: a(3,3),b(3)
integer :: v(3),iflag
external sgesv
a=reshape([2.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,4.0],[3,3])
b=[998.0,999.0,1000.0]
print *,'a=',a
print *,'b=',b
call sgesv(3,1,a,3,v,b,3,iflag)
print *,'solve=',b
end program test_sgesv
编译 在命令行输入:ifort test.f liblapack.a librefblas.a,生成a.out文件
运行 在命令行输入:./a.out,运行结果如下图,如果你能运行,就说明lapack装成功啦!
2.下载SIB-CROP代码
To get SiBcrop from our subversion repository, use the following command:
svn co http://salix.atmos.colostate.edu/svn/sib/branches/SiB3crop
This will check out the latest version of the code. You will have read-only access to the code this way. If you wish to contribute changes, see Contributing below.
(1)在命令行输入:svn co https://salix.atmos.colostate.edu/svn/sib/branches/SiB3crop (记得http后加s,官网写的是http)
(2)出现:( R )eject, accept ( t )emporarily or accept ( p )ermanently? 这里我选了p
(3)过个几分钟你会发现你把SIB-CROP的代码成功下载下来啦!
3. SIB-CROP模型编译
(1)修改Makefile中相关库的路径
在命令行输入:
1) 将Makefile.example改名为Makefile:cp Makefile.example Makefile
2)用gedit编辑Makefile.example: gedit Makefile(这里你也可以用vim编辑器编辑)
COMPILER = ifort !修改编译器
OPT = debug
NETCDF_ROOT = /software/netcdf-3.6.3-intel !netcdf库的安装路径
LAPACK_ROOT = /data/lapack-3.8.0_ifort/lapack-3.8.0 !LAPACK安装路径
LALIB = -L$(LAPACK_ROOT) -llapack -lrefblas -ltmglib !LAPACK编译成功后生成的3个.a文件
(2)编译
在命令行输入:make
编译成功为生成: SiBD3crop-lxifort-debug和 sibmerge-lxifort-debug两个可执行文件,即编译成功(这两个文件有啥区别我也不知道)
编译的过程我遇到了下面的问题,记下来,万一以后再遇到:
错误1: 找不到某个命令。这个主要是因为在Makefile里改的LAPACK_ROOT和LALIB路径不对造成的
错误2: 显式接口和隐式接口的问题
解决:
//在qsat_eau.F90里加上下面语句:
MODULE mod1 ! 模块
CONTAINS
END MODULE mod1
//在netrad.F90里加上下面语句:
use mod1
参考:https://blog.csdn.net/weixin_43780543/article/details/90082308
错误3:phosib.f90里的479行 sib%diag%assim(i) = assimy(icconv)被注释了
解决:
去掉注释即可
错误4:编译依赖库和编译模型的编译器不一致造成的
解决:
如果你编译模型时候使用的是ifort,那你编译netcdf应该也用ifort,因此需要重装netcdf
参考:http://blog.sina.com.cn/s/blog_15070f08d0102w41w.html
4. 下载驱动数据
官网上http://sib.atmos.colostate.edu/给了两个站点的测试数据,任意下载其中一种即可
两个站点我都下了,但测试时候用的是bondville,bondville文件下包含下述几个子文件:
5. SIB-CROP模型运行
(1)该过程主要涉及到一些文件路径的更改
(2)运行
在命令行输入:./SiBD3crop (备注:上图中SiBD3crop-lxifort-debug写错了,编译成功的文件应该是SiBD3crop)
完结撒花! 感谢实验室师兄的指导!