*"$BI=Bj(B 1$B$D$N<4$rIA$-:BI8@_Dj(B GTOOL3(GGAXSZ)
*
*"$BMzNr(B 90/08/18 $B>B8}(B  $BFX(B
*"     95/06/05 $BC]9-??0l(B for dcl-5.0
*"     95/11/08 $BC]9-??0l(B $B0[$J$kJ#?t<4%U%!%$%k$KBP1~(B
*"     97/12/01 $BC]9-??0l(B SET -> STX
*
*********************************************************************
*"         << 1$B$D$N<4$rIA$-:BI8@_Dj(B >>
*********************************************************************
      SUBROUTINE GGAXSZ
     I         ( HHEAD , AXISZ , HPOS  )
*
      CHARACTER  HHEAD ( * )*(*)         !" $B%X%C%@!<(B
      REAL       AXISZ ( * )             !" $B3J;R0LCV(B
      CHARACTER  HPOS *(*)               !" $B%;%C%H$9$k<4(B ('X' or 'Y')
*
#ifdef SYS_IBMS
      INCLUDE    (GZSIZE)                !" NCC, NDC, NED
#else
#include         "gzsize.F"              !" NCC, NDC, NED
#endif
      CHARACTER  HTITL*(NCC)      
      CHARACTER  HTITLZ( 2 )*(NCC)
      CHARACTER  HSIDE *2, HSIDEL *2
      REAL       AZMINZ( 2 )
      REAL       AZMAXZ( 2 )
      LOGICAL    OSETZ ( 2 )
      SAVE       AZMINZ, AZMAXZ, OSETZ, HTITLZ
*
*"         < 1. $B$9$G$K@_Dj$5$l$F$$$l$P2?$b$7$J$$(B >
*
      IF      ( HPOS(1:1) .EQ. 'X' ) THEN
         IIZ = 1
      ELSE IF ( HPOS(1:1) .EQ. 'Y' ) THEN
         IIZ = 2
      ELSE
         CALL MSGDMP('E','GGAXSZ','INVALID AXIS SPECIFIER.' )
      ENDIF
*
      IF  ( OSETZ( IIZ ) ) THEN
         CALL GHCGET ( HHEAD, 'TITL1', HTITL ) !" $B@_Dj$5$l$F$$$k<4$H(B
         CALL CLADJ( HTITL )                   !" $BF1$8$+$I$&$+(B check
         IF( HTITL .NE. HTITLZ(IIZ) )THEN
            CALL MSGDMP('W','GGAXSZ','TITLE OF AXIS IS DIFFERENT' )
         ENDIF
                                             RETURN
      ELSE
            OSETZ( IIZ ) = .TRUE.
      ENDIF
*
*"         < 2. $BJ8;z$NBg$-$5Ey(B >
*
      CALL GGPGET ( 'SAXSL'  , SAXSL )
      CALL GGPGET ( 'SAXST'  , SAXST )
      CALL UZPSTX ( 'RSIZEL1', SAXSL )
      CALL UZPSTX ( 'RSIZEC1', SAXST )
*
*"         < 3. $B%&%#%s%I%&HO0O(B >
*
      CALL GHPGET ( HHEAD, 'ASTR1', IZSTR )
      CALL GHPGET ( HHEAD, 'AEND1', IZEND )
      CALL GHCGET ( HHEAD, 'TITL1', HTITL )
      HTITLZ(IIZ) = HTITL
      CALL CLADJ( HTITLZ(IIZ) )
*
      CALL GHPGET ( HHEAD , 'MISS' , VMISZ )
      CALL GLPGET ( 'RUNDEF', RUNDEF )
*
      CALL GHPGET ( HHEAD , 'DMIN' , DMINZ )
      CALL GHPGET ( HHEAD , 'DMAX' , DMAXZ )
      CALL GHPGET ( HHEAD , 'DIVS' , DIVSZ )
      CALL GHPGET ( HHEAD , 'DIVL' , DIVLZ )
      IF ( DMINZ .EQ. VMISZ ) DMINZ = RUNDEF
      IF ( DMAXZ .EQ. VMISZ ) DMAXZ = RUNDEF
      IF ( DIVSZ .EQ. VMISZ ) DIVSZ = RUNDEF
      IF ( DIVLZ .EQ. VMISZ ) DIVLZ = RUNDEF
*
*"         < 4. $BHO0O$N%;%C%H(B >
*
      CALL GUSMIS( HHEAD )
*
      IF ( HPOS(1:1) .EQ. 'X' ) THEN
         CALL USSPNT( IZEND-IZSTR+1, AXISZ, RUNDEF)
         CALL USRGET('XDTMIN', DMINQ)
         CALL USRGET('XDTMAX', DMAXQ)
      ELSE
         CALL USSPNT( IZEND-IZSTR+1, RUNDEF, AXISZ )
         CALL USRGET('YDTMIN', DMINQ)
         CALL USRGET('YDTMAX', DMAXQ)
      ENDIF
