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:
- Open a terminal.
- Update your package list:
- Install the GNU Fortran compiler:
- Verify the installation by checking the version:
sudo apt update
sudo apt install gfortran
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:
- Download and install the MinGW installer.
- Run the installer and select
gfortran
during the setup. - 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
). - Verify the installation by opening Command Prompt and running:
gfortran --version
The output should display the installed version of GNU Fortran.