可以的,Ubuntu 完全可以编译 Fortran 程序。下面是常见做法:
最常用的是 GNU Fortran(gfortran):
sudo apt update
sudo apt install gfortran
安装完成后检查版本:
gfortran --version
例如,创建一个 hello.f90:
program hello
print *, "Hello, Fortran!"
end program hello
编译:
gfortran hello.f90 -o hello
运行:
./hello
gfortran test.f90 -O2 -o test # 优化
gfortran test.f90 -Wall # 显示警告
如果你有具体的 Fortran 版本(如 F77 / F90 / F2003 / F2008)或项目类型(如 Makefile、CMake),我可以给你更具体的建议。