macos的ifort+xcode教程

2025-04-28 00:02:25

1、我们韦蛾拆篮经常在windows上用intel Fortran ,在Microsoft Visual Studio在写代码编译,在linux或者macos的终端中用命令去编译fortran文件也是很方便的,但是intel Fortran compilers在官网也上提供了在macbook使用xcode+ intel fortran的方法编辑编译fortran程序。下面将具体配置说明如下:首先根据macbook的macos版本下载安装可以使用的xcode

2、下载 intel fortran compilers for mac (下文缩写为ifort),学生或者科研单位可以用学校的邮箱申请免费的版本,也就是Microsoft会给你一个SN号或者license。 (一定要用学校的邮箱申请)

3、在安装ifort的时候,选择安装 Command line tool+xcode的配置环境的选项。这个时候会有窗口跳出,选择xcode的安装文件,在applications里面选择xcode就可以了。到这一步算是xcode+ifort安装完毕。

4、打开xcode,在 welcome to xcode的界面,选择create a new xcode project

macos的ifort+xcode教程

5、选择macOs,application选择 Command Line Tool,点击next

macos的ifort+xcode教程

6、对product name取个名字(我随便取的a),language选择C即可,最后给project选择一个位置放置。 左边选择a的project,点击右边窗口的Build Rules,再点击+号,process选择Fortran Source files, using选择安装的intel Fortran。

macos的ifort+xcode教程

7、在Build Setting中向下滑找到intel fortran- Performance Library Build C泠贾高框ompoents选项,在其中use intel math kernel library 中选择 use threaded intel math kernel library(-mkl-parallel)

macos的ifort+xcode教程

8、可以将project a中加入f90的文件,也可以将main.c改为main.f90,将fortran的代码写入。 配置fortran的环境,在菜单栏中选Product<Seheme<edit scheme

macos的ifort+xcode教程

9、在Run选项的Environment Variables中点击加号,Name中填入DYLD_LIBRARY_PATH,value中填入li芟鲠阻缒b所在的文件夹地址,可能不同版本的intel fortran 和不同macbook的系统,lib文件地址也不同,我的是:/opt/intel/compilers_and_libraries_2018.1.126/mac/compiler/lib:/opt/intel/compilers_and_libraries_2018.1.126/mac/mkl/lib

macos的ifort+xcode教程

10、最后运行程序,如我正常输出的的hello world,值得注意的是,macOS的ifort中输出文件,导入文件的数据,要加上文件的具体地址如 Open(unit=1,file=’/user/yourname/desktop/a/a.dat’),这样xcode+ifort的配置就完成了,方法比较笨,有什么不对,希望大家包涵。

macos的ifort+xcode教程
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