Install Fortran Compiler

Introduction

Fortran, a programming language widely used in scientific computing, has several compiler options available, such as Intel Fortran, GNU Fortran (gfortran), and others. Among these, gfortran stands out as a free and open-source option that is compatible with multiple platforms. In this guide, we focus on installing gfortran for both Ubuntu and Windows systems. For more information, visit here.

Installing Fortran Compiler on Ubuntu

To install a Fortran compiler (e.g., GNU Fortran), follow these steps:

  1. Open a terminal.
  2. Update your package list:
  3. sudo apt update
  4. Install the GNU Fortran compiler:
  5. sudo apt install gfortran
  6. Verify the installation by checking the version:
  7. gfortran --version

You should see the installed version of GNU Fortran in the output.

Installing Fortran Compiler on Windows

To install a Fortran compiler on Windows, you can use the MinGW (Minimalist GNU for Windows) toolchain. Here's how:

  1. Download and install the MinGW installer.
  2. Run the installer and select gfortran during the setup.
  3. Add the MinGW bin directory to your system's PATH variable:
    • Right-click "This PC" or "My Computer" and select "Properties".
    • Go to "Advanced system settings" → "Environment Variables".
    • Under "System variables," locate "Path," click "Edit," and add the path to MinGW's bin directory (e.g., C:\\MinGW\\bin).
  4. Verify the installation by opening Command Prompt and running:
  5. gfortran --version

The output should display the installed version of GNU Fortran.