module dcl_parm
  use dcl_common

! udpack  ! Contour
! uepack  ! Hatch
! ugpack  ! Vector
! uspack  ! Scale
! uzpack  ! Axis
! ulpack  ! Log
! ucpack  ! Calendar
! umpack  ! Map
! sgpack  ! Graph
! swpack  ! Device
! glpack  ! Global

  interface DclGetParm
    module procedure DclGetIntegerS, DclGetRealS, DclGetLogicalS, DclGetCharS
  end interface

  interface DclSetParm
    module procedure DclSetInteger, DclSetReal, DclSetLogical, DclSetChar
  end interface

  interface DclSetParmEx
    module procedure DclSetIntegerEX, DclSetRealEX, DclSetLogicalEX, DclSetCharEX
  end interface

!======================================================
  contains
    function DclGetInteger(name)
      integer                       :: DclGetInteger
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udiget(pname,DclGetInteger)
        case('HATCH')
          call ueiget(pname,DclGetInteger)
        case('VECTOR')
          call ugiget(pname,DclGetInteger)
        case('SCALE')
          call usiget(pname,DclGetInteger)
        case('AXIS')
          call uziget(pname,DclGetInteger)
        case('LOG')
          call uliget(pname,DclGetInteger)
        case('CALENDAR')
          call uciget(pname,DclGetInteger)
        case('MAP')
          call umiget(pname,DclGetInteger)
        case('GRAPH')
          call sgiget(pname,DclGetInteger)
        case('DEVICE')
          call swiget(pname,DclGetInteger)
        case('GLOBAL')
          call gliget(pname,DclGetInteger)
        case default
          call msgdmp('E', 'DclGetInteger', 'Invalid prefix ['//prefix//']')
      end select

    end function
!------------------------------------------------------
    function DclGetReal(name)
      real                          :: DclGetReal
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udrget(pname,DclGetReal)
        case('HATCH')
          call uerget(pname,DclGetReal)
        case('VECTOR')
          call ugrget(pname,DclGetReal)
        case('SCALE')
          call usrget(pname,DclGetReal)
        case('AXIS')
          call uzrget(pname,DclGetReal)
        case('LOG')
          call ulrget(pname,DclGetReal)
        case('CALENDAR')
          call ucrget(pname,DclGetReal)
        case('MAP')
          call umrget(pname,DclGetReal)
        case('GRAPH')
          call sgrget(pname,DclGetReal)
        case('DEVICE')
          call swrget(pname,DclGetReal)
        case('GLOBAL')
          call glrget(pname,DclGetReal)
        case default
          call msgdmp('E', 'DclGetReal', 'Invalid prefix ['//prefix//']')
      end select
    end function
!------------------------------------------------------
    function DclGetLogical(name)
      logical                       :: DclGetLogical
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udlget(pname,DclGetLogical)
        case('HATCH')
          call uelget(pname,DclGetLogical)
        case('VECTOR')
          call uglget(pname,DclGetLogical)
        case('SCALE')
          call uslget(pname,DclGetLogical)
        case('AXIS')
          call uzlget(pname,DclGetLogical)
        case('LOG')
          call ullget(pname,DclGetLogical)
        case('CALENDAR')
          call uclget(pname,DclGetLogical)
        case('MAP')
          call umlget(pname,DclGetLogical)
        case('GRAPH')
          call sglget(pname,DclGetLogical)
        case('DEVICE')
          call swlget(pname,DclGetLogical)
        case('GLOBAL')
          call gllget(pname,DclGetLogical)
        case default
          call msgdmp('E', 'DclGetLogical', 'Invalid prefix ['//prefix//']')
      end select
    end function
!------------------------------------------------------
    function DclGetChar(name)
      character(len=8)              :: DclGetChar
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('SCALE')
          call uscget(pname,DclGetChar)
        case('DEVICE')
          call swcget(pname,DclGetChar)
        case('GLOBAL')
          call glcget(pname,DclGetChar)
        case default
          call msgdmp('E', 'DclGetChar', 'Invalid prefix ['//prefix//']')
      end select
    end function
!======================================================
    subroutine DclGetIntegerS(name, value)
      integer                       :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udiget(pname,value)
        case('HATCH')
          call ueiget(pname,value)
        case('VECTOR')
          call ugiget(pname,value)
        case('SCALE')
          call usiget(pname,value)
        case('AXIS')
          call uziget(pname,value)
        case('LOG')
          call uliget(pname,value)
        case('CALENDAR')
          call uciget(pname,value)
        case('MAP')
          call umiget(pname,value)
        case('GRAPH')
          call sgiget(pname,value)
        case('DEVICE')
          call swiget(pname,value)
        case('GLOBAL')
          call gliget(pname,value)
        case default
          call msgdmp('E', 'DclGetParm', 'Invalid prefix ['//prefix//']')
      end select

    end subroutine
!------------------------------------------------------
    subroutine DclGetRealS(name, value)
      real                          :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udrget(pname,value)
        case('HATCH')
          call uerget(pname,value)
        case('VECTOR')
          call ugrget(pname,value)
        case('SCALE')
          call usrget(pname,value)
        case('AXIS')
          call uzrget(pname,value)
        case('LOG')
          call ulrget(pname,value)
        case('CALENDAR')
          call ucrget(pname,value)
        case('MAP')
          call umrget(pname,value)
        case('GRAPH')
          call sgrget(pname,value)
        case('DEVICE')
          call swrget(pname,value)
        case('GLOBAL')
          call glrget(pname,value)
        case default
          call msgdmp('E', 'DclGetParm', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!------------------------------------------------------
    subroutine DclGetLogicalS(name, value)
      logical                       :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udlget(pname,value)
        case('HATCH')
          call uelget(pname,value)
        case('VECTOR')
          call uglget(pname,value)
        case('SCALE')
          call uslget(pname,value)
        case('AXIS')
          call uzlget(pname,value)
        case('LOG')
          call ullget(pname,value)
        case('CALENDAR')
          call uclget(pname,value)
        case('MAP')
          call umlget(pname,value)
        case('GRAPH')
          call sglget(pname,value)
        case('DEVICE')
          call swlget(pname,value)
        case('GLOBAL')
          call gllget(pname,value)
        case default
          call msgdmp('E', 'DclGetParm', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!------------------------------------------------------
    subroutine DclGetCharS(name, value)
      character(len=8)              :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('SCALE')
          call uscget(pname,value)
        case('DEVICE')
          call swcget(pname,value)
        case('GLOBAL')
          call glcget(pname,value)
        case default
          call msgdmp('E', 'DclGetParm', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!======================================================
    subroutine DclSetInteger(name, value)
      integer                       :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udiset(pname,value)
        case('HATCH')
          call ueiset(pname,value)
        case('VECTOR')
          call ugiset(pname,value)
        case('SCALE')
          call usiset(pname,value)
        case('AXIS')
          call uziset(pname,value)
        case('LOG')
          call uliset(pname,value)
        case('CALENDAR')
          call uciset(pname,value)
        case('MAP')
          call umiset(pname,value)
        case('GRAPH')
          call sgiset(pname,value)
        case('DEVICE')
          call swiset(pname,value)
        case('GLOBAL')
          call gliset(pname,value)
        case default
          call msgdmp('E', 'DclSetParm', 'Invalid prefix ['//prefix//']')
      end select

    end subroutine
!------------------------------------------------------
    subroutine DclSetReal(name, value)
      real                          :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udrset(pname,value)
        case('HATCH')
          call uerset(pname,value)
        case('VECTOR')
          call ugrset(pname,value)
        case('SCALE')
          call usrset(pname,value)
        case('AXIS')
          call uzrset(pname,value)
        case('LOG')
          call ulrset(pname,value)
        case('CALENDAR')
          call ucrset(pname,value)
        case('MAP')
          call umrset(pname,value)
        case('GRAPH')
          call sgrset(pname,value)
        case('DEVICE')
          call swrset(pname,value)
        case('GLOBAL')
          call glrset(pname,value)
        case default
          call msgdmp('E', 'DclSetParm', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!------------------------------------------------------
    subroutine DclSetLogical(name, value)
      logical                       :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udlset(pname,value)
        case('HATCH')
          call uelset(pname,value)
        case('VECTOR')
          call uglset(pname,value)
        case('SCALE')
          call uslset(pname,value)
        case('AXIS')
          call uzlset(pname,value)
        case('LOG')
          call ullset(pname,value)
        case('CALENDAR')
          call uclset(pname,value)
        case('MAP')
          call umlset(pname,value)
        case('GRAPH')
          call sglset(pname,value)
        case('DEVICE')
          call swlset(pname,value)
        case('GLOBAL')
          call gllset(pname,value)
        case default
          call msgdmp('E', 'DclSetParm', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!------------------------------------------------------
    subroutine DclSetChar(name, value)
      character(len=*)              :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('SCALE')
          call uscset(pname,value)
        case('DEVICE')
          call swcset(pname,value)
        case('GLOBAL')
          call glcset(pname,value)
        case default
          call msgdmp('E', 'DclSetParm', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!======================================================
    subroutine DclSetIntegerEX(name, value)
      integer                       :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udistx(pname,value)
        case('HATCH')
          call ueistx(pname,value)
        case('VECTOR')
          call ugistx(pname,value)
        case('SCALE')
          call usistx(pname,value)
        case('AXIS')
          call uzistx(pname,value)
        case('LOG')
          call ulistx(pname,value)
        case('CALENDAR')
          call ucistx(pname,value)
        case('MAP')
          call umistx(pname,value)
        case('GRAPH')
          call sgistx(pname,value)
        case('DEVICE')
          call swistx(pname,value)
        case('GLOBAL')
          call glistx(pname,value)
        case default
          call msgdmp('E', 'DclSetParmEX', 'Invalid prefix ['//prefix//']')
      end select

    end subroutine
!------------------------------------------------------
    subroutine DclSetRealEX(name, value)
      real                          :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udrstx(pname,value)
        case('HATCH')
          call uerstx(pname,value)
        case('VECTOR')
          call ugrstx(pname,value)
        case('SCALE')
          call usrstx(pname,value)
        case('AXIS')
          call uzrstx(pname,value)
        case('LOG')
          call ulrstx(pname,value)
        case('CALENDAR')
          call ucrstx(pname,value)
        case('MAP')
          call umrstx(pname,value)
        case('GRAPH')
          call sgrstx(pname,value)
        case('DEVICE')
          call swrstx(pname,value)
        case('GLOBAL')
          call glrstx(pname,value)
        case default
          call msgdmp('E', 'DclSetParmEX', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!------------------------------------------------------
    subroutine DclSetLogicalEX(name, value)
      logical                       :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('CONTOUR')
          call udlstx(pname,value)
        case('HATCH')
          call uelstx(pname,value)
        case('VECTOR')
          call uglstx(pname,value)
        case('SCALE')
          call uslstx(pname,value)
        case('AXIS')
          call uzlstx(pname,value)
        case('LOG')
          call ullstx(pname,value)
        case('CALENDAR')
          call uclstx(pname,value)
        case('MAP')
          call umlstx(pname,value)
        case('GRAPH')
          call sglstx(pname,value)
        case('DEVICE')
          call swlstx(pname,value)
        case('GLOBAL')
          call gllstx(pname,value)
        case default
          call msgdmp('E', 'DclSetParmEX', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
!------------------------------------------------------
    subroutine DclSetCharEX(name, value)
      character(len=*)              :: value
      character(len=*), intent(in)  :: name
      character(len=8)              :: prefix, pname

      n = index(name, ':') 
      prefix = name(1:n-1)
      pname  = name(n+1:)
      call cupper(prefix)
      
      select case(prefix)
        case('SCALE')
          call uscstx(pname,value)
        case('DEVICE')
          call swcstx(pname,value)
        case('GLOBAL')
          call glcstx(pname,value)
        case default
          call msgdmp('E', 'DclSetParmEX', 'Invalid prefix ['//prefix//']')
      end select
    end subroutine
end module dcl_parm
