! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

  module Element_M
    implicit none

    integer, parameter, private :: NAME_LENGTH = 18, MAX_ISO = 10

    type, public :: Isotope_Type  ! Derived type definition
      integer :: Nucleon_Count
      real :: Abundance
    end type Isotope_Type

    type, public :: Chem_El_Type_1  ! Derived type definition
      character (len = NAME_LENGTH) :: Element_Name
      character (len = 3) :: Symbol
      integer :: Atomic_Number
      real :: Atomic_Mass
    end type Chem_El_Type_1

    type, public :: Chem_El_Type_2  ! Derived type definition
      character (len = NAME_LENGTH) :: Element_Name
      character (len = 3) :: Symbol
      integer :: Atomic_Number
      real :: Atomic_Mass
      type (Isotope_Type) :: Principal_Isotope  ! Previously defined
    end type Chem_El_Type_2

    type, public :: Chem_El_Type_3  ! Element with isotopes
      character (len = NAME_LENGTH) :: Element_Name
      character (len = 3) :: Symbol
      integer :: Atomic_Number
      real :: Atomic_Mass
      integer :: N_Iso   ! Isotope count
      type(Isotope_Type), dimension(MAX_ISO) :: Isotopes
    end type Chem_El_Type_3

    type, public :: Box_Type  ! Derived type definition
      type (Chem_El_Type_2) :: El  ! Previously defined derived type
      type (Box_Type), pointer :: Next_BP  ! Pointer to structure of same type
    end type Box_Type

  end module Element_M
