centos配置hdf5和netcdf的fortran环境

爱茂勋
2023-12-01


(1)Build zlib
$ sudo ./configure --prefix=/usr/local/netcdf4
$ make
$ make check
$ sudo make install
(2)Build HDF5
Then you build HDF5, specifying the location of the zlib library:
$sudo ./configure --with-zlib=/usr/local/netcdf4 --prefix=/usr/local/netcdf4
$sudo make             
$sudo make check
$sudo make install
(3)build curl
$sudo  ./configure --with-zlib=/usr/local/netcdf4 --prefix=/usr/local/netcdf4
$ make
$ make check
$ sudo make install
(4)Build netcdf4.4.1.1
After HDF5 is done, build netcdf-c, specifying the location of the HDF5, zlib, and (if built into HDF5) the curl header files and libraries in the CPPFLAGS and LDFLAGS environment variables.
$ CPPFLAGS=-I/usr/local/netcdf4/include LDFLAGS=-L/usr/local/netcdf4/lib ./configure --prefix=/usr/local/netcdf4
$sudo apt-get install m4 (如果提示没有m4的话,否则可以不执行)
$  make
$  make check
$  sudo make install
(5)Build netcdf4-fortran-4.4.4
$ export LD_LIBRARY_PATH=/usr/local/netcdf4/lib:${LD_LIBRARY_PATH}
$sudo CPPFLAGS=-I/usr/local/netcdf4/include LDFLAGS=-L/usr/local/netcdf4/lib ./configure --prefix=/usr/local/netcdf4 CC=gcc FC=gfortran     #可用gfortran或ifort,要与pycnal安装一致
$  sudo make
$ sudo make check
$  sudo make install
---------------------------------------------------------------------------
添加环境变量:
$ sudo gedit ~/.bashrc
export NETCDF=/usr/local/netcdf4
export PATH=$NETCDF/bin:$PATH
export CPPFLAGS=-I/usr/local/netcdf4/include
export LDFLAGS=-L/usr/local/netcdf4/lib
export LD_LIBRARY_PATH=/usr/local/netcdf4/lib:${LD_LIBRARY_PATH}
$source ~/.bashrc

-----------------------------------------------------------------------------------------------------------------------

相关链接:https://www.jianshu.com/p/90ecc0580bd1

 

 类似资料: