爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 23933|回复: 15

NCO-4.4.7安装~latest version NCO千呼万唤始出来啊~

[复制链接]
发表于 2014-12-10 15:59:22 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
本帖最后由 风往北吹 于 2014-12-10 16:35 编辑

最近需要使用NCO就在服务器上摸索着安装了NCO,在论坛里也有人安装了NCO但是版本比较老了(v4.0.6),譬如,nces(统计相关的)命令就无法使用。http://bbs.06climate.com/forum.php?mod=viewthread&tid=27031所以,我尝试着去安装最近的新版本(最新是V4.4.8),稳定保险起见就安装了v4.4.7。感觉NCO还是在处理大量模式数据有自己的优势的,将自己的安装过程share一下。


网上有相关的shell script安装,由于服务器不一定都能连外网用不了wget,所以,还是自己下载合适版本的库,来配合nco安装。需要的库有:antlr-2.7.7  ;udunits-2.1.20 ;gsl-1.16;zlib-1.2.5 ;netcdf-4.1.1(最新版本的c和f是分开的,方便起见就安装这个版本)   以及  nco-4.4.7。使用论坛的帖子里面的方法,最后始终会报错,提示netcdf找不到,低版本的nco是没有问题的,我有点强迫症,新版本不使用,心里过意不去,就尝试着gfsoso了几下,还是有些收获的,好的闲话少说,上东西。


第一步,在bashrc中提前写好环境变量。 记得vi ~/.bashrc  之后还要 source ~/.bashrc


INSTALL_PATH=/home/software    #服务器中非ROOT用户需要指定
#ANTLR
APP=antlr-2.7.7
ANTLR_PATH=$INSTALL_PATH/$APP

#UDUNITS
APP=udunits-2.1.20
UDUNITS_PATH=$INSTALL_PATH/$APP

# ZLIB
APP=zlib-1.2.5
ZLIB_PATH=$INSTALL_PATH/$APP

#hdf4
APP=hdf-4.2.9
HDF4_PATH=$INSTALL_PATH/$APP

# HDF5
APP=hdf5-1.8.6
HDF5_PATH=$INSTALL_PATH/$APP

#GSL
APP=gsl
GSL_PATH=$INSTALL_PATH/$APP

#NETCDF
APP=netcdf-4.1.1
NETCDF4_PATH=$INSTALL_PATH/$APP

export NETCDF_ROOT=/home/disk2/users/zhpfu/software/netcdf-4.1.1
export NETCDF_LIB=/home/disk2/users/zhpfu/software/netcdf-4.1.1/lib
export NETCDF4_ROOT=/home/disk2/users/zhpfu/software/netcdf-4.1.1
export NETCDF_INC=/home/disk2/users/zhpfu/software/netcdf-4.1.1/include
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/disk2/users/zhpfu/software/netcdf-4.1.1/lib

# NCO
APP=nco-4.4.7  #4.3.0 #4.0.7
NCO_PATH=$INSTALL_PATH/$APP
PATH=$PATH:$NCO_PATH/bin


第二步,编译,安装相应的库

mkdir -p $INSTALL_PATH/src     创建目录存放下载各种库的source

# ANTLR2
cd $INSTALL_PATH/src
tar xzf antlr-2.7.7.tar.gz ; cd antlr-2.7.7
CC=gcc CXX='' ./configure \
--prefix=$ANTLR_PATH \
--disable-csharp \
--disable-java \
--disable-python 2>&1 | tee $APP.config


make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install


# UDUNITS
cd $INSTALL_PATH/src
tar xzf udunits-2.1.20.tar.gz ; cd udunits-2.1.20
CC=gcc CXX='' F77=gfortran ./configure \
--prefix=$UDUNITS_PATH 2>&1 | tee $APP.config


make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install

# ZLIB
cd $INSTALL_PATH/src
tar zxf zlib-1.2.5.tar.gz ; cd zlib-1.2.5
CC=gcc FC=gfortran CXX='' ./configure \
--prefix=$ZLIB_PATH | tee $APP.config


make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install


