      PROGRAM circle
      IMPLICIT NONE
      REAL r, xwin, ywin
      INTEGER IR_
      CALL GWopen(IR_, 0)
      r = 1                                 ! radius of circle
      CALL compute_aspect_ratio(r,xwin,ywin)
      CALL GWindow(IR_, -xwin, -ywin, xwin, ywin)
      CALL GWsetpen(IR_, 16, -1, -1, -1)
      CALL GWellipse(IR_, -r, -r, r, r)     ! draw circle
      CALL GWquit(IR_)
      END
C
      SUBROUTINE compute_aspect_ratio(r,x,y)
      IMPLICIT NONE
      REAL aspect_ratio, m, size, r, x, y
      INTEGER IR_, px, py
      m = 0.1*r                             ! margin
      size = r + m
*     px, py: # pixels in horizonal and vertical direction
      CALL GWsize(IR_, 2, px,py)
      IF(px .GT. py) THEN
         aspect_ratio = REAL(px)/py
         x = aspect_ratio*size
         y = size
      ELSE
         aspect_ratio = REAL(py)/px
         x = size
         y = aspect_ratio*size
      END IF
      END
