Declarations in Fortran
Four typed variables for the lighthouse log, declared before any statement runs.
program declarations
! implicit none turns off the 1950s i-through-n typing rules.
implicit none
integer :: lamp_turns = 148
real :: oil_gallons = 6.5
character(len=12) :: station = "Gull Rock"
logical :: storm_watch = .true.
print *, "Station: ", station
print *, "Turns tonight: ", lamp_turns
print *, "Oil on hand: ", oil_gallons
print *, "Storm watch? ", storm_watch
end program declarations
How it works
implicit noneturns off the 1950s rule that typed variables by their first letter.integer,real,character(len=12), andlogicalcover the basics;::splits type from name.- Initializers ride on the declaration, and
.true.is how logicals are spelled.
Keywords and builtins used here
characterendimplicitintegerlenlogicalnoneprintprogramreal
The run, in numbers
- Lines
- 13
- Characters to type
- 396
- Tokens
- 59
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 51 seconds.
Step 2 of 3 in Programs & variables, step 2 of 27 in Language basics.