        SUBROUTINE DF_VIEWPORT(LUS,BUFFER,ANNOTATE)
C
C----------------------------------------------------------------------
C.IDENTIFICATION: Subroutine DF_VIEWPORT
C.LIBRARY:        XASGRAPH
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 13 Oct 93 - Prototype
C.PURPOSE:        set DeFault VIEWPORT
C.SYNTAX:         CALL DF_VIEWPORT(LUS,BUFFER,ANNOTATE)
C.PARAMETERS:     INTEGER LUS(2)       : the graphics logical units
C                 CHARACTER ANNOTATE   : the annotate flag (N|S|L)
C                 CHARACTER*(*) BUFFER : a work buffer provided by main
C----------------------------------------------------------------------
C
C
C       defines a default viewport or uses the one in the environment
C       note that a change in the PLOTCOMMENT variable forces the
C       VIEWPORT to revert to the default defined here for such mode
C
        INTEGER   LUS(*)
        CHARACTER BUFFER*(*),ANNOTATE,DEFAULT*30,LAST
        REAL XVL,XVU,YVL,YVU
C       default viewport for data plotting  (probably obsolete)
        DATA XVL,XVU,YVL,YVU /0.15,0.95,0.5,0.9/
C
C       plotcomment may be one of Short None Long (default)
C-->    no check for invalid values
        CALL GET_GLOBAL_DEFAULT('PLOTCOMMENT','L',ANNOTATE)
        CALL UPCASE(ANNOTATE)
C-->    in the future read this stuff from a configuration file
        IF(ANNOTATE.EQ.'N')THEN
          DEFAULT='0.15,0.98,0.10,0.98'       
        ELSEIF(ANNOTATE.EQ.'S')THEN
          DEFAULT='0.15,0.95,0.10,0.9'       
        ELSE
          DEFAULT='0.15,0.98,0.5,0.98'       
        ENDIF
C       need to change viewport only if 'annotation' style changed
        CALL GET_GLOBAL_DEFAULT('LASTCOMMENT','*',LAST)
C
C       set up a default viewport
C-->    to be changed reading from a configuration file
C
        CALL Y_COORDINATES(LUS,1)
        IF(LAST.EQ.ANNOTATE)THEN   
          CALL GET_GLOBAL_DEFAULT('VIEWPORT',DEFAULT,BUFFER)
          READ(BUFFER,*)XVL,XVU,YVL,YVU 
        ELSE
          READ(DEFAULT,*)XVL,XVU,YVL,YVU
        ENDIF
        CALL Y_VIEWPORT(LUS,XVL,XVU,YVL,YVU)
        WRITE(BUFFER,'(4(G15.7,'',''))')XVL,XVU,YVL,YVU
        CALL Z_SET_GLOBAL('VIEWPORT',BUFFER)
        CALL Z_SET_GLOBAL('LASTCOMMENT',ANNOTATE) 
        RETURN
        END  
