在 Ubuntu 上编译 Fortran 程序,常用以下几种工具/编译器:
sudo apt update
sudo apt install gfortran
gfortran hello.f90 -o hello
./hello
# 示例(需先注册/下载 oneAPI)
sudo apt install intel-oneapi-compiler-fortran
ifort hello.f90 -o hello
# 或新版
ifx hello.f90 -o hello
sudo apt install flang
flang hello.f90 -o hello
sudo apt install make
sudo apt install cmake
| 场景 | 推荐 |
|---|---|
| 学习 / 普通使用 | ✅ gfortran |
| 高性能计算 | Intel ifort/ifx |
| 研究 LLVM 生态 | Flang |
如果你是刚开始学 Fortran,直接用 gfortran + make 就足够了。需要我给你一个完整示例吗?