本文平台基于:MacOS10.15.2,同样适用低版本MacOS。
目前最新的Ferret版本为v7.6,

本文主要参考以下内容:
https://github.com/NOAA-PMEL/Ferret/blob/master/README_ferret_mac_homebrew.md
https://nicojourdain.github.io/students_dir/students_install_Ferret/
https://ferret.pmel.noaa.gov/Ferret/documentation/ferret-tutorial-script

1. 安装XQuartz

到官网https://www.xquartz.org/ 下载安装最新版,目前最新版是XQuartz-2.7.11.dmg

2. 安装homebrew

一般Mac用户都会装,官网 https://brew.sh/
注意需要xcode命令行工具

xcode-select --install

3. 安装部分依赖

brew install gcc
brew install readline
brew install hdf5
brew install netcdf

4. 安装Ferret

4.1 获取source code

# 如需最新版
git clone https://github.com/NOAA-PMEL/Ferret.git
# 如需老版本(如7.4.4),可将上一行改为
git clone https://github.com/NOAA-PMEL/Ferret.git ~/git/Ferret --branch 7.4.4

4.2 获得依赖lib所在位置

# 使用which+软件名,或brew list+软件名,如
brew list netcdf
/usr/local/Cellar/netcdf/4.6.3_1/lib/
brew list readline
/usr/local/Cellar/readline/8.0.1/lib/

4.3 编辑配置文件

cd $HOME/git/Ferret
cp site_specific.mk.in site_specific.mk
# 修改以下文件,有两行不赋值
vi site_specific.mk
DIR_PREFIX = $(HOME)/git/Ferret (wherever you cloned or copied the Ferret source)
BUILDTYPE = intel-mac
INSTALL_FER_DIR = /Users/yao/Documents/SOFTWARE/Ferret (wherever you want Ferret installed)
HDF5_LIBDIR = 
SZ_LIBDIR = 
NETCDF_LIBDIR = /usr/local/Cellar/netcdf/4.6.3_1/lib
(wherever Homebrew put its netcdf library)
READLINE_LIBDIR = /usr/local/Cellar/readline/8.0.1/lib (wherever Homebrew put its hidden readline library)
# 类似的,设置编译平台为mac
cp external_functions/ef_utility/site_specific.mk.in external_functions/ef_utility/site_specific.mk 
vi external_functions/ef_utility/site_specific.mk
BUILDTYPE = intel-mac

4.4 make&install ferret

# 在安装目录下安装,这两步都很快
sudo make
sudo make install

4.5 获取ferret数据

cd /Users/yao/Documents/SOFTWARE/Ferret
mkdir fer_dsets
cd fer_dsets
wget ftp://ftp.pmel.noaa.gov/ferret/pub/data/fer_dsets_smaller.tar.gz
gunzip fer_dsets_smaller.tar.gz
tar xvf fer_dsets_smaller.tar 
rm -f fer_dsets_smaller.tar

4.6 生成一些路径

cd /Users/yao/Documents/SOFTWARE/Ferret/bin
sudo ./Finstall

Enter your choice:
 (1) Install executables, (2) Customize ferret_paths files, (3,q,x) Exit
 (1, 2, 3, q, x) --> 2

 Customize ferret_paths files...

 Enter the name of the directory where the 'fer_environment.tar.gz'
 file was installed/extracted (FER_DIR).  The location recommended
 in the Ferret installation guide was '/usr/local/ferret'.

 FER_DIR --> /Users/yao/Documents/SOFTWARE/Ferret

 Enter the name of the directory where the 'fer_dsets.tar.gz'
 file was installed/extracted (FER_DSETS).
# Preferred editor for local and remote sessions

 FER_DSETS --> /Users/yao/Documents/SOFTWARE/Ferret/fer_dsets

 Enter the name of the directory where you want to place
 the newly created 'ferret_paths.csh' and 'ferret_path.sh'
 files; for example, '/usr/local'.

 desired ferret_paths location --> /usr/local

 To duplicate behavior found in older version of Ferret, you can
 create a link (shortcut) 'ferret_paths' that refers to either
 'ferret_paths.csh' or 'ferret_paths.sh'.  This is simply a
 convenience for users and should only be done on systems where
 all Ferret users work under the same shell (such as tcsh or bash).
 The files 'ferret_path.csh' and 'ferret_paths.sh' can always be
 used regardless of the answer to this question.

 ferret_paths link options:
    c - link to ferret_paths.csh (all users work under tcsh, csh)
    s - link to ferret_paths.sh (all users work under bash, dash, ksh, sh)
    n - do not create the link (use ferret_paths.csh or ferret_paths.sh)
 ferret_paths link to create? (c/s/n) [n] --> s

 Created /usr/local/ferret_paths.csh
 Creating Finstall.log in /Users/yao/Documents/SOFTWARE/Ferret/bin

 Created /usr/local/ferret_paths.sh

 Created /usr/local/ferret_paths
     as a link to ferret_paths.sh

 Enter your choice:
 (1) Install executables, (2) Customize ferret_paths files, (3,q,x) Exit
 (1, 2, 3, q, x) --> 3

4.7 设置环境变量

vi ~/.zshrc
# 文件最后添加以下两行
export PATH="/Users/yao/Documents/SOFTWARE/Ferret/bin:$PATH"
source /usr/local/ferret_paths
:wq
source ~/.zshrc

5. 测试

which ferret
/Users/yao/Documents/SOFTWARE/Ferret/bin/ferret

ferret
     NOAA/PMEL TMAP
     FERRET v7.6 (optimized)
     Darwin 19.2.0 - 12/11/19
     11-Dec-19 21:29

yes? SET DATA etopo20
yes? SHOW DATA
     currently SET data sets:
    1> /Users/yao/Documents/SOFTWARE/Ferret/fer_dsets/data/etopo20.cdf  (default)
 name     title                             I         J         K         L
 ROSE     RELIEF OF THE SURFACE OF THE EA  1:1081    1:540     ...       ...

yes? SHADE ROSE

Screen Shot 2019-12-11 at 21.31.08.png
当你能看到一张海底地形时,说明一切安装正常。

P.S.小教程

在网上能找到的一个孟老师的小教程,尽管课件有些老,对于入门者还是聊胜于无。
海洋数据处理及可视化.pptx

Last modification:December 11th, 2019 at 11:04 pm
If you think my article is useful to you, please feel free to appreciate