你提到“CentOS Fortran 错误”,但没有给具体的错误信息,所以下面我先把CentOS 上常见的 Fortran 错误及解决办法整理出来,你可以对照看。如果方便,把完整报错贴出来,我可以精准帮你分析。
bash: gfortran: command not found
CentOS 默认没装 Fortran 编译器。
sudo yum install gcc-gfortran
或(CentOS 8 / Stream):
sudo dnf install gcc-gfortran
验证:
gfortran --version
cannot find -lxxx
缺少对应的科学计算库(如 BLAS、LAPACK、MPI)
sudo yum install blas-devel lapack-devel
sudo yum install openmpi-devel
使用 MPI 时:
module load mpi
mpif90 test.f90
gfortran -g -fcheck=all -o test test.f90
./test
增大栈空间:
ulimit -s unlimited
Error: Rank mismatch
或
Non-numeric character in statement
老 Fortran 77 代码用新编译器
gfortran -ffixed-form old.f
或改用 g77(不推荐,已淘汰)
如果是 ifort:
bash: ifort: command not found
需要:
source /opt/intel/oneapi/setvars.sh
请贴出:
gfortran xxx.f90 -o xxx)cat /etc/redhat-release)如果你愿意,直接把报错截图或文字发出来,我可以一步一步帮你解决。