Install NetCdf4 with Hdf5 In Ubuntu Linux

Hai All,

I installed Netcdf4 along with Hdf5 in ubuntu 14.04 LTS 64-bit.

You can follow the below steps to do the same.

szip

Download latest source of zlib from here http://www.zlib.net/ and install it
by

$ ./configure; make; sudo make install

Download szip from http://www.hdfgroup.org/ftp/lib-external/szip/2.1/src/szip-2.1.tar.gz

and extract it.

$ ./configure --prefix=/usr/local/szip
$ make; sudo make install

HDF5

We need to find the path of POSIX to enable threads in hdf configuration.

In the configure of hdf5,  –with-pthread option must point to the directory that contains the POSIX Threads library install ([DIR]/includes/pthread.h, [DIR]/lib/libpthread*)

So lets locate it as shown below.

$ locate pthread.h -> /usr/include/
$ locate libpthread.a -> /usr/lib/x86_64-linux-gnu/
$ locate libpthread.so -> /usr/lib/x86_64-linux-gnu/

Download hdf5 latest source from http://www.hdfgroup.org/HDF5/release/obtainsrc.html

I downloaded http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.13.tar.bz2

and extract it and then go inside

$ ./configure --prefix=/usr/local/hdf5 --enable-fortran --enable-cxx --with-szlib=/usr/local/szip --enable-threadsafe --with-pthread=/usr/include/,/usr/lib/x86_64-linux-gnu/ --enable-hl --enable-shared --enable-unsupported

Note 1: In above configuration removed –enable-parallel, since it gives error on “mpi.h” while doing make.

Note 2: More over ROMS forum suggest that parallel netCDF will not improve much scaleup on model speedup. so lets go with single mode as for now.

SUMMARY OF THE HDF5 CONFIGURATION
========================

General Information:
——————-
HDF5 Version: 1.8.13
Configured on: Mon Feb 2 10:55:19 IST 2015
Configured by: tuxcoder@Ocean
Configure mode: production
Host system: x86_64-unknown-linux-gnu
Uname information: Linux Ocean 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Byte sex: little-endian
Libraries: static, shared
Installation point: /usr/local/hdf5

Compiling Options:
——————
Compilation Mode: production
C Compiler: /usr/bin/gcc
CFLAGS:
H5_CFLAGS: -std=c99 -pedantic -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wfloat-equal -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wdisabled-optimization -Wformat=2 -Wunreachable-code -Wendif-labels -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros -Wunsafe-loop-optimizations -Wc++-compat -Wstrict-overflow -Wlogical-op -Wlarger-than=2048 -Wvla -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -O3 -fomit-frame-pointer -finline-functions
AM_CFLAGS:
CPPFLAGS:
H5_CPPFLAGS: -D_POSIX_C_SOURCE=199506L -DNDEBUG -UH5_DEBUG_API
AM_CPPFLAGS: -I/usr/include/ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_BSD_SOURCE
Shared C Library: yes
Static C Library: yes
Statically Linked Executables: no
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS: -L/usr/local/szip/lib -L/usr/lib/x86_64-linux-gnu/
Extra libraries: -lpthread -lz -ldl -lm
Archiver: ar
Ranlib: ranlib
Debugged Packages:
API Tracing: no

Languages:
———-
Fortran: yes
Fortran Compiler: /usr/bin/gfortran
Fortran 2003 Compiler: no
Fortran Flags:
H5 Fortran Flags:
AM Fortran Flags:
Shared Fortran Library: yes
Static Fortran Library: yes

C++: yes
C++ Compiler: /usr/bin/g++
C++ Flags:
H5 C++ Flags:
AM C++ Flags:
Shared C++ Library: yes
Static C++ Library: yes

Features:
———
Parallel HDF5: no
High Level library: yes
Threadsafety: yes
Default API Mapping: v18
With Deprecated Public Symbols: yes
I/O filters (external): deflate(zlib)
I/O filters (internal): shuffle,fletcher32,nbit,scaleoffset
MPE: no
Direct VFD: no
dmalloc: no
Clear file buffers before write: yes
Using memory checker: no
Function Stack Tracing: no
Strict File Format Checks: no
Optimization Instrumentation: no
Large File Support (LFS): yes

$ make
$ sudo make install

NetCdf4

Download latest netcdf from http://www.unidata.ucar.edu/downloads/netcdf/index.jsp

