!------------------------------------------------------------------------------
!
!  Program name:
!
!    circledef
!
!  Purpose
!
!    This program defines a derived type point, and uses this defined type to 
!    define another derived type circle.
!
!------------------------------------------------------------------------------

PROGRAM circledef    ! to define a derived type for a circle

  IMPLICIT NONE
  TYPE point         ! defines type point
    REAL x,y
  END TYPE point

  TYPE circle        ! defines type circle
    TYPE(point) centre
    REAL        radius
  END TYPE circle

  TYPE(point) o      ! o is type point
  TYPE(circle) one   ! one is type circle


  o%x = 1.0          ! assign o by components
  o%y = 2.0           

  one%centre = o     ! centre of the circle assigned to point o

  one%radius = 0.5   ! assigns the radius of the circle

  PRINT '(/)'
  PRINT *,'Print centre of circle by components'
  WRITE (*,'(2F6.2,/)') o%x,o%y
  
  PRINT *,'Print centre of circle by derived type'
  WRITE (*,*) o
  PRINT '(//)'
  
  WRITE (*,*) 'Print circle by components'
  WRITE (*,'(3F6.2,/)') one
  
  PRINT *,'Print circle by derived type'
  WRITE (*,*) one
  PRINT '(//)'

END PROGRAM circledef

