February of Fortran
Tags: fortran, beginners, computerscience
Published: 2020-02-29 18:39:11

---
title: February of Fortran
published: true
date: 2020-02-29 18:07:00 UTC
tags: fortran, beginners, computer science
cover_image: https://lautarolobo.xyz/images/february-of-fortran-653ed35e.webp
canonical_url: https://lautarolobo.xyz/blog/february-of-fortran/
---

## What is Fortran?

Fortran is a 63 y.o. programming language developed by IBM for scientific and engineering applications. Its name is an acronym from **FORmula TRANslation** , and still being in use for that purpose.

It’s a general-purpose programming language, but best suited for computationally intensive areas like computational physics, computational chemistry, high-performance computing and so.

Many programming languages were based on or influenced by, Fortran. And it has received many updates among the years, last one in 2018.

It was originally conceived as FORTRAN, all uppercase, in 1956. 5 updates later, in the 90s, it became Fortran. The update also added many other changes like free-form source, inline comments, modules, recursive procedures, dynamic memory allocation and many other changes that make the language _modern-er_.

## How to Compile and Run a Fortran Program

Let’s say you want to compile and run your first Fortran program, like this one:

```fortran
program HelloWorld
  implicit none
  print*, "hello world"
  write(*,*) "hello world"
end program

! it should return:
! hello world
! hello world

```

Well, you should make a series of things:

- Install [gfortran](https://gcc.gnu.org/wiki/GFortran), which is a Fortran compiler.
- Save your code with .f90 extension (even if you are writing in Fortran 2015, .f90 it’s the standard file extension).
- Compile with gfortran.
- Run your program as you would run any C program.

And that’s how you do it!

## What is Fortran Used For

Fortran is still in use in HPC (High Performace Computing). All that is mathematical chunk is probably done with Fortran. It’s widely used in scientific computing from Chemistry and Physics to Astronomy and Mathematics.

I can almost hear the masses… why not Python?

In fact, you can use Python in those areas. But even if Python is a better choice in many cases, you wouldn’t use it in HPC, since Fortran is _performant-er_. It may take more time to write, but sometimes code performance means everything.

You know, even that Python has evolved, wasn’t born exclusively for Physicists and Mathematicians.

As I’ve read somewhere:

> At the end of the day, Physicists are writing very different programs than Computer Scientists with very different goals and concerns.

You may say that Physicists are not willing to change, or that there’s a lot of Fortran legacy code out there, but even then, Fortran keeps being the best choice for some HPC projects, or Physics calculations.

But that doesn’t mean that you can only use Fortran. Other programming languages used in HPC are C and C++, both being faster than Fortran in many cases, or the somehow-new [Julia](https://julialang.org/) that is [slowly entering the market](https://www.hpcwire.com/2020/01/14/julia-programmings-dramatic-rise-in-hpc-and-elsewhere/), is also faster than Fortran and it was developed by MIT exclusively for HPC and all scientific computing.

If you want to see a detailed comparison between Python, C++, and Fortran on scientific computing, check out [this amazing paper](http://downloads.hindawi.com/journals/sp/2014/870146.pdf).