[英]How to get started with gfortran on a Mac?
Just finished installing the compiler gfortran 6.1.刚刚安装编译器gfortran 6.1。 El Capitan.
埃尔卡皮坦。 Next, I want to know how to run a file.
接下来,我想知道如何运行文件。 So, I have a few questions:
所以,我有几个问题:
A step by step guide would be a great help.一步一步的指南将是一个很大的帮助。 I am a first time Mac user.
我是第一次使用 Mac 用户。 :)
:)
gfortran /your/source/file
that would be with an absolute path. gfortran /your/source/file
将使用绝对路径。 If you are in the directory of the source file already you do not need to specify the complete path. Step by step "hello world": 一步一步“你好世界”:
Just to give a command line example without the need for an editor (this is not what you typically would do): 只是给出一个命令行示例而不需要编辑器(这不是你通常会做的):
Open the terminal, then enter 打开终端,然后输入
cat >hello.f90 <<EOF program hello implicit none write(*,*) 'hello world' end program hello EOF
Compile your program in the terminal with: gfortran hello.f90
使用以下
gfortran hello.f90
在终端中编译您的程序: gfortran hello.f90
./a.out
./a.out
在终端中执行它 If you want another name use the -o
option: 如果您想要其他名称,请使用
-o
选项:
gfortran -o hello hello.f90 ./hello
myapp.f90 to see its result: myapp.f90 查看结果:
gfortran myapp.f90 -o myapp.exe !this line make myapp.exe by myapp.f90 gfortran myapp.f90 -o myapp.exe !这一行通过 myapp.f90 生成 myapp.exe
myapp "" OUTPUT.DAT !this line execute myapp.exe myapp "" OUTPUT.DAT !这一行执行 myapp.exe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.