1: program isoweight
2: !
3: ! Declare derived type.
4: ! integer, parameter :: elements = 106
5: integer, parameter :: elements = 10
6: type mendeleev
7: character (len=12) :: name
8: character (len=2 ) :: symbol
9: integer :: atomic_number
10: double precision :: mass
11: integer :: isotopes
12: double precision, dimension(:),pointer :: weight
13: end type mendeleev
14: type ( mendeleev ) periodic(elements)
15: !
16: ! Tell the user what will happen.
17: print *, " "
18: print *, "ISOWEIGHT reports isotopic weights."
19: !
20: ! Read the file to get the data. Allocate sufficient memory
21: ! to hold all isotopes for a given element.
22: open ( unit=5, file='isoweight.input' )
23: rewind 5
24: do i = 1, elements, 1
25: read ( 5,100 ) periodic(i)%name, &
26: periodic(i)%symbol, &
27: periodic(i)%atomic_number, &
28: periodic(i)%mass, &
29: periodic(i)%isotopes
30: 100 format ( a12, 1x, a2, 1x, i3, 1x, f9.5, 1x, i3 )
31: allocate ( periodic(i)%weight(periodic(i)%isotopes) )
32: read ( 5, * ) periodic(i)%weight
33: end do
34: close ( unit=5 )
35: !
36: ! Display the first few elements.
37: print *, " "
38: print *, "First", elements, "elements are ..."
39: print *, " "
40: print 200
41: 200 format ( ' ', 'Name Symbol Number Mass ', &
42: 'Isotope Weights', &
43: /, ' ', '------------ ------ ------ --------- ', & !zgs
44: '------- ---------' )
45: ! a comma after slash need to be added.
46:
47: do i = 1, elements, 1
48: m = nint ( periodic(i)%weight(1) )
49: print 300, periodic(i)%name, &
50: periodic(i)%symbol, &
51: periodic(i)%atomic_number, &
52: periodic(i)%mass, &
53: nint ( periodic(i)%weight(j) ), &
54: periodic(i)%weight(1)
55: 300 format ( ' ', a12, 1x, a2, 5x, i6, 1x, &
56: f9.6, 1x, i7, 1x, f9.6 )
57: do j = 2, periodic(i)%isotopes, 1
58: print 400, nint ( periodic(i)%weight(j) ), &
59: periodic(i)%weight(j)
60: 400 format ( ' ', 37x, i7, 1x, f9.6 )
61: end do
62: print *, " "
63: deallocate ( periodic(i)%weight )
64: end do
65: !
66: ! End of processing.
67: print *, "ISOWEIGHT is finished."
68: print *, " "
69: end program isoweight