在 CentOS 上升级(或安装更新版本的)Fortran 编译器(通常是 gfortran),有几种常见方式。下面按推荐程度从高到低说明。
CentOS 7 默认 gcc/gfortran 很老(4.8),可以使用 DevToolset 升级到新版本。
sudo yum install -y centos-release-scl
sudo yum install -y devtoolset-11-gcc-gfortran
scl enable devtoolset-11 bash
查看版本:
gfortran --version
重启终端后需重新
scl enable,或写入.bashrc
CentOS 8 / Stream 可使用 AppStream:
sudo dnf install -y gcc-gfortran
查看版本:
gfortran --version
如需更新:
sudo dnf update gcc-gfortran
sudo yum groupinstall -y "Development Tools"
sudo yum install -y gmp mpfr mpc
wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
tar -xzf gcc-13.2.0.tar.gz
cd gcc-13.2.0
./contrib/download_prerequisites
mkdir build && cd build
../configure --enable-languages=fortran --disable-multilib
make -j$(nproc)
sudo make install
| CentOS | 默认 gfortran | 可升级到 |
|---|---|---|
| 7 | 4.8 | 11(SCL) |
| 8 | 8/10 | 11+ |
| Stream | 11+ | 最新 |
ifort,需单独安装 Intel oneAPI如果你告诉我:
我可以给你精确命令。