*
      CALL GHPGET ( HHEAD, 'STYP', ISTYP )
*
      IF ( DIVLZ .NE. RUNDEF ) THEN
         IF      ( DMINZ .NE. RUNDEF .AND.
     &             DMAXZ .NE. RUNDEF       ) THEN
            IF ( DMAXZ-DMINZ .LT. DIVLZ ) THEN
               DIVLZ = DMAXZ-DMINZ
            ENDIF
         ELSE IF ( DMINZ .NE. RUNDEF ) THEN
            IF ( DMAXQ .LT. DMINZ+DIVLZ ) THEN
               DMAXZ = DMINZ + DIVLZ
            ENDIF
         ELSE IF ( DMAXZ .NE. RUNDEF ) THEN
            IF ( DMINQ .GT. DMAXZ-DIVLZ ) THEN
               DMINZ = DMAXZ - DIVLZ
            ENDIF            
         ELSE
            DMINZ =  IGUS( DMINQ/DIVLZ )*DIVLZ
            DMAXZ = -IGUS(-DMAXQ/DIVLZ )*DIVLZ
         ENDIF
      ENDIF

      IF ( HPOS(1:1) .EQ. 'X' ) THEN
         IF ( ISTYP .GT. 0 ) THEN
            CALL USPSTX( 'LXINV', .FALSE. )
         ELSE
            CALL USPSTX( 'LXINV', .TRUE. )
         ENDIF
         CALL SGPSTX( 'UXMIN', DMINZ  )
         CALL SGPSTX( 'UXMAX', DMAXZ  )
         CALL USPSTX( 'DXT' , DIVSZ )
         CALL USPSTX( 'DXL' , DIVLZ )
      ELSE
         IF ( ISTYP .GT. 0 ) THEN
            CALL USPSTX( 'LYINV', .FALSE. )
         ELSE
            CALL USPSTX( 'LYINV', .TRUE. )
         ENDIF
         CALL SGPSTX( 'UYMIN', DMINZ  )
         CALL SGPSTX( 'UYMAX', DMAXZ  )
         CALL USPSTX( 'DYT' , DIVSZ )
         CALL USPSTX( 'DYL' , DIVLZ )
      ENDIF
*
*"         < 5. $B:BI8@_Dj(B >
*
      IF ( ABS( ISTYP ) .LE. 2 ) THEN
         CALL SGPGET( 'ITR',ITR )
         IF ( HPOS(1:1) .EQ. 'X' ) THEN
            ITR = MOD(ITR-1,2)+1 + ( ABS( ISTYP )-1 )*2 
         ELSE
            ITR = ((ITR-1)/2) * 2 + ABS( ISTYP ) 
         ENDIF
         CALL SGPSTX( 'ITR',ITR )
      ELSE
         CALL MSGDMP('E','GGAXSZ','INVALID ISTYP.' )
      ENDIF
*
      CALL USPFIT
      CALL GRSTRF
*
*"         < 6. $B:BI8<4$rIA$/(B >
*
      IF ( HPOS(1:1) .EQ. 'X' ) THEN
         CALL GGAXLZ ( 'X' )

         CALL GGPGET ( 'INNER', INNER )
         CALL UZPSTX ( 'INNER', INNER )
         CALL GGCGET ( 'CXSIDE', HSIDE )
         NCS = LENZ(HSIDE)
         DO 6100 N=1, NCS
            CALL USXAXS(HSIDE(N:N))
 6100    CONTINUE

         CALL GGCGET ( 'CXSIDEL', HSIDEL )
         IF ( INDEX(HSIDEL,HSIDE(1:1)) .GE. 1 ) THEN
            IF (LENZ(HTITL).NE.0) CALL UXSTTL(HSIDE(1:1), HTITL, 0.)
         ENDIF

         CALL UZPSTX ( 'INNER', -INNER )
         CALL GGCGET ( 'CXSIDET', HSIDE )
         NCS = LENZ(HSIDE)
         DO 6110 N=1, NCS
            CALL UXPTMK(HSIDE(N:N),1,AXISZ,IZEND-IZSTR+1 )
 6110    CONTINUE
         CALL UZPSTX ( 'INNER', INNER )
*
      ELSE
         CALL GGAXLZ ( 'Y' )

         CALL GGPGET ( 'INNER', INNER )
         CALL UZPSTX ( 'INNER', INNER )
         CALL GGCGET ( 'CYSIDE', HSIDE )
         NCS = LENZ(HSIDE)
         DO 6200 N=1, NCS
            CALL USYAXS(HSIDE(N:N))
 6200    CONTINUE

         CALL GGCGET ( 'CYSIDEL', HSIDEL )
         IF ( INDEX(HSIDEL,HSIDE(1:1)) .GE. 1 ) THEN
            IF (LENZ(HTITL).NE.0) CALL UYSTTL(HSIDE(1:1), HTITL, 0.)
         ENDIF