I downloaded netcdf-4.3.2 from here

extract it and go inside it.

$ CPPFLAGS="-I/usr/local/szip/include -I/usr/local/hdf5/include" 
LDFLAGS="-L/usr/local/szip/lib -L/usr/local/hdf5/lib" 
./configure --prefix=/usr/local/netcdf4 --enable-netcdf-4 --enable-shared
$ make
$ make check

================================================
Testsuite summary for netCDF 4.3.2
================================================
# TOTAL: 2
# PASS: 2
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
================================================

$ sudo make install

Thats’ it!

Advertisements

About arulalant

Currently working as "Project Scientist – C" in National Centre for Medium Range Weather Forecasting (NCMRWF), MoES, Noida, India
This entry was posted in Uncategorized. Bookmark the permalink.

9 Responses to Install NetCdf4 with Hdf5 In Ubuntu Linux

  1. Building NetCDF* with the Intel® compilers
    NetCDF (Network Common Data Form) is a machine-independent, self-describing, binary data format standard for exchanging scientific data. Information about NetCDF can be obtained from the University Corporation for Atmospheric Research (UCAR), website: http://www.unidata.ucar.edu/software/netcdf/.

    Configured by: subha@subha-HP-Z440(subharsgis08@gmail.com)-Workstation
    Configure mode: production
    Host system: x86_64-You-linux-gnu
    Uname information: Linux subha-HP-Z840-Workstation 4.4.0-71-generic #92-XXXXX SMP Fri Mar 24 12:59:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    Byte sex: little-endian
    Libraries: static, shared
    Installation point: XXXXXXXXXXX

    #intel_v17.0.0.109
    export INTEL=/opt/intel
    export PATH=$INTEL/bin:$PATH
    export LD_LIBRARY_PATH=$INTEL/lib:$LD_LIBRARY_PATH
    . $INTEL/bin/ifortvars.sh intel64
    . $INTEL/bin/iccvars.sh intel64
    . $INTEL/bin/compilervars.sh intel64

    export CC=icc
    export CXX=icpc
    export CFLAGS=’-O3 -xHost -ip -no-prec-div -static-intel’
    export CXXFLAGS=’-O3 -xHost -ip -no-prec-div -static-intel’
    export F77=ifort
    export FC=ifort
    export F90=ifort
    export FFLAGS=’-O3 -xHost -ip -no-prec-div -static-intel’
    export CPP=’icc -E’
    export CXXCPP=’icpc -E’
    cd netcdf-4.1.3
    ./configure –prefix=$DIR/netcdf CXX=icpc CC=icc FfC=ifort CPP=’icc -E’ CXXCPP=’icpc -E’–prefix=/usr/local/netcdf4 –enable-netcdf-4 –enable-shared
    make
    make check
    make install
    export PATH=$DIR/netcdf/bin:$PATH
    export NETCDF=$DIR/netcdf

    Like

  2. subharsgis08 says:

    ./configure –prefix=$DIR/hdf5 CXX=icpc CC=icc FC=ifort –with-zlib=$DIR/zlib –with-szlib=$DIR/szip –with-zlib=$DIR/mpich –enable-fortran –enable-fortran2003 –enable-cxx –enable-unsupported –enable-trace –enable-production –enable-static-exec –enable-debug=all –enable-threadsafe –enable-shared –enable-hl –with-pthread

    SUMMARY OF THE HDF5 CONFIGURATION
    =================================

    General Information:
    ——————-
    HDF5 Version: 1.8.15
    Configured on: Thu Mar 30 23:45:53 IST 2017
    Configured by: subha@subha-HP-Z440(subharsgis08@gmail.com)-Workstation
    Configure mode: production
    Host system: x86_64-You-linux-gnu
    Uname information: Linux subha-HP-Z840-Workstation 4.4.0-71-generic #92-XXXXX SMP Fri Mar 24 12:59:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    Byte sex: little-endian
    Libraries: static, shared
    Installation point: XXXXXXXXXXX

    Compiling Options:
    ——————
    Compilation Mode: production
    C Compiler: /opt/intel/compilers_and_libraries_2017.2.174/linux/bin/intel64/icc ( Intel(R) C Intel(R) 64 Compiler Version 17.0.2.174 Build 20170213)
    CFLAGS: -O3 -xHost -ip
    H5_CFLAGS: -std=c99 -O3
    AM_CFLAGS:
    CPPFLAGS: -I/home/subha/Build_HWRF/LIB/grib2/include
    H5_CPPFLAGS: -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -UNDEBUG -DH5AC_DEBUG -DH5B_DEBUG -DH5B2_DEBUG -DH5D_DEBUG -DH5E_DEBUG -DH5F_DEBUG -DH5G_DEBUG -DH5HG_DEBUG -DH5HL_DEBUG -DH5I_DEBUG -DH5MF_DEBUG -DH5MM_DEBUG -DH5O_DEBUG -DH5P_DEBUG -DH5S_DEBUG -DH5T_DEBUG -DH5V_DEBUG -DH5Z_DEBUG -DH5_DEBUG_API
    AM_CPPFLAGS: -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/home/subha/Build_HWRF/LIB/mpich/include -I/home/subha/Build_HWRF/LIB/szip/include
    Shared C Library: yes
    Static C Library: yes
    Statically Linked Executables: yes
    LDFLAGS: -L/home/subha/Build_HWRF/LIB/grib2/lib
    H5_LDFLAGS:
    AM_LDFLAGS: -L/home/subha/Build_HWRF/LIB/mpich/lib -L/home/subha/Build_HWRF/LIB/szip/lib
    Extra libraries: -lpthread -lsz -lz -ldl -lm
    Archiver: ar
    Ranlib: ranlib
    Debugged Packages: ac,b,b2,d,e,f,g,hg,hl,i,mf,mm,o,p,s,t,v,z
    API Tracing: yes

    Languages:
    ———-
    Fortran: yes
    Fortran Compiler: /opt/intel/compilers_and_libraries_2017.2.174/linux/bin/intel64/ifort ( Intel(R) Fortran Intel(R) 64 Compiler Version 17.0.2.174 Build 20170213)
    Fortran 2003 Compiler: yes
    Fortran Flags: -m64
    H5 Fortran Flags: -O3
    AM Fortran Flags:
    Shared Fortran Library: yes
    Static Fortran Library: yes

    C++: yes
    C++ Compiler: /opt/intel/compilers_and_libraries_2017.2.174/linux/bin/intel64/icpc ( Intel(R) C++ Intel(R) 64 Compiler Version 17.0.2.174 Build 20170213)
    C++ Flags: -O3 -xHost -ip
    H5 C++ Flags:
    AM C++ Flags:
    Shared C++ Library: yes
    Static C++ Library: yes

    Features:
    ———
    Parallel HDF5: no
    High Level library: yes
    Threadsafety: yes
    Default API Mapping: v18
    With Deprecated Public Symbols: yes
    I/O filters (external): deflate(zlib),szip(encoder)
    MPE: no
    Direct VFD: no
    dmalloc: no
    Clear file buffers before write: yes
    Using memory checker: no
    Function Stack Tracing: no
    Strict File Format Checks: yes
    Optimization Instrumentation: yes

    Like

  3. Rich says:

    Hi, how can I install netcdf4 with parallel support? I’ve tried every way I can think of, but get errors… it seems that I am unable to link hdf5 with netcdf as netcdf install fails with the error that it cannot find hdf5.h

    I’ve added the –with-hdf5, I’ve enabled parellel on both netcdf and hdf5, I’ve set my environment vars (including the CC and cfflags), uninstalled, reinstalled.. many times.
    All paths are correct.

    I’m on ubuntu 16 on AWS.

    Any ideas?

    Like

  4. Arjun says:

    Thank you so much for your post. I followed all your steps, NetCDF along with HDF5 libraries, is installed successfully; but when I try to run “nc-config” it gives an error that nc-config isn’t installed. The first thing I did was to check the location of installed libraries, and Netcdf4, HDF5, szip are located in “/usr/local/”, as expected; but I am not really sure how to proceed. Please advise.

    Like

  5. Merih says:

    Hi Arulalan,
    Thank you so much for helping !!

    Like

  6. Allen Tsai says:

    Thank you for helping!

    Like

  7. Pingback: How to install ESMF and ESMFPy in Ubuntu using gfortran, gcc, python | Tux Coder

  8. jimmy says:

    thanks with hdf5 under Features: I seem to be missing ” -fomit-frame-pointer -finline-functions”
    also I only have ” I/O filters (external): deflate(zlib),szip(encoder)”
    No internal I/O like yours posted above
    Any ideas ?

    Like

  9. Good. Keep on update your post.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s