program myderivedtype

  implicit none

!-- type definitions here
  type phone_type
    integer :: area_code, number
  end type phone_type

  type address_type 
    integer :: number
    character(len=30) :: street, city
    character(len=2) :: state
    integer :: zip_code
  end type address_type

  type person_type
    character (len=40) :: name
    type (address_type) :: address
    type (phone_type) :: phone
    character(len=100) :: remarks
  end type person_type

!-- create instances of our derived types
  type (phone_type) :: myphone
  type (person_type) :: joesmith
  type (person_type), dimension(1000) :: black_book

  myphone%area_code = 970
  myphone%number = 4918327

  write(*,*) myphone%area_code
  write(*,*) myphone%number

  joesmith%name = 'Joe Smith'
  joesmith%address%street = 'Elm'
  joesmith%address%city = 'Aurora'
  joesmith%address%state = 'Colorado'

  write(*,*) joesmith

!-- purposeful mistake
!  joesmith%city = 'Denver'
  
end program myderivedtype
