在Linux上安装Fortran编译器的简明指南
一 安装前检查
gfortran --version。若返回版本号,说明已安装;若未安装,继续按下方步骤进行。该检查方式简单可靠,适用于所有主流发行版。二 发行版对应的安装命令
| 发行版/系列 | 包管理器 | 安装命令 | 备注 |
|---|---|---|---|
| Debian/Ubuntu | apt | sudo apt-get update && sudo apt-get install gfortran |
建议同时安装构建工具:sudo apt-get install build-essential |
| CentOS 7 | yum | sudo yum install gcc-gfortran |
老版本 CentOS 使用 yum |
| Fedora | dnf | sudo dnf install gcc-gfortran |
新一代 Fedora 使用 dnf |
| openSUSE | zypper | sudo zypper install gcc-fortran |
适用于 openSUSE 系列 |
三 验证安装与第一个程序
gfortran --version,应显示 GNU Fortran 的版本信息。program hello
print *, "Hello, World!"
end program hello
gfortran hello.f90 -o hello
./hello
gfortran -Wall hello.f90 -o hello。以上步骤完成后,即可确认编译器工作正常。四 科学计算常用库与并行环境
五 其他编译器与进阶选择