Whattt? FORTRAN ? who still codes in FORTRAN in 2017 ???
Well, I’m sure we are still hundreds of people on this earth who have to code in Fortran for one reason or another. And for those who are wondering (or want to remember) how to compile hello world in Fortran, here is how it works.
Remark #1 : It’s not because I code in Fortran from times to times that I’m not a modern woman. I actually code in Fortran 95. Which means, no need for CAPITAL LETTERS. You can even start your instruction at the very first column of your line. Waw. Modern times …
Step 1 : Create a file named hello_world.f95 with these lines in it
program hello print *,"Hello World!" end program hello
Step 2 : Make sure you have gfortran installed on your system
$ which gfortran
Should output something. Otherwise type
$ sudo apt-get install gfortran
Step 3 : Compile your code
$ gfortran -std=f95 -Wextra -Wall -pedantic hello_world.f95 -o hello_world
- -std=f95 asks the compiler to check your code against the Fortran 95 standard
- -Wextra -Wall -pedantic will warn you about many standard violations.
- -o hello_world sets the executable name to “hello_world”
Step 4 : Execute your code
Should output :
That’s it. Now, this is only part one of my series. Next time we’ll see how to make Fortran and C communicate with each other.