Installing NetCDF-Fortran
Procedure
- Use PuTTY to log in to the server as the root user.
- Go to the installation directory.
cd /path/to/netcdf
- 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
- Decompress the source package.
tar -zxvf netcdf-fortran-4.4.5.tar.gz
- Go to the directory generated after the decompression.
cd netcdf-fortran-4.4.5
- 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"

- Apply the patch package.
- Create a libtool.patch file.
vi libtool.patch
- 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=""
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Create a libtool.patch file.
- Install the patch.
patch -p1 < libtool.patch

- Perform the compilation and installation.
make -j 8

make install

- Set the environment variables.
export PATH=/path/to/netcdf/bin:$PATH export LD_LIBRARY_PATH=/path/to/netcdf/lib:$LD_LIBRARY_PATH
Parent topic: Configuring the Compilation Environment