可以的,Ubuntu 完全可以运行 Fortran 程序。
Ubuntu 默认通常没有自带 Fortran 编译器,需要手动安装,最常用的是 gfortran(GNU Fortran):
sudo apt update
sudo apt install gfortran
安装完成后可以查看版本:
gfortran --version
例如,创建一个文件 hello.f90:
program hello
print *, "Hello, Fortran on Ubuntu!"
end program hello
编译:
gfortran hello.f90 -o hello
运行:
./hello
输出:
Hello, Fortran on Ubuntu!
gfortran 支持:
在 Ubuntu 上跑 Fortran 常用于:
.f 文件,Fortran 77),同样可以用 gfortran 编译ifort,需单独安装)如果你有具体的 Fortran 代码或报错信息,可以发出来,我可以帮你直接在 Ubuntu 环境下排查。