Just finished installing the compiler 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. :)
On every Mac computer, there is a application called terminal that allows you to communicate with the computer and get stuff done. Terminal will then ask a password, enter it and allow the program to install on your computer. This is your compiler; it's called gfortran!
The OS X Fortran compiler supports a full range of project targets including command-line programs and GUI based applications. It provides a complete 64-bit macOS/OS X Fortran compiler solution and supports mixed language development by interfacing with Apple's Xcode C/C++ compiler.
5. To create a new fortran program click on file>New>File>Select Fortran Source>Hit Go and follow the instructions in the dialog box. 6. To open an existing fortran source file select File>Open> and navigate to the fortran source file.
gfortran /your/source/file
that would be with an absolute path. 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
./a.out
If you want another name use the -o
option:
gfortran -o hello hello.f90
./hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With