wiki:nco_install

Version 5 (modified by lalibert, 8 years ago) (diff)

--

Compliling NCO as a non-root user

  1. Install libs4cdo. Instructions can be found here.
  2. Create a local installation directory in your home. In BASH:
    mkdir -p ~/local/nco
    export NCO_HOME="~/local/nco"
    export CDO_HOME="~/local/cdo"
    
  3. Run the following script and hope for the best! Here's the installation we were able to get:
    ncap2 -r
    
    NCO netCDF Operators version "4.0.8"
    ncap2 version 4.0.8
    Linked to netCDF library version 4.1.2
    Copyright (C) 1995--2011 Charlie Zender
    NCO is free software and comes with A BIG FAT KISS and ABOLUTELY NO WARRANTY
    License: GNU General Public License (GPL) Version 3
    Homepage: http://nco.sf.net
    User's Guide: http://nco.sf.net/nco.html
    Configuration Option:	Active?	Meaning or Reference:
    Check _FillValue	Yes	http://nco.sf.net/nco.html#mss_val
    Check missing_value	No	http://nco.sf.net/nco.html#mss_val
    Compressed netCDF3	No	http://nco.sf.net/nco.html#znetcdf (pre-alpha)
    DAP clients (libdap)	No	http://nco.sf.net/nco.html#dap
    DAP clients (libnetcdf)	Yes	http://nco.sf.net/nco.html#dap
    Debugging: Custom	No	Pedantic, bounds checking (slowest execution)
    Debugging: Symbols	No	Produce symbols for debuggers (e.g., dbx, gdb)
    GNU Scientific Library	Yes	http://nco.sf.net/nco.html#gsl
    Internationalization	No	http://nco.sf.net/nco.html#i18n (pre-alpha)
    MPI parallelization	No	http://nco.sf.net/nco.html#mpi (beta)
    netCDF3 64-bit files	Yes	http://nco.sf.net/nco.html#lfs
    netCDF4/HDF5		Yes	http://nco.sf.net/nco.html#nco4
    OpenMP SMP threading	No	http://nco.sf.net/nco.html#omp
    Optimization: run-time	No	Fastest execution possible (slowest compilation)
    Parallel netCDF3	No	http://nco.sf.net/nco.html#pnetcdf (pre-alpha)
    Shared libraries built	No	Small, dynamically linked executables
    Static libraries built	Yes	Large executables with private namespaces
    UDUnits conversions	Yes	http://nco.sf.net/nco.html#udunits
    UDUnits2 conversions	No	http://nco.sf.net/nco.html#udunits
    Wildcarding (regex)	Yes	http://nco.sf.net/nco.html#rx
    
    #THIS SCRIPT COMPILES NCO ASSUMING LIBS4CDO WAS INSTALLED
    #FREDERIC LALIBERTE AT THE UNIVERSITY OF TORONTO, 2012
    #
    #MODIFIED FROM A POSTING BY kwilcox at
    #http://sourceforge.net/projects/nco/forums/forum/9830/topic/4089501
    
    #CREATE SOURCE CODE REPOSITORY
    INSTALL_PATH=$NCO_HOME
    mkdir -p $INSTALL_PATH/src
    
    #FLAGS FOR INSTALLING LIBRABRIES
    INSTALL_ANTLR=1
    INSTALL_UDUNITS=1
    INSTALL_GSL=1
    
    
    echo "Must specify NETCDF4_DIR and HDF5_DIR."
    echo "If libs4cdo was installed, point to that installation"
    NETCDF4_DIR=$CDO_HOME
    HDF5_DIR=$CDO_HOME
    
    ############# ANTLR2 #################
    APP=antlr-2.7.7
    ANTLR_PATH=$INSTALL_PATH/$APP
    if [ "$INSTALL_ANTLR" -eq "1" ]; then
    rm -rf $ANTLR_PATH
    cd $INSTALL_PATH/src
    
    rm -rf ${APP}
    wget http://www.antlr2.org/download/${APP}.tar.gz
    tar xzf ${APP}.tar.gz ; cd ${APP}
    
    # Bug in antlr-2.7.7 -------------------
    sed -i "13a #include <strings.h>" lib/cpp/antlr/CharScanner.hpp
    sed -i "14a #include <cstdio>" lib/cpp/antlr/CharScanner.hpp
    #The previous lines were extremely important for a successful build, FBL
    
    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
    fi
    #########################################
    
    ################ UDUNITS #################
    APP=udunits-2.1.20
    UDUNITS_PATH=$INSTALL_PATH/$APP
    if [ "$INSTALL_UDUNITS" -eq "1" ]; then
    rm -rf $UDUNITS_PATH
    cd $INSTALL_PATH/src
    
    rm -rf ${APP}*
    wget ftp://ftp.unidata.ucar.edu/pub/udunits/${APP}.tar.gz
    tar xzf ${APP}.tar.gz ; cd ${APP}
    
    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
    fi
    #########################################
    
    #GSL
    # GSL ###################################
    APP=gsl-1.15
    GSL_PATH=$INSTALL_PATH/$APP
    if [ "$INSTALL_GSL" -eq "1" ]; then
    rm -rf $GSL_PATH
    cd $INSTALL_PATH/src
    
    rm -rf ${APP}*
    wget http://gnu.mirror.iweb.com/gnu/gsl/${APP}.tar.gz
    tar xzf ${APP}.tar.gz ; cd ${APP}
    
    ./configure \
    --prefix=$GSL_PATH \
    CFLAGS="-fexceptions" | tee $APP.config
    make 2>&1 | tee $APP.make
    make install 2>&1 | tee $APP.install
    fi
    #########################################
    
    #FINALLY!
    # NCO ###################################
    APP=nco-4.0.8
    NCO_PATH=$INSTALL_PATH/$APP
    rm -rf $NCO_PATH
    cd $INSTALL_PATH/src
    
    rm -rf ${APP}*
    wget http://nco.sourceforge.net/src/${APP}.tar.gz
    tar xzf ${APP}.tar.gz ; cd ${APP}
    
    export LD_LIBRARY_PATH=$HDF5_DIR/lib:$LD_LIBRARY_PATH
    export PATH=$HDF5_DIR/bin:$PATH
    export LD_LIBRARY_PATH=$NETCDF4_DIR/lib:$LD_LIBRARY_PATH
    export PATH=$NETCDF4_DIR/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=$GSL_PATH/lib:$LD_LIBRARY_PATH
    export PATH=$GSL_PATH/bin:$PATH
    
    CC=gcc CXX='' \
    NETCDF_INC=$NETCDF4_DIR/include \
    NETCDF_LIB=$NETCDF4_DIR/lib \
    NETCDF4_ROOT=$NETCDF4_DIR \
    HDF5_LIB_DIR=$HDF5_DIR/lib \
    UDUNITS2_PATH=$UDUNITS_PATH \
    LDFLAGS="-L$ANTLR_PATH/lib -lantlr \
    -lhdf5_hl -lhdf5 -L$NETCDF4_DIR/lib -lnetcdf" \
    CFLAGS="-I$HDF5_DIR/include \
    -L$HDF5_DIR/lib \
    -I$ANTLR_PATH/include \
    -L$ANTLR_PATH/lib" \
    CPPFLAGS="-I$HDF5_DIR/include \
    -L$HDF5_DIR/lib \
    -I$ANTLR_PATH/include \
    -L$ANTLR_PATH/lib" \
    ./configure \
    --prefix=$NCO_PATH \
    --disable-shared \
    --disable-udunits2 \
    --enable-netcdf-4 2>&1 | tee $APP.config
    echo "#define ENABLE_NETCDF4 1" >> config.h
    make 2>&1 | tee $APP.make
    make install 2>&1 | tee $APP.install
    
  4. Update your .bashrc:
    export PATH=$HOME/local/ndo/bin:$PATH