[Mac OSX]+homebrew安装NCL(ncar command language)
2016-09-28 18:00
495 查看
mac下尝试了很多种简单的方法,比如通过anaconda安装
但是不行,没有osx下面的版本,尝试从ncl源码编译,时间太长,
尝试gcc源码编译,时间也很长。
因此在mac OSX下面最好的方法还是采取ncl自带的预编译版本,然后通过brew或者macport自行安装gcc,在整个过程中走了不少弯路,希望能够帮助大家。
开源包管理器:Homebrew1.0.5
https://www.earthsystemgrid.org/dataset/ncl.630.html
ncl的数据下载从原先的FTP服务器迁移到了earth system grid.
ncl包括三种下载文件:
1. 预编译版本包含opendap;
2. 预编译版本包含不opendap;
3. 源码
下载不包含opendap的版本:ncl_ncarg-6.3.0.MacOS_10.10_64bit_nodap_gcc492.tar.gz
gcc
homebrew/versions/gcc48
homebrew/versions/gcc43 homebrew/versions/gcc49
homebrew/versions/gcc44 homebrew/versions/gcc5
homebrew/versions/gcc45 homebrew/versions/gcc6
homebrew/versions/gcc46 homebrew/versions/llvm-gcc28
homebrew/versions/gcc47
大概经过几分钟,安装完成
gcc (Homebrew gcc49 4.9.3) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GNU Fortran (Homebrew gcc49 4.9.3) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
dyld: Library not loaded: /usr/local/lib/libgomp.1.dylib
Referenced from: /opt/ncl/bin/ncl
Reason: image not found
Trace/BPT trap: 5
笔者在官网搜到的答案是gcc的版本安装不对,实在是相当大的误导,这里的libgomp.1.dylib或其它类似的库文件其实都放在
/usr/local/lib/gcc中,而gcc只会搜寻/usr/local/lib目录,下面的子目录文件不会装载,这其实应该可以通过添加gcc的搜索路径解决,但笔者采取更直接的办法,直接将/usr/local/lib/gcc/4.9(注意brew安照版本号存放库文件,这样虽然便于管理,却给用户使用增加了麻烦)中的库文件直接复制到了/usr/local/lib中。
export NCARG_ROOT=”/opt/ncl”
export PATH=”NCARGROOT/bin:PATH”
Copyright (C) 1995-2015 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.3.0
The use of this software is governed by a License Agreement.
See htt
!!安装成功!!
conda install ncl
但是不行,没有osx下面的版本,尝试从ncl源码编译,时间太长,
尝试gcc源码编译,时间也很长。
因此在mac OSX下面最好的方法还是采取ncl自带的预编译版本,然后通过brew或者macport自行安装gcc,在整个过程中走了不少弯路,希望能够帮助大家。
1.系统信息
操作系统:OSX 10.11EL CAPTAIN开源包管理器:Homebrew1.0.5
2.下载ncl
随着ncl版的不断更新,截止写作时最新版本为6.3.0,https://www.earthsystemgrid.org/dataset/ncl.630.html
ncl的数据下载从原先的FTP服务器迁移到了earth system grid.
ncl包括三种下载文件:
1. 预编译版本包含opendap;
2. 预编译版本包含不opendap;
3. 源码
下载不包含opendap的版本:ncl_ncarg-6.3.0.MacOS_10.10_64bit_nodap_gcc492.tar.gz
3.安装gcc
mac自带的gcc版本ncl没法用,是clang的,需要安装和下载的ncl相对应的版本,因此我们这里安装gcc4.9的版本。gcc492表示4.9.2这个版本,不过第二个小数点后的.2子版本是可以忽略的,只要保证前面两个主版本相同就行。我们通过homebrew进行安装。## 查询可以下载的版本 % brew search gcc
gcc
homebrew/versions/gcc48
homebrew/versions/gcc43 homebrew/versions/gcc49
homebrew/versions/gcc44 homebrew/versions/gcc5
homebrew/versions/gcc45 homebrew/versions/gcc6
homebrew/versions/gcc46 homebrew/versions/llvm-gcc28
homebrew/versions/gcc47
## 下载的范围包括gcc4.3~gcc6 % brew install homebrew/versions/gcc49
大概经过几分钟,安装完成
# 查看gcc版本(发现还是以前的gcc) % gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 7.3.0 (clang-703.0.31) Target: x86_64-apple-darwin15.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin # 查看 gfortran版本(gfortran也是ncl需要的) % gfortran --version
# 修改默认gcc 文件访问路径 % which gcc /usr/bin # 我们安装的gcc默认放在/usr/local/bin中。添加搜索别名 % cd /usr/local/bin % ln -s gcc-4.9 gcc # 新开一个命令行,输入 % gcc --version
gcc (Homebrew gcc49 4.9.3) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# 同理修改gfortran % ln -s gfortran-4.9 gfortran % gfortran --version
GNU Fortran (Homebrew gcc49 4.9.3) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
4.修改gcc的lib位置
之所以单独成章因为这是最重要的一步,笔者耗费很多时间才发现这一问题,如果直接运行解压缩后的ncl命令则会一直报库文件没发正常装载的错误:dyld: Library not loaded: /usr/local/lib/libgomp.1.dylib
Referenced from: /opt/ncl/bin/ncl
Reason: image not found
Trace/BPT trap: 5
笔者在官网搜到的答案是gcc的版本安装不对,实在是相当大的误导,这里的libgomp.1.dylib或其它类似的库文件其实都放在
/usr/local/lib/gcc中,而gcc只会搜寻/usr/local/lib目录,下面的子目录文件不会装载,这其实应该可以通过添加gcc的搜索路径解决,但笔者采取更直接的办法,直接将/usr/local/lib/gcc/4.9(注意brew安照版本号存放库文件,这样虽然便于管理,却给用户使用增加了麻烦)中的库文件直接复制到了/usr/local/lib中。
% sudo cp -R /usr/local/lib/gcc/4.9/* /usr/local/lib/
5.解压缩ncl
笔者将早先下载的文件安装在/opt中% sudo -s # cd /opt # mkdir ncl # mv ~/Download/ncarg-6.3.0.MacOS_10.10_64bit_nodap_gcc492.tar.gz ncl # cd ncl # tar xvfz ncarg-6.3.0.MacOS_10.10_64bit_nodap_gcc492.tar.gz
## 修改bash_profile,添加ncl root % vim ~/.bash_profile
export NCARG_ROOT=”/opt/ncl”
export PATH=”NCARGROOT/bin:PATH”
## 更新配置 % source ~/.bash_profile
6.测试
% ncl
Copyright (C) 1995-2015 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.3.0
The use of this software is governed by a License Agreement.
See htt
!!安装成功!!
相关文章推荐
- 利用RVM和Homebrew在Mac OS X 10.8 Mountain Lion上安装Ruby 2.0.0
- mac os x 10.9.1 安装 Homebrew软件包管理工具及brew安装maven3.1.1
- mac os x 10.9 安装 Command Line Tools ( xCode6 居然不能直接下载这工具 -_-!! )
- Mac OS X上安装和使用Homebrew和Homebrew Cask来进行软件安装管理
- 如何在NCL(The NCAR Command Language )启动时自动加载自定义的函数和程序
- Mac笔记(一) Mac OS X 10.9.4 安装 Homebrew
- Mac OS X 程序员利器 – Homebrew安装与使用以及python学习指南
- Mac OS X 10.9.4 系统用HomeBrew安装管理ruby
- Mac OS X EL Capitan MAC OX 10.11 安装cocoapods后还是提示-bash :pod command not found 解决办法
- Mac OS X下HomeBrew安装卸载
- Mac OS X 程序员利器 – Homebrew安装与使用
- Mac OS X 程序员利器 – Homebrew安装与使用
- Mac OS X下使用Homebrew安装PNG支持——重新编译PHP
- Mac OS X 安装 Homebrew&XCode&Cmake&Eclipse&Opencv
- Mac OS X 程序员利器 – Homebrew安装与使用
- Mac OS X上如何安装Homebrew?
- mac os maverick下安装nginx+php-fpm via homebrew
- Mac OS X 10.10 运用 Homebrew安装Hadoop 2.7.1
- Mac OS X系统 HomeBrew的安装和简单使用
- Mac OS X 下 HomeBrew的安装和简单使用