FORTRAN is a powerful programming language that is often over-shadowed by the more popular mainstream programming languages. Setting up and using FORTRAN on Windows 10 using the GCC Installation Manager makes the process quick and easy.
Visit mingw.org using your favourite browser and click on the downloads tab. Then click on the mingw-get-setup.exe link as pictured below.
Save the file to your downloads directory and run the program when the download completes. The MinGW Installation Manager will appear from which you can choose the packages to be installed. Note that the MinGW Installation Manager is a separate “app” that can be run at any time to manage or change the installed packages.
The various packages available through the Basic Setup are pictured below and include The GNU Ada Compiler, the GNU FORTRAN Compiler, The GNU C++ Compiler, and The GNU Objective-C Compiler.
Click on the All Packages option to reveal a host of other packages that are available.
We installed all of the available compilers, including the GNU FORTRAN compiler.
Testing the Installation (gfortran)
Create a simple test program as shown below using an editor (Visual Studio Code) and save it as addNumbers.f90 (Note that you must use a file extension such as .f90 or .f95 or the program may not compile).
program addNumbers ! This simple program adds two numbers implicit none ! Type declarations real :: a, b, result ! Executable statements a = 12.0 b = 15.0 result = a + b print *, 'The total is ', result end program addNumbers
Open a terminal (cmd.exe) session and compile the program by entering the following command: gfortran -c addNumbers.f90
Enter the following command to generate an executable file: gfortran -o addNumbers.exe addNumbers.f90
The program will compile to create the addNumbers.exe executable file. Type .\addNumbers at the prompt to run the file from the current location as Windows Powershell will not load commands from the current location by default.
The program and terminal session from Visual Studio Code are as pictured below:
FTN95 from Silverfrost Limited is a complete Fortran development environment and includes the powerful Plato IDE. Version 8.70 was just released as discussed in our recently published article “New Release of FTN95 Version 8.70.”
Related Articles and Resources
- The GCC Compiler Collection: gcc.gnu.org
- MinGW – Compiler Suite (http://mingw.org)
- GNU Fortran: Using the Compiler (https://gcc.gnu.org/wiki/GFortranUsage)
- Fortran – (2018, August 26). Wikibooks, The Free Textbook Project. Retrieved 19:38, January 4, 2020, from https://en.wikibooks.org/w/index.php?title=Fortran&oldid=3454070.
- Fortran 90/95 Programming Manual (fifth revision 2005)
- Free Fortran Compilers (https://www.thefreecountry.com/compilers/fortran.shtml)
- Absoft – Absoft Pro Fortran – Paid license required.
- Simply Fortran – simplyfortran.com, version 3.7 as of this writing (Approximatrix) – Windows, MacOS, GNU/Linux. Free 30-day trial. NOTE: Use Google’s CHROME browser to download this package on Windows 10. Microsoft’s EDGE browser terminates the download prematurely.
- Lahey/GNU Fortran – Free trial versions are available for download.
- Lahey Fortran Professional (32-64 bit)
- Lahey/GNU Fortran – Rainier edition (32-64 bit)
- Lahey/Fujitsu Fortran Express (32 bit)
- Introduction to Programming Using Fortran 95 (fortrantutorial.com)
- SilverFrost FTN95 Personal Edition (SilverFrost.com)
- JDOODLE – Online Fortran Compiler IDE
- Fortran Tutorial – https://www.fortrantutorial.com/
- SilverFrost FTN95 – Personal Edition is free for home use or evaluation purposes only. Tiered licensing is available for commercial or academic purposes.
- The free personal edition will display a splash window as shown below: