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

PROGRAM rectdef

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

  TYPE rectangle                ! defines type rectangle
    TYPE(point) ver1, ver2, ver3, ver4
  END TYPE rectangle

  TYPE(point) a, b, c, d        ! a,b,c,d type point
  TYPE(rectangle) poly          ! poly is type rectangle

  a = point(0.0, 0.0)
  b = point(0.0, 5.0)
  c = point(3.0, 5.0)
  d = point(3.0, 0.0)
   
  poly = rectangle(a, b, c, d)

  WRITE(*, *) 'Print corners of rectangle by components'
  WRITE(*, '(8F6.2,/)') a%x,a%y, b%x,b%y, c%x,c%y, d%x,d%y
  WRITE(*, *) 'Print corners of rectangle by derived type'
  WRITE(*, *) poly

END PROGRAM rectdef




