1: !
2: ! Establish a data structure and display mechanism
3: ! for presidential facts.
4: module facts
5: integer, parameter :: WIDTH=32
6: type key_facts
7: character (len=WIDTH) :: who
8: character (len=WIDTH) :: what
9: character (len=WIDTH) :: k_where
10: character (len=WIDTH) :: when
11: end type key_facts
12: contains
13: subroutine show_facts ( fact_set, number )
14: type ( key_facts ) fact_set
15: integer number
16: print 100, number
17: 100 format ( /, ' ', 'Number ', i2.2, / ) !zgs,
18: ! two comma after and before the slash need to be added
19: print 200, fact_set
20: 200 format ( ' ', 10x, a )
21: end subroutine show_facts
22: end module facts
23:
24: program history
25: !
26: ! Bring in the data structure and display mechanism.
27: use facts
28: type ( key_facts ) presidents(42)
29: !
30: ! Record information about the first and current president.
31: presidents(1)%who = "George Washington"
32: presidents(1)%what = "Engineer, General"
33: presidents(1)%k_where = "Mount Vernon, VA"
34: presidents(1)%when = "1789-1797"
35: presidents(42) = key_facts ( "Bill Clinton", "Governor", &
36: "Little Rock, AK", "1993-?" )
37: !
38: ! Display the information for the only two elements of
39: ! PRESIDENTS that have data.
40: call show_facts ( presidents( 1), 1 )
41: call show_facts ( presidents(42), 42 )
42: print *, " "
43: end program history