How to compile swan+adcirc with netcdf4 support

last updated – 05/13/2015

 

Here is some instruction on how to build adcirc with NetCDF4 support using the Intel Fortran compiler (ifort). These notes are specific to the University of Central Florida (UCF) STOKES cluster (stokes.ist.ucf.edu), but should be adaptable for other clusters.

  1. Set Fortran (FC) and C (CC) compiler and flags you wish to useexport FC=ifort
    export CC=icc
    export CXX=icpc
    export FC=ifort
    export F77=ifort
    export F90=ifort
    export CFLAGS='O3 -xsse4.2 -ip'
    export CXXFLAGS='O3 -xsse4.2 -ip'
    export FCFLAGS='O3 -xsse4.2 -ip'
  2. Build zlibDownload zlib source code from http://www.zlib.net/Create a directory to download zlib source. For this example I will use the the directory: “/apps/CHAMPS/zlib”
    wget http://zlib.net/zlib-1.2.8.tar.gz
    tar -zxvf zlib-1.2.8.tar.gz
    cd zlib-1.2.8
    Build zlib | In this example, I will build to “/apps/CHAMPS/local/zlib-1.2.8”
    ./configure --prefix=/apps/CHAMPS/local/zlib-1.2.8
    make
    make check
    make install
  3. Build hdf5Download hdf5 source code from http://www.hdfgroup.org/HDF5/release/obtain5.htmlCreate a directory to download hdf5 source. For this example I will use the the directory: “/apps/CHAMPS/hdf5”
    wget http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.13.tar.gz
    tar -zxvf hdf5-1.8.13.tar.gz
    cd hdf5-1.8.13
    Build hdf5 with netcdf4 support | In this example I will build to “/apps/CHAMPS/local/hdf5-1.8.13”
    ./configure --prefix=/apps/CHAMPS/local/hdf5-1.8.13 --with-zlib=/apps/CHAMPS/local/zlib-1.2.8 --enable-fortran --enable-cxx
    make
    make check
    make install
  4. Build NetCDF-C with netcdf4 supportDownload NetCDF-C source code from http://www.unidata.ucar.edu/downloads/netcdf/index.jspCreate a directory to download NetCDF source. For this example I will use the the directory: “/apps/CHAMPS/netcdf”
    wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.2.tar.gz
    tar -zxvf netcdf-4.3.2.tar.gz
    cd netcdf-4.3.2
    Build NetCDF-C with NetCDF4 support | In this example I will build to “/apps/CHAMPS/local/netcdf-4.3.2”
    export CPPFLAGS=-I/apps/CHAMPS/local/hdf5-1.8.13/include
    export LDFLAGS=-L/apps/CHAMPS/local/hdf5-1.8.13/lib
    ./configure --prefix=/apps/CHAMPS/local/netcdf-4.3.2 #Note: You may have to include --disable-dap if you did not install libcurl
    make
    make check
    make install
  5. Build NetCDF-C with netcdf4 supportDownload NetCDF-F source code from http://www.unidata.ucar.edu/downloads/netcdf/index.jspCreate a directory to download NetCDF source. For this example I will use the the directory: “/apps/CHAMPS/netcdf”
    wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.0.tar.gz
    tar -zxvf netcdf-fortran-4.4.0.tar.gz
    cd netcdf-fortran-4.4.0
    Build NetCDF-F with NetCDF4 support | In this example I will build to “/apps/CHAMPS/local/netcdf-fortran-4.4.0”
    export CPPFLAGS=-I/apps/CHAMPS/local/netcdf-4.3.2/include
    export LDFLAGS=-L/apps/CHAMPS/local/netcdf-4.3.2/lib -lnetcdf' #This includes the
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/CHAMPS/local/netcdf-4.3.2/lib
    ./configure --prefix=/apps/CHAMPS/local/netcdf-fortran-4.4.0
    make
    make check
    make install
  6. Add library paths to .bashrc file# FOR NetCDF support
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/CHAMPS/local/zlib-1.2.8/lib/
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/CHAMPS/local/hdf5-1.8.8-intel-13.0/lib/
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/CHAMPS/local/netcdf-4.3.2-Intel-13.0/lib/
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/CHAMPS/local/netcdf-fortran-4.4.0/lib/
  7. Build adcircGo to the “swan” directory.
    Edit the macros.inc flag in the swan directory for your system and desired compiler flags.
    Also, clean this directory:
    make clean ; make clobberGo to the “work” directory.
    Edit the cmplrflags.mk file for your system and desired compiler and flags.
    Add the following to the cmplrflags.mk file:
    SWAN=enable
    NETCDF=enable
    NETCDF4=enable
    NETCDF4_COMPRESSION=enable
    NETCDFHOME=/path/to/NETCDF/FORTRAN/build
    HDF5HOME=/path/to/HDF5/build
    ifeq($(NETCDF),enable))
    FLIBS := $(FLIBS) -L$(NETCDFHOME)/lib -lnetcdff -L/path/to/netcdf-4.3.2-Intel-13.0/lib -lnetcdf -L$(HDF5HOME)/lib -lhdf5 -lhdf5_fortran
    endif

    Also, clean this directory of any previous builds:
    make clean ; make clobberBuild adcprep
    make adcprep
    make padcirc
    make padcswan

I may have left out some intricate details or made a mistake, but I think that is everything. Please let me know if an error is found and I will modify the document.

Sources Used:

  • ADCIRC ListServ
    • Jason Fleming
    • Nate Dill
  • Intel Developer Zone
    • https://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-netcdf-with-the-intel-compilers
    • https://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-hdf5-with-intel-compilers

Permanent link to this article: http://www.mattbilskie.com/how-to-compile-swanadcirc-with-netcdf4-support/