多语言展示
当前在线:1388今日阅读:2今日分享:38

macos的ifort+xcode教程

macos的intel fortran+xcode的配置教程
方法/步骤
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

5

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

6

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

7

在Build Setting中向下滑找到intel fortran- Performance Library Build Compoents选项,在其中use intel math kernel library 中选择 use threaded intel math kernel library(-mkl-parallel)

8

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

9

在Run选项的Environment Variables中点击加号,Name中填入DYLD_LIBRARY_PATH,value中填入lib所在的文件夹地址,可能不同版本的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

10

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

推荐信息