# GSL      
tar xzf gsl-1.16.tar.gz ; cd gsl-1.16     
   ./configure \   
    --prefix=$GSL_PATH \     
   CFLAGS="-fexceptions" | tee $APP.config  


make 2>&1 | tee $APP.make        
make install 2>&1 | tee $APP.install

# HDF5
cd $INSTALL_PATH/src
tar xzf hdf5-1.8.6.tar.gz ; cd hdf5-1.8.6
CC=gcc FC=gfortran CXX='' ./configure \
--prefix=$HDF5_PATH \--enable-fortran \
--with-zlib=$ZLIB_PATH \
--with-pic 2>&1 | tee $APP.config


make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install

# NetCDF4

cd $INSTALL_PATH/src
tar xzf netcdf-4.1.1.tar.gz ; cd netcdf-4.1.1
CC=gcc FC=gfortran F77=gfortran CXX='' ./configure \
--prefix=$NETCDF4_PATH \
--enable-fortran \
--enable-static \
--enable-shared\
--enable-f77 \
--disable-cxx \
--enable-netcdf4 \
--with-hdf5=$HDF5_PATH \
--with-zlib=$ZLIB_PATH \
--with-pic 2>&1 | tee $APP.config


make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install


# NCO
cd $INSTALL_PATH/src
tar xzf nco-4.4.7.tar.gz ; cd nco-4.4.7
export LD_LIBRARY_PATH=$HDF5_PATH/lib:$LD_LIBRARY_PATH
export PATH=$HDF5_PATH/bin:$PATH
export LD_LIBRARY_PATH=$NETCDF4_PATH/lib:$LD_LIBRARY_PATH
export PATH=$NETCDF4_PATH/bin:$PATH
export LD_LIBRARY_PATH=$ANTLR_PATH/lib:$LD_LIBRARY_PATH
export PATH=$ANTLR_PATH/bin:$PATH
export LD_LIBRARY_PATH=$UDUNITS_PATH/lib:$LD_LIBRARY_PATH
export PATH=$UDUNITS_PATH/bin:$PATH
export LD_LIBRARY_PATH=$ZLIB_PATH/lib:$LD_LIBRARY_PATH
export PATH=$ZLIB_PATH/bin:$PATH
CC=gcc CXX='' \
NETCDF_INC=$NETCDF4_PATH/include \
NETCDF_LIB=$NETCDF4_PATH/lib \
NETCDF4_ROOT=$NETCDF4_PATH \
HDF5_LIB_DIR=$HDF5_PATH/lib \
UDUNITS2_PATH=$UDUNITS_PATH \
LDFLAGS="-L$ANTLR_PATH -lantlr \
-lhdf5_hl -lhdf5 -L$NETCDF4_PATH/lib -lnetcdf" LIBS='-lcurl' \      
CFLAGS="-I$HDF5_PATH/include \
-L$HDF5_PATH/lib \
-I$ANTLR_PATH/include \
-L$ANTLR_PATH/lib" \
CPPFLAGS="-I$HDF5_PATH/include \
-L$HDF5_PATH/lib \
-I$ANTLR_PATH/include \
-L$ANTLR_PATH/lib" \
./configure \
--prefix=$NCO_PATH \
--disable-shared \
--enable-netcdf-4 2>&1 | tee $APP.config


make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install



高版本无法安装的原因找到了,########### a static build netCDF4 library with OpenDAP support installed. curl library with LIBS='-lcurl':   LIBS='-lcurl'


