在Linux上手动安装NCL(不使用conda)
How to build NCL and NCAR Graphics from source code
Catalogue
How to build NCL and NCAR Graphics from source code
先放一下如何优雅的使用conda安装NCL
Installing NCL with “conda”
参考:使用conda安装ncl:
# install
conda create -n ncl_stable -c conda-forge ncl
source activate ncl_stable
# test
ncl -V
ncl $NCARG_ROOT/lib/ncarg/nclex/gsun/gsun02n.ncl
ncl $NCARG_ROOT/lib/ncarg/nclex/nug/NUG_multi_timeseries.ncl
如果是MacOS,可能会遇到X11系列Error。解决方法是下载XQuartz。
如果服务器恰好没有连网:
还没有完全成功,前期的安装package遇到的问题已经解决,没有办法在linux上安装X11,所以不能用example进行验证
因为想要整洁的环境,所以package全部安装在anaconda3目录下面,如果没有anaconda3可以安装在$HOME/local下面
参考:在Linux上手动安装NCL
在$HOME目录下mkdir package_install
将package上传到package_install
non-optional external softwares:
- JPEG:
wget http://www.ijg.org/files/jpegsr9b.zip #先在本地用wget,再上传到服务器
tar -xvf jpegsrc.v9a.tar.gz
cd jpeg-9a
./configure --disable-shared --prefix=$HOME/anaconda3
make all install
- zlib
必须要使用1.2.11及以后的版本
:
wget https://zlib.net/zlib-1.2.11.tar.gz
tar -xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=$HOME/anaconda3 --static
make all install
- cairo:
# PNG
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.36.tar.gz
tar -xvf libpng-1.6.36.tar.gz
cd libpng-1.6.36/
./configure --with-pic --disable-shared --prefix=$HOME/anaconda3 --with-zlib-prefix=$HOME/anaconda3 CPPFLAGS=-I$HOME/anaconda3/include #一定要链接到自己安装的路径
make
make check # should be 33/33 pass
make install
#pkg-config
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.tar.gz
tar -xvf pkg-config-0.29.tar.gz
cd pkg-config-0.29/
./configure --prefix=$HOME/anaconda3
#FreeType
wget https://sourceforge.net/projects/freetype/files/freetype2/2.9.1/freetype-2.9.1.tar.gz
tar -xvf freetype-2.9.1.tar.gz
cd freetype-2.9.1/
./configure --prefix=$HOME/anaconda3 --disable-shared
#pixman
wget https://www.cairographics.org/releases/LATEST-pixman-0.38.0
tar -xvf pixman-0.38.0.tar.gz
cd pixman-0.38.0/
./configure --prefix=$HOME/anaconda3
make all install
#cairo
wget http://cairographics.org/releases/cairo-1.16.0.tar.xz
tar -xvf cairo-1.16.0.tar.xz
cd cairo-1.16.0/
/configure --prefix=$HOME/anaconda3 --enable-quartz-font=no --enable-quartz=no --enable-shared=no --enable-static=yes --with-zlib-prefix=$HOME/anaconda3 CPPFLAGS=-I$HOME/anaconda3/include
make all install
pixman/cairo的安装会遇到一些Error:
- $PATH/anaconda3/lib/libpng16.a(pngrutil.o): In function
png_inflate_claim
: $PATH/package_install/libpng-1.6.36/pngrutil.c:429: undefined reference toinflateValidate
- or something like undefined reference to
inflateValidate@ZLIB_1.2.9
解决方法:检查zlib版本是否为1.2.11及以上,不然会出现错误1;在编译png的时候是否加上--with-zlib-prefix=$HOME/anaconda3 CPPFLAGS=-I$HOME/anaconda3/include
,否则会和原本安装在系统中的zlib路径混淆,造成版本错误。
- NetCDF:
【记录】在Anaconda(linux)中安装netCDF4库
偷懒了,用了以前安装的netCDF4库,安装路径同样也在anaconda3下面,不知道这个会不会有影响。
- HDF-4:
wget https://support.hdfgroup.org/ftp/HDF/HDF_Current/src/hdf-4.2.14.tar
gzip -d hdf-4.2.13.tar.gz
tar -xvzf hdf-4.2.13.tar
cd hdf-4.2.13/
/configure --prefix=$HOME/anaconda3 --with-zlib=$HOME/anaconda3 --with-jpeg=$HOME/anaconda3 --disable-netcdf
make all install
Build NCL with Source Code
这个方法没有成功的build出ncl,所以选择的是先用source code编译一遍,再把bin替换成precompiled的bin
#download ncl_ncarg-6.6.2.tar.gz
tar -zxvf ncl_ncarg-6.6.2.tar.gz
export NCARG=/home/usr_name/package_install/ncl_ncarg-6.6.2
cd $NCARG/config
make -f Makefile.ini
./ymake -config `pwd` #检查ymake里的第一行sch的路径。如果没有sch会报错:bash: ./ymake: /bin/csh: bad interpreter: No such file or directory。
如果更改了ymake中csh的路径,同样要改的还有ldrel, ymkmf, ymake-install, callconv
。
grep SYSTEM_INCLUDE Makefile
# SYSTEM_INCLUDE = "LINUX"
cd $NCARG
./Configure -v
# Parent installation directory : /usr/local/ncarg
# Enter Return (default), new directory, or q(quit) > $HOME/package_install/ncl_install
# Enter local include search path(s) : /usr/X11R6/include
# Enter Return (default), new directories, or q(quit) > $HOME/package_install/ncl_install $HOME/anaconda3/include/freetype2
cd $NCARG
make Everything >& make-output &
tail -f make-output
export NCARG_ROOT=$安装ncl的时候选择的路径
export PATH=$NCARG_ROOT/bin:$PATH
export MANPATH=$NCARG_ROOT/man:$MANPATH
# check
ncl -V (目前安装到这一步,6.6.2)
跑example的时候仍然会报错:
这是因为没有X11,选择使用 wks = gsn_open_wks("png","maponly") ; send graphics to PNG file
就不会报错了
warning:Unable to load System Resource File /home/cmx/package_install/ncl_install/lib/ncarg/sysresfile
GKS ERROR NUMBER -208 ISSUED FROM SUBROUTINE GOPWK :
–X driver error: DISPLAY environment variable not set
GKS ERROR NUMBER 25 ISSUED FROM SUBROUTINE GESC :
–SPECIFIED WORKSTATION IS NOT OPEN
fatal:Workstation with PID#8 is not open
fatal:Unable to open Workstation-Can’t Create
fatal:Unable to access object with id:-4
fatal:_NhlCreate:Invalid Parent id #-4
fatal:PID #-4 can’t be found in NhlSetValues
fatal:NhlDraw: Invalid Layer Id: -4
fatal:Unable to update Workstation with PID#-4
fatal:Unable to clear Workstation with PID#-4
fatal:[“Execute.c”:8637]:Execute: Error occurred at or near line 2742 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
如果没有办法编译出ncl:
使用precompiled bin替换编译后的ncl package的bin
Installing NCL with precompiled binary
更多推荐
所有评论(0)