*-----------------------------------------------------------------------
*     UGUNIT
*-----------------------------------------------------------------------
*     Copyright (C) 2000-2022 GFD Dennou Club. All rights reserved.
*-----------------------------------------------------------------------
      SUBROUTINE UGUNIT


*     / GET INTERNAL PARAMETERES /

      CALL UGRGET('RUNDEF',RUNDEF)
      CALL UGIGET('INDEX',INDEX )

*     / INQUIRE NORMALIZATION TRANSFORMATION /

      CALL SGQVPT(VX1,VX2,VY1,VY2)

*     / DETERMINE LOCATION OF UNIT VECTORS IN NDC /

      CALL UGRGET('VXULOC',VXULOC)
      IF (VXULOC.EQ.RUNDEF) THEN
        CALL UGRGET('VXUOFF',VXOFF)
        VXULOC=VX2+VXOFF
        CALL UGRSET('VXULOC',VXULOC)
      END IF

      CALL UGRGET('VYULOC',VYULOC)
      IF (VYULOC.EQ.RUNDEF) THEN
        CALL UGRGET('VYUOFF',VYOFF)
        VYULOC=VY1+VYOFF
        CALL UGRSET('VYULOC',VYULOC)
      END IF

*     / DETERMINE LENGTH OF UNIT VECTORS IN NDC /

      CALL UGRGET('UXUNIT',UXUNIT)
      CALL UGRGET('XFACT2',XFACT2)
      IF (UXUNIT.EQ.RUNDEF) THEN
        CALL UGRGET('VXUNIT',VXUNIT)
        UXUNIT=VXUNIT/XFACT2
        CALL UGRSET('UXUNIT',UXUNIT)
      ELSE
        VXUNIT=UXUNIT*XFACT2
        CALL UGRSET('VXUNIT',VXUNIT)
      END IF

      CALL UGRGET('UYUNIT',UYUNIT)
      CALL UGRGET('YFACT2',YFACT2)
      IF (UYUNIT.EQ.RUNDEF) THEN
        CALL UGRGET('VYUNIT',VYUNIT)
        UYUNIT=VYUNIT/YFACT2
        CALL UGRSET('UYUNIT',UYUNIT)
      ELSE
        VYUNIT=UYUNIT*YFACT2
        CALL UGRSET('VYUNIT',VYUNIT)
      END IF

*     / DRAW UNIT VECTORS /

      UVX1=VXULOC
      UVX2=VXULOC+VXUNIT
      UVY1=VYULOC
      UVY2=VYULOC+VYUNIT

      CALL SZLAOP(1,INDEX)
      CALL SZLAZV(UVX1,UVY1,UVX2,UVY1)
      CALL SZLAZV(UVX1,UVY1,UVX1,UVY2)
      CALL SZLACL

      END
