Fortran 90 programming for Windows 10
Fortran (FORmula TRANslation ) was originally developed in 1954 by IBM. Fortran was the first languages to allow the programmer to use higher level. As much as it is an old programming language, Fortran is needed for some engineering application in universities and research facilities. Here we will introduce simple way to compile Fortran program inside windows 10 OS.
Install gfortran compiler and Set the environment
Here we will introduce MinGW-w64 as gfortran compiler. Installing the compiler was introduced in a pervious article.
Install EditPlus
EditPlus can be installed as a trail version for 30 days from here.
After installing EditPlus, it can be configure to run C++ as follows:
Add alt text
Add alt text
Add alt text
Add alt text
Add alt text
Now:
1- from Add tool make “Menu text “ with any name you want. Here we chosen Compile Fortran.
2-In” Command “ section, browse to MinGW-w64 install directory and chose “gfortran.exe”.
3-In” Argument” section put the following text
$(FileName) -g -o $(FileNameNoExt).exe
4-In “Initial directory” section put the following text
$(FileDir)
5- Check “ Capture Output” and click “OK”
Add alt text
6- Add a new tool for running. Here we will use the name Run++ in “Menu Text:”. You can chose any preferable name you want.
7- In “ Command” put the following text
$(FileNameNoExt)
8- In “Initial directory” put the following text
$(FileDir)
Add alt text
In tool you should have the newly made Compile and run commands
Add alt text
Write the following program and save it as name**.f90 .
PROGRAM Triangle
IMPLICIT NONE
REAL :: a, b, c, Area
PRINT *, 'Please enter the&
&lengths of the 3 sides.'
READ *, a, b, c
PRINT *, 'Triangle'is area: ', Area(a,b,c)
END PROGRAM Triangle
FUNCTION Area(x,y,z)
IMPLICIT NONE
REAL :: Area ! function type
REAL, INTENT( IN ) :: x, y, z
REAL :: theta, height
theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
height = x*SIN(theta); Area = 0.5*y*height
END FUNCTION Area
After saving it, compile it the run it using the newly made (Compile Fortran) and (Run Fortran) commands.
you should get
Add alt text
Add alt text