CentOS如何安装Fortran开发工具
导读:CentOS 安装 Fortran 开发工具 一 安装 GNU Fortran 编译器 gfortran 更新索引并安装基础开发组与编译器: 安装开发工具组:sudo yum groupinstall “Development Tool...
CentOS 安装 Fortran 开发工具
一 安装 GNU Fortran 编译器 gfortran
- 更新索引并安装基础开发组与编译器:
- 安装开发工具组:sudo yum groupinstall “Development Tools” -y
- 安装 gfortran:sudo yum install gcc-gfortran -y
- 验证安装:
- 查看版本:gfortran --version
- 说明:在 CentOS 中,Fortran 编译器包名为gcc-gfortran;若系统未预装 gcc,建议同时安装基础开发工具组以获得完整的构建链。
二 安装常用构建与版本控制工具
- 安装常用工具:
- sudo yum install make git cmake -y
- 作用:make 管理构建流程,git 进行版本控制,cmake 管理跨平台构建。
三 可选 安装 VS Code 与 Fortran 语言服务器
- 安装 VS Code(.rpm 方式):
- 下载安装包:wget https://update.code.visualstudio.com/latest/linux-x64/stable -O code.rpm
- 安装:sudo yum install code.rpm -y
- 安装 Fortran 语言服务器(fortls):
- 确保已安装 python3 与 pip3,然后:pip3 install fortran-language-server
- VS Code 插件建议:fortran-language-server、gfortran(用于语法高亮、跳转、格式化与 LSP 支持)。
四 验证与第一个程序
- 创建测试源文件 hello.f90:
program hello_world implicit none print *, 'Hello, World!' end program hello_world - 编译与运行:
- 编译:gfortran -o hello hello.f90
- 运行:**./**hello
- 预期输出:Hello, World!
五 可选 安装 Intel Fortran 编译器 ifort(商业版)
- 适用于需要 ifort 的场景(如 MKL 优化、兼容性要求)。
- 安装步骤要点:
- 确认许可与兼容性(CentOS 7/8 常见),下载 Intel oneAPI HPC Toolkit 或经典版安装包。
- 运行安装程序,按向导完成安装。
- 导入环境(bash):在 ~/.bashrc 中添加
- source /opt/intel/oneapi/setvars.sh
- 或针对经典版:source /opt/intel/composerxe-/bin/compilervars.sh intel64
- 验证:ifort --version
- 提示:Intel 编译器为商业软件,需许可证;安装与路径以官方文档为准。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: CentOS如何安装Fortran开发工具
本文地址: https://pptw.com/jishu/786006.html
