- Fixed Format Fortran Rules
- Our first program - Hello World !
write(*,*) 'Hello World !'
end program helloWorld
Compiling a single fortran file (with the gfortran compiler)
$ gfortran helloWorld.f -o helloWorld
Running the executable (Assuming the current directory contains the executable)
- Windows OS
- Projectile problem
c This program computes the velocity and height of a projectile
c given the initial height, initial velocity and the constant
c Declare the variables
real hght0, vel0, time, velof, hghtf, accel
c Declare the value of the acceleration due to gravity
data accel /-9.807/
c Obtain the initial height, initial velocity and the time after
write(*,*) 'Enter the initial height, initial velocity and the'
write(*,*) 'time after launch'
read(*,*) hght0, vel0, time
c Calculate the height and the velocity
hghtf = vel0*time + 0.5*accel*time**2 + hght0
velof = vel0 + accel*time
c Display the height and the velocity after time
write(*,*) 'Time after launch:', time
write(*,*) 'Current Height:', hghtf
write(*,*) 'Current Velocity:', velof
end program projec
Enter the initial height, initial velocity and the
time after launch
100 90 4.3
Time after launch: 4.30000019
Current Height: 396.334290
Current Velocity: 47.8298988