Rate This Document
Findability
Accuracy
Completeness
Readability

Installing NetCDF-Fortran

Procedure

  1. Use PuTTY to log in to the server as the root user.
  2. Go to the installation directory.
    cd /path/to/netcdf
  3. Obtain the source package and rename it.
    wget https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.4.5.tar.gz
    mv v4.4.5.tar.gz netcdf-fortran-4.4.5.tar.gz
  4. Decompress the source package.
    tar -zxvf netcdf-fortran-4.4.5.tar.gz
  5. Go to the directory generated after the decompression.
    cd netcdf-fortran-4.4.5
  6. Configure the compilation.
    ./configure --prefix=/path/to/netcdf --build=aarch64-unknown-linux-gnu --enable-shared --with-pic --disable-doxygen --enable-largefile --enable-static CC=clang CXX=clang++ FC=flang F77=flang CPPFLAGS="-I/path/to/hdf5/include -I/path/to/netcdf/include " LDFLAGS="-L/path/to/hdf5/lib -L/path/to/netcdf/lib -Wl,-rpath=/path/to/hdf5/lib -Wl,- rpath=/path/to/netcdf/lib" CFLAGS="-L/path/to/hdf5/lib -L/path/to/netcdf/lib -I/path/to/hdf5/include -I/path/to/netcdf/include -fPIC" CXXFLAGS="-L/path/to/hdf5/lib -L/path/to/netcdf/lib -I/path/to/hdf5/include -I/path/to/netcdf/include -fPIC" FCFLAGS="-L/path/to/hdf5/lib -L/path/to/netcdf/lib -I/path/to/hdf5/include - I/path/to/netcdf/include -fPIC"

  7. Apply the patch package.
    1. Create a libtool.patch file.
      vi libtool.patch
    2. Press i to enter the edit mode and add the following content:
      diff -ruN hdf5-1.10.1/libtool hdf5-1.10.1-new/libtool
      --- hdf5-1.10.1/libtool 2019-12-02 20:02:56.270676503 +0000
      +++ hdf5-1.10.1-new/libtool 2019-12-02 20:03:05.062708034 +0000
      @@ -11832,7 +11832,7 @@
      pic_flag=""
      # How to pass a linker flag through the compiler.
      -wl=""
      +wl="-Wl,"
      # Compiler flag to prevent dynamic linking.
      link_static_flag=""
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  8. Install the patch.
    patch -p1 < libtool.patch

  9. Perform the compilation and installation.
    make -j 8

    make install

  10. Set the environment variables.
    export PATH=/path/to/netcdf/bin:$PATH
    export LD_LIBRARY_PATH=/path/to/netcdf/lib:$LD_LIBRARY_PATH