一、下载以及相关资源参考地址
Github: https://github.com/parflow/parflow
Parflow blog: http://parflow.blogspot.com/
Parflow users: https://mailman.mines.edu/pipermail/parflow-users/
User manual: https://github.com/parflow/parflow/blob/master/user_manual.pdf
二、安装
主要参考 User manual(https://github.com/parflow/parflow/blob/master/user_manual.pdf)以及 Blog (http://parflow.blogspot.com/search/label/linux) 安装parflow
系统:window 下 Vmware 运行 lubuntu-19.10 desktop amd64
1. 安装准备
(1)Ubuntu下进入终端(Qterminal)
You will first need to download and install C, C++ and Fortran compilers and Tcl/Tk. The download list below also includes optional, but recommended text editors. Ubuntu ships with vim-lite, which sucks. At the very least, install the full version of vim. Downloading and installing these is very easy. All you have to do is enter the following commands:
提前安装如下工具:
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install gdc
sudo apt-get install gfortran
sudo apt-get install tcl-dev
sudo apt-get install tk-dev
可选安装
sudo apt-get install vim [highly recommended]
sudo apt-get install jedit [my favorite text editor – allows vertical selection]
(2)下载Parflow安装包
注:本次安装的parflow版本为3.3.1,最新版已经是3.6.0
2. 安装
(1)在home下新建一个文件夹名为 pfdir
cd
mkdir pfdir
cd pfdir
(2)将 parflow-3.3.1.tar.gz 复制到pfdir文件夹下,并进行解压
tar -xvf parflow-3.3.1.tar.gz
(3)将解压出来的parflow-3.3.1文件夹重命名为parflow(手动)
(4)承接(1)中的设置路径,继续新建文件夹build
mkdir build
cd build
(5)设定PARFLOW_DIR环境变量
export PARFLOW_DIR=/home/pf/pfdir/parflow
(6)build 和 install Parflow
cd build
cmake ../parflow -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR (或者 ccmake ../parflow 在gui下自行设置CMAKE_INSTALL_PREFIX的路径,即与PARFLOW_DIR一致)
make
make install
(7)测试parflow
cd $PARFLOW_DIR
cd test
tclsh default_single.tcl 1 1 1
若运行成功,会显示 :
(8)跳转至build路径,然后运行test
cd ../../build
make test
运行后,会有如下显示:
(9)运行example测试parflow。可以先回到home目录,新建一个foo文件夹,作为运行实例以及存储相关结果的文件夹,该文件夹可以完全独立于parflow文件夹,代码如下
cd
mkdir foo
cd foo
cp $PARFLOW_DIR/examples/default_single.tcl . (注意最后有个点 .)
chmod 640 * (foo赋予文件读写权限)
tclsh default_single.tcl
运行成功会显示一大段空白,如下:
同时,foo文件夹下会生成模型运行的结果
三、可能出现的问题
(1)build 和 install Parflow过程中出现,如下图所示问题
解决办法:打开pftools文件夹下的pkgindex.tcl文件,将代码替换为:
也可以自行去github下载该文件 https://github.com/parflow/parflow/blob/master/pftools/pkgIndex.tcl
# Tcl package index file, version 1.0
if {![package vsatisfies [package provide Tcl] 8.5]} {puts "ERROR : pftools requires TCL 8.5 or greater"; return}
package ifneeded parflow 1.0 [list apply {dir {
uplevel 1 [list source [file join $dir parflow.tcl]]
uplevel 1 [list source [file join $dir pfvtk.tcl]]
if { [file exists [file join $dir parflow[info sharedlibextension]]] } {
load [file join $dir parflow[info sharedlibextension]]
} else {
load [file join $dir libpftools[info sharedlibextension]] parflow
}
}} $dir]
package ifneeded xparflow 1.0 [list apply {dir {
package require parflow
uplevel 1 [list source [file join $dir xpftools.tcl]]
uplevel 1 [list source [file join $dir xpfthelp.tcl]]
uplevel 1 [list source [file join $dir metaEListBox.tcl]]
uplevel 1 [list source [file join $dir metaEntry.tcl]]
uplevel 1 [list source [file join $dir xpftgeneral.tcl]]
uplevel 1 [list source [file join $dir xpftdatadsp.tcl]]
uplevel 1 [list source [file join $dir xpftdiffdsp.tcl]]
uplevel 1 [list source [file join $dir xpftstatdsp.tcl]]
uplevel 1 [list source [file join $dir xpftfunctions.tcl]]
uplevel 1 [list source [file join $dir xpftfuncwin.tcl]]
uplevel 1 [list source [file join $dir xpftinfowin.tcl]]
uplevel 1 [list source [file join $dir xpftgriddsp.tcl]]
uplevel 1 [list source [file join $dir pftformat.tcl]]
uplevel 1 [list source [file join $dir fsb.tcl]]
uplevel 1 [list source [file join $dir xpftpf.tcl]]
uplevel 1 [list source [file join $dir xpftsds.tcl]]
uplevel 1 [list source [file join $dir xpftnewgrid.tcl]]
}} $dir]
(2)build 路径下,执行make install 后出现 如下 /config permission denied 错误
解决办法:设置正确的PARFLOW_DIR路径,在本次运行中为 /home/pf/pfdir/parflow, 且通过ccmake检查CMAKE_INSTALL_PREFIX是否与PARFLOW_DIR一致
设置当前工作路径在build下,运行代码为
ccmake ../parflow
出现如下图所示的GUI。若不是/home/pf/pfdir/parflow,请按照最下栏的提示,修改路径。修改后,先按 c 进行configure,然后在新的显示界面按 e ,最后按 g 保存退出GUI
欢迎Parflow交流:memoryxu2015@outlook.com