*
         CALL UZPSTX ( 'INNER', -INNER )
         CALL GGCGET ( 'CYSIDET', HSIDE )
         NCS = LENZ(HSIDE)
         DO 6210 N=1, NCS
            CALL UYPTMK(HSIDE(N:N),1,AXISZ,IZEND-IZSTR+1 )
 6210    CONTINUE
         CALL UZPSTX ( 'INNER', INNER )
       ENDIF
*
      RETURN
*=====================================================================
*"         << $B<4$N:BI8HO0O$N@_Dj(B >>
*=====================================================================
      ENTRY      GGRANG
     I         ( HHEAD , AXISZ , HPOS  )
*
      CALL GHPGET ( HHEAD, 'ASTR1', IZSTR )
      CALL GHPGET ( HHEAD, 'AEND1', IZEND )
      CALL GLPGET ( 'RUNDEF', RUNDEF )
*
      CALL GUSMIS ( HHEAD )
*
      IF ( HPOS(1:1) .EQ. 'X' ) THEN
         CALL USSPNT( IZEND-IZSTR+1, AXISZ, RUNDEF)
      ELSE
         CALL USSPNT( IZEND-IZSTR+1, RUNDEF, AXISZ)
      ENDIF
*
      RETURN
*=====================================================================
*"         << X or Y $B<4$N%j%;%C%H(B >>
*=====================================================================
      ENTRY      GGAXRR( HPOS )
*
      CALL GTPGET ( 'MISS', VMISD )
*
      IF      ( HPOS(1:1) .EQ. 'X' ) THEN
         IIZ = 1
         CALL SGPSTX( 'UXMIN', 0.  )
         CALL SGPSTX( 'UXMAX', 1.  )
      ELSE IF ( HPOS(1:1) .EQ. 'Y' ) THEN
         IIZ = 2
         CALL SGPSTX( 'UYMIN', 0.  )
         CALL SGPSTX( 'UYMAX', 1.  )
      ENDIF
*
      AZMINZ( IIZ ) = VMISD
      AZMAXZ( IIZ ) = VMISD
      OSETZ ( IIZ ) = .FALSE.
*
      RETURN
      END
*=====================================================================
*"         << $B<4IA2h$N%j%;%C%H(B >>
*=====================================================================
      SUBROUTINE GGAXRS
*
      CALL GGAXRR( 'X' )
      CALL GGAXRR( 'Y' )
*
      RETURN
      END
*=====================================================================
*"         << $B<4%i%Y%k$NIA2h%U%i%0(B >>
*=====================================================================
      SUBROUTINE GGAXLZ ( HPOS )
*
      CHARACTER  HPOS   * 1
      CHARACTER  HSIDEL * 2
*
      IF ( HPOS .EQ. 'X' ) THEN
         CALL GGCGET ( 'CXSIDEL', HSIDEL )
         IF ( INDEX( HSIDEL, 'B' ) .GE. 1 ) THEN
            CALL UZPSTX('LABELXB',.TRUE.)
         ELSE
            CALL UZPSTX('LABELXB',.FALSE.)            
         ENDIF
         IF ( INDEX( HSIDEL, 'T' ) .GE. 1 ) THEN
            CALL UZPSTX('LABELXT',.TRUE.)
         ELSE
            CALL UZPSTX('LABELXT',.FALSE.)            
         ENDIF
         IF ( INDEX( HSIDEL, 'U' ) .GE. 1 ) THEN
            CALL UZPSTX('LABELXU',.TRUE.)
         ELSE
            CALL UZPSTX('LABELXU',.FALSE.)            
         ENDIF
*
      ELSE IF ( HPOS .EQ. 'Y' ) THEN
         CALL GGCGET ( 'CYSIDEL', HSIDEL )
         IF ( INDEX( HSIDEL, 'L' ) .GE. 1 ) THEN
            CALL UZPSTX('LABELYL',.TRUE.)
         ELSE
            CALL UZPSTX('LABELYL',.FALSE.)            
         ENDIF
         IF ( INDEX( HSIDEL, 'R' ) .GE. 1 ) THEN
            CALL UZPSTX('LABELYR',.TRUE.)
         ELSE
            CALL UZPSTX('LABELYR',.FALSE.)            
         ENDIF
         IF ( INDEX( HSIDEL, 'U' ) .GE. 1 ) THEN
            CALL UZPSTX('LABELYU',.TRUE.)
         ELSE
            CALL UZPSTX('LABELYU',.FALSE.)            
         ENDIF
      ELSE
         CALL MSGDMP('E','GGAXLZ','INVALID AXIS SPECIFIER.' )
      ENDIF
*
      RETURN
      END
