以下是在CentOS上搭建Fortran开发环境的步骤:
sudo yum update -y
,sudo yum install gcc-gfortran -y
。安装完成后,通过gfortran --version
验证安装。sudo yum install make git cmake -y
。若安装了Intel Fortran编译器或其他自定义路径的编译器,需将其路径添加到~/.bashrc
文件中,如export PATH=/path/to/compiler/bin:$PATH
,然后运行source ~/.bashrc
使配置生效。
sudo rpm -ivh code-VERSION-x86_64.rpm
。ms-vscode.cpptools
、hansec.fortran-ls
等。创建一个简单的Fortran程序,如hello_world.f90
,用gfortran -o hello hello_world.f90
编译,再运行./hello
,若输出“Hello, World!”,则环境配置成功。