      program isoweight
!
!     Declare derived type.
!     integer, parameter                          :: elements = 106
      integer, parameter                          :: elements = 10
      type mendeleev
           character (len=12)                     :: name
           character (len=2 )                     :: symbol
           integer                                :: atomic_number
           double precision                       :: mass
           integer                                :: isotopes
           double precision, dimension(:),pointer :: weight
      end  type mendeleev
      type ( mendeleev ) periodic(elements)
!
!     Tell the user what will happen.
      print *, " "
      print *, "ISOWEIGHT reports isotopic weights."
!
!     Read the file to get the data. Allocate sufficient memory
!     to hold all isotopes for a given element.
      open ( unit=5, file='isoweight.input' )
      rewind 5
      do i = 1, elements, 1
         read ( 5,100 ) periodic(i)%name,          &
                        periodic(i)%symbol,        &
                        periodic(i)%atomic_number, &
                        periodic(i)%mass,          &
                        periodic(i)%isotopes
100      format ( a12, 1x, a2, 1x, i3, 1x, f9.5, 1x, i3 )
         allocate ( periodic(i)%weight(periodic(i)%isotopes) )
         read ( 5,  * ) periodic(i)%weight
      end do
      close ( unit=5 )
!
!     Display the first few elements.
      print *, " "
      print *, "First", elements, "elements are ..."
      print *, " "
      print 200
200   format ( ' ', 'Name         Symbol Number      Mass ', &
                    'Isotope   Weights',                     &
             / ' ', '------------ ------ ------ --------- ', &
                    '------- ---------'                           )
      do i = 1, elements, 1
         m = nint ( periodic(i)%weight(1) )
         print 300,        periodic(i)%name,          &
                           periodic(i)%symbol,        &
                           periodic(i)%atomic_number, &
                           periodic(i)%mass,          &
                    nint ( periodic(i)%weight(j) )    &
                           periodic(i)%weight(1)
300      format ( ' ', a12, 1x, a2, 5x, i6, 1x, &
                      f9.6, 1x, i7, 1x, f9.6      )
         do j = 2, periodic(i)%isotopes, 1
            print 400, nint ( periodic(i)%weight(j) ), &
                              periodic(i)%weight(j)
400         format ( ' ', 37x, i7, 1x, f9.6 )
         end do
         print *, " "
      deallocate ( periodic(i)%weight )
      end do
!
!     End of processing.
      print *, "ISOWEIGHT is finished."
      print *, " "
      end program isoweight