第三步,试试看
$ nces
nces: ERROR received 0 filenames; need at least twonces Command line options cheatsheet (full details at http://nco.sf.net/nco.html#nces):nces [-3] [-4] [-6] [-7] [-A] [--bfr sz] [-C] [-c] [--cnk_byt sz] [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min min] [--cnk_plc plc] [--cnk_scl sz] [-D nco_dbg_lvl] [-d ...]  [--dbl|flt] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [-L lvl] [-l path] [--msa] [-n ...] [--no_tmp_fl] [--nsm_fl] [--nsm_grp] [--nsm_sfx] [-O] [-o out.nc] [-p path] [-R] [-r] [--ram_all] [-t thr_nbr] [--unn] [-v ...] [-X box] [-x] [-y op_typ] in.nc [...] [out.nc]-3, --3, --fl_fmt=classic        Output file in netCDF3 CLASSIC (32-bit offset) storage format-4, --4, --netcdf4                Output file in netCDF4 (HDF5) storage format-6, --6, --64, --fl_fmt=64bit        Output file in netCDF3 64-bit offset storage format-7, --7, --fl_fmt=netcdf4_classic        Output file in netCDF4 CLASSIC format (3+4=7)-A, --apn, --append        Append to existing output file, if any    --bfr_sz, --buffer_size sz        Buffer size to open files with-C, --nocoords                Associated coordinate variables should not be processed-c, --crd, --coords        Coordinate variables will all be processed    --cnk_dmn, --chunk_dimension nm,sz        Chunksize of dimension nm is sz    --cnk_map, --chunk_map map                Chunking map [dmn,lfp,prd,rd1,rew,scl,xpl,xst]    --cnk_min, --chunk_min min                Minimum size [B] of variable to chunk    --cnk_plc, --chunk_policy plc        Chunking policy [all,g2d,g3d,xpl,xst,uck]    --cnk_scl, --chunk_scalar sz        Chunksize scalar (for all dimensions)-D, --dbg_lvl, --debug-level lvl        Debug-level is lvl-d, --dmn, --dimension dim,[min][,[max]][,[stride]] Dimension's limits and stride in hyperslab    --dbl, --flt, --rth_dbl|flt        dbl: Always promote single- to double-precision b4 arithmetic (default). flt: OK with single-precision arithmetic.-F, --ftn, --fortran        Fortran indexing conventions (1-based) for I/O    --fl_fmt, --file_format fmt        File format [classic,64bit,netcdf4,netcdf4_classic]-G, --gpe [grp_nm][:[lvl]]        Group Path Editing path, levels to replace-g, --grp grp1[,grp2[...]] Group(s) to process (regular expressions supported)-H, --fl_lst_in, --file_list        Do not create "input_file_list" global attribute-h, --hst, --history        Do not append to "history" global attribute    --hdf_upk, --hdf_upk        HDF unpack convention: unpacked=scale_factor*(packed-add_offset)    --hdr_pad, --header_pad        Pad output header with nbr bytes-L, --dfl_lvl, --deflate lvl        Lempel-Ziv deflation (lvl=0..9) for netCDF4 output-l, --lcl, --local path        Local storage path for remotely-retrieved files-n, --nintap nbr_files,[nbr_numeric_chars[,increment]] NINTAP-style abbreviation of file list    --no_tmp_fl                Do not write output to temporary file    --nsm_fl, --ensemble_file        Ensembles comprise equally weighted files    --nsm_grp, --ensemble_group        Ensembles comprise equally weighted groups    --nsm_sfx, --ensemble_suffix        Place ensemble output in group parent/parent+nsm_sfx-o, --output, --fl_out fl_out        Output file name (or use last positional argument)-O, --ovr, --overwrite        Overwrite existing output file, if any-p, --pth, --path path        Path prefix for all input filenames-R, --rtn, --retain        Retain remotely-retrieved files after use-r, --revision, --vrs, --version        Compile-time configuration and/or program version    --ram_all, --diskless_all        Open netCDF3 files and create output files in RAM-t, --thr_nbr, --threads, --omp_num_threads thr_nbr        Thread number for OpenMP    --unn, --union        Select union of specified groups and variables-v, --variable var1[,var2[...]] Variable(s) to process (regular expressions supported)-X, --auxiliary lon_min,lon_max,lat_min,lat_max        Auxiliary coordinate bounding box-x, --xcl, --exclude        Extract all variables EXCEPT those specified with -v-y, --op_typ, --operation op_typ        Arithmetic operation: avg,min,max,ttl,sqravg,avgsqr,sqrt,rms,rmssdnin.nc [...]                Input file namesout.nc                        Output file name (or use -o switch)Eight ways to find more help on nces and/or NCO:1. Examples:     http://nco.sf.net/nco.html#xmp_nces2. Ref. manual:  http://nco.sf.net/nco.html#nces3. User Guide:   http://nco.sf.net#RTFM4. Manual pages: 'man nces', 'man nco', ...5. Homepage:     http://nco.sf.net6. FAQ:          http://nco.sf.net#FAQ7. Help Forum:   http://sf.net/p/nco/discussion/98308. Publications: http://nco.sf.net#pubPost questions, suggestions, patches at http://sf.net/projects/nco


妥妥的~~~~~~
===============================================================================================================================
依照以上的步骤是可以完美安装NCO的,good luck~~
感谢一个叫Gavin的家伙提供的脚本作为参考,免去了很多摸索过程 http://sourceforge.net/p/nco/discussion/9830/thread/8e006deb








antlr-2.7.7.tar.gz

3.48 MB, 下载次数: 153, 下载积分: 金钱 -5

gsl.tar.gz

3.37 MB, 下载次数: 125, 下载积分: 金钱 -5

hdf5-1.8.6.tar.gz

7.19 MB, 下载次数: 88, 下载积分: 金钱 -5

nco-4.4.7.tar.gz

7.61 MB, 下载次数: 112, 下载积分: 金钱 -5

netcdf-4.1.1.tar.gz

10.68 MB, 下载次数: 170, 下载积分: 金钱 -5

udunits-2.2.17.tar.gz

968.7 KB, 下载次数: 103, 下载积分: 金钱 -5

zlib-1.2.5.tar.gz

531.88 KB, 下载次数: 60, 下载积分: 金钱 -5

评分

参与人数 1金钱 +22 贡献 +6 收起 理由
又是那隻貓 + 22 + 6

查看全部评分

密码修改失败请联系微信:mofangbao
发表于 2014-12-10 16:51:34 | 显示全部楼层
大赞楼主{:eb502:}{:eb502:}准备在NCO的道路上抱您大腿
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2014-12-10 17:28:29 | 显示全部楼层
yrovl 发表于 2014-12-10 16:51
大赞楼主准备在NCO的道路上抱您大腿

{:eb500:}{:eb500:}{:eb500:}{:eb500:}{:eb500:}
密码修改失败请联系微信:mofangbao
发表于 2015-2-23 00:26:05 | 显示全部楼层
谢谢分享!

评分

参与人数 1金钱 +20 收起 理由
letsdo8 + 20

查看全部评分

密码修改失败请联系微信:mofangbao
发表于 2015-2-24 09:02:42 | 显示全部楼层
对于LINUX用的好的,表示钦佩
密码修改失败请联系微信:mofangbao
发表于 2015-3-18 10:19:38 | 显示全部楼层
给力,顶顶顶{:5_235:}
密码修改失败请联系微信:mofangbao
发表于 2015-3-23 17:46:28 | 显示全部楼层
感谢楼主分享
密码修改失败请联系微信:mofangbao
发表于 2015-4-22 15:06:30 | 显示全部楼层
谢谢楼主分享{:eb502:}{:eb502:}{:eb502:}
密码修改失败请联系微信:mofangbao
发表于 2015-9-10 21:04:51 来自手机 | 显示全部楼层
感谢楼主,按照你的步骤,安装过程中虽然出现了很多错误,可能是因为我用的是ifort的编译器,最后弄完了,试了试,nco里的几个命令竟然能用
密码修改失败请联系微信:mofangbao
发表于 2015-10-21 09:21:56 | 显示全部楼层
                      >> E R R O R <<
============================================================

g++ -O2 -DNDEBUG -felide-constructors -pipe -c  -I . -I /usr/local/src/antlr-2.7.7/scripts/../lib/cpp /usr/local/src/antlr-2.7.7/lib/cpp/src/../../../lib/cpp/src/CharScanner.cpp

============================================================
Got an error while trying to execute  command  above.  Error
messages (if any) must have shown before. The exit code was:
exit(1)
按楼主给的方法,安装第一个antlr出现如上错误,请问楼主这是什么情况?该怎么解决?
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表