      MODULE sglib_mod
! 
!===========================================================================
! sgnco.F
      INTERFACE AGCLINS

      SUBROUTINE    R4_AGCLINS(
     > ZDATA,MXD,X,NX,Y,NY,CL,NCL)
      IMPLICIT NONE
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      integer nlm
      parameter(nlm=40)
      INTEGER MXD
      INTEGER NX
      INTEGER NY
      INTEGER NCL
      REAL(KIND=r4) :: ZDATA(:,:)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      REAL(KIND=r4) :: CL(NLM)
      end subroutine R4_AGCLINS

      SUBROUTINE    R8_AGCLINS(
     > R8_ZDATA,MXD,R8_X,NX,R8_Y,NY,R8_CL,NCL)
      IMPLICIT NONE
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      integer nlm
      parameter(nlm=40)
      INTEGER MXD
      INTEGER NX
      INTEGER NY
      INTEGER NCL
      REAL(KIND=r8) :: R8_ZDATA(:,:)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      REAL(KIND=r8) :: R8_CL(NLM)
      end subroutine R8_AGCLINS

      END INTERFACE

      INTERFACE AGRAPH
      SUBROUTINE AGRAPH(
     > MINX,MAXX,MINY,MAXY,XMIN,XMAX,YMIN,YMAX,XLABL,YLABL)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER MINX
      INTEGER MAXX
      INTEGER MINY
      INTEGER MAXY
      REAL(KIND=r4):: XMIN
      REAL(KIND=r4):: XMAX
      REAL(KIND=r4):: YMIN
      REAL(KIND=r4):: YMAX
      CHARACTER*(*) XLABL
      CHARACTER*(*) YLABL
      END SUBROUTINE AGRAPH

      SUBROUTINE R8_AGRAPH(
     > MINX,MAXX,MINY,MAXY,R8_XMIN,R8_XMAX,R8_YMIN,R8_YMAX,XLABL,YLABL)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER MINX
      INTEGER MAXX
      INTEGER MINY
      INTEGER MAXY
      REAL(KIND=r8) :: R8_XMIN
      REAL(KIND=r8) :: R8_XMAX
      REAL(KIND=r8) :: R8_YMIN
      REAL(KIND=r8) :: R8_YMAX
      CHARACTER*(*) XLABL
      CHARACTER*(*) YLABL
      END SUBROUTINE R8_AGRAPH
      END INTERFACE
!===========================================================================

       INTERFACE AGCXGET
       SUBROUTINE R4_AGCXGET(
     > XIND,FXX,X,NXS)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: XIND
      REAL(KIND=r4) :: FXX
      INTEGER NXS
      REAL(KIND=r4) :: X(:)
      END SUBROUTINE R4_AGCXGET
      
      SUBROUTINE R8_AGCXGET(
     > R8_XIND,R8_FXX,R8_X,NXS)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_XIND
      REAL(KIND=r8) :: R8_FXX
      INTEGER NXS
      REAL(KIND=r8) :: R8_X(:)
      END SUBROUTINE R8_AGCXGET
      END INTERFACE

      INTERFACE AGCYGET
      SUBROUTINE R4_AGCYGET(
     > YIND,FYY,Y,NYS)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: YIND
      REAL(KIND=r4) :: FYY
      INTEGER NYS
      REAL(KIND=r4) :: Y(:)
      END SUBROUTINE R4_AGCYGET
      SUBROUTINE R8_AGCYGET(
     > R8_YIND,R8_FYY,R8_Y,NYS)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_YIND
      REAL(KIND=r8) :: R8_FYY
      INTEGER NYS
      REAL(KIND=r8) :: R8_Y(:)
      END SUBROUTINE R8_AGCYGET
      END INTERFACE

      INTERFACE AGCPLST
      SUBROUTINE R4_AGCPLST(
     > PL1,PL2,KPL,X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER KPL
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      REAL(KIND=r4) :: PL1(:)
      REAL(KIND=r4) :: PL2(:)
      END SUBROUTINE R4_AGCPLST

      SUBROUTINE R8_AGCPLST(
     > R8_PL1,R8_PL2,KPL,R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER KPL
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      REAL(KIND=r8) :: R8_PL1(:)
      REAL(KIND=r8) :: R8_PL2(:)
      END SUBROUTINE R8_AGCPLST
      END INTERFACE


      INTERFACE AGNCOF
      SUBROUTINE R4_AGNCOF(
     > XCS,YCS,NCS,IAI,IAG,NAI)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER NCS
      INTEGER NAI
      REAL(KIND=r4) :: XCS(:)
      REAL(KIND=r4) :: YCS(:)
      INTEGER IAI(*)
      INTEGER IAG(*)
      END SUBROUTINE R4_AGNCOF

      SUBROUTINE R8_AGNCOF(
     > R8_XCS,R8_YCS,NCS,IAI,IAG,NAI)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER NCS
      INTEGER NAI
      REAL(KIND=r8) :: R8_XCS(:)
      REAL(KIND=r8) :: R8_YCS(:)
      INTEGER IAI(*)
      INTEGER IAG(*)
      END SUBROUTINE R8_AGNCOF
      END INTERFACE

      INTERFACE RCONTR
      SUBROUTINE R4_RCONTR(
     > K1,C,K2,A,MAXA,XARRAY,IMIN,IMAX,ISTEP,YARRAY,JMIN,
     > JMAX,JSTEP)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER K1
      INTEGER K2
      INTEGER MAXA
      INTEGER IMIN
      INTEGER IMAX
      INTEGER ISTEP
      INTEGER JMIN
      INTEGER JMAX
      INTEGER JSTEP
      REAL(KIND=r4) :: C(:)
      REAL(KIND=r4) :: A(:,:)
      REAL(KIND=r4) :: XARRAY(:)
      REAL(KIND=r4) :: YARRAY(:)
      END SUBROUTINE R4_RCONTR

      SUBROUTINE R8_RCONTR(
     > K1,R8_C,K2,R8_A,MAXA,R8_XARRAY,IMIN,IMAX,ISTEP,R8_YARRAY,JMIN,
     > JMAX,JSTEP)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER K1
      INTEGER K2
      INTEGER MAXA
      INTEGER IMIN
      INTEGER IMAX
      INTEGER ISTEP
      INTEGER JMIN
      INTEGER JMAX
      INTEGER JSTEP
      REAL(KIND=r8) :: R8_C(:)
      REAL(KIND=r8) :: R8_A(:,:)
      REAL(KIND=r8) :: R8_XARRAY(:)
      REAL(KIND=r8) :: R8_YARRAY(:)
      END SUBROUTINE R8_RCONTR
      END INTERFACE

      INTERFACE CONTUR
      SUBROUTINE R4_CONTUR(
     > K1,C,K2,A,MAXA,XARRAY,IMIN,IMAX,ISTEP,YARRAY,JMIN,
     > JMAX,JSTEP)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER K1
      INTEGER K2
      INTEGER MAXA
      INTEGER IMIN
      INTEGER IMAX
      INTEGER ISTEP
      INTEGER JMIN
      INTEGER JMAX
      INTEGER JSTEP
      REAL(KIND=r4) :: C(:)
      REAL(KIND=r4) :: A(:,:)
      REAL(KIND=r4) :: XARRAY(:,:)
      REAL(KIND=r4) :: YARRAY(:,:)  
      END SUBROUTINE R4_CONTUR  

      SUBROUTINE R8_CONTUR(
     > K1,R8_C,K2,R8_A,MAXA,R8_XARRAY,IMIN,IMAX,ISTEP,R8_YARRAY,JMIN,
     > JMAX,JSTEP)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER K1
      INTEGER K2
      INTEGER MAXA
      INTEGER IMIN
      INTEGER IMAX
      INTEGER ISTEP
      INTEGER JMIN
      INTEGER JMAX
      INTEGER JSTEP
      REAL(KIND=r8) :: R8_C(:)
      REAL(KIND=r8) :: R8_A(:,:)
      REAL(KIND=r8) :: R8_XARRAY(:,:)
      REAL(KIND=r8) :: R8_YARRAY(:,:)
      END SUBROUTINE R8_CONTUR  
      END INTERFACE

      INTERFACE AGCLXY
      SUBROUTINE R4_AGCLXY(
     > XAR,NX,IMIN)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER NX
      INTEGER IMIN
      REAL(KIND=r4) :: XAR(:)
      END SUBROUTINE R4_AGCLXY

      SUBROUTINE R8_AGCLXY(
     > R8_XAR,NX,IMIN)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER NX
      INTEGER IMIN
      REAL(KIND=r8) :: R8_XAR(:)
      END SUBROUTINE R8_AGCLXY
      END INTERFACE

      INTERFACE AGCUSET
      SUBROUTINE R4_AGCUSET(
     > XARRAY,YARRAY,MAXA,NX,NY)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER MAXA
      INTEGER NX
      INTEGER NY
      REAL(KIND=r4) :: XARRAY(:,:)
      REAL(KIND=r4) :: YARRAY(:,:)
      END SUBROUTINE R4_AGCUSET

      SUBROUTINE R8_AGCUSET(
     > R8_XARRAY,R8_YARRAY,MAXA,NX,NY)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER MAXA
      INTEGER NX
      INTEGER NY
      REAL(KIND=r8) :: R8_XARRAY(:,:)
      REAL(KIND=r8) :: R8_YARRAY(:,:)
      END SUBROUTINE R8_AGCUSET
      END INTERFACE

      INTERFACE AGCULEV
      SUBROUTINE R4_AGCULEV(
     > K1,C,K2,ZAR,NZ,CL,NCL)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER K1
      INTEGER K2
      INTEGER NZ
      INTEGER NCL
      REAL(KIND=r4) :: C(:)
      REAL(KIND=r4) :: ZAR(:)
      REAL(KIND=r4) :: CL(:)
      END SUBROUTINE R4_AGCULEV 

      SUBROUTINE R8_AGCULEV(
     > K1,R8_C,K2,R8_ZAR,NZ,R8_CL,NCL)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER K1
      INTEGER K2
      INTEGER NZ
      INTEGER NCL
      REAL(KIND=r8) :: R8_C(:)
      REAL(KIND=r8) :: R8_ZAR(:)
      REAL(KIND=r8) :: R8_CL(:)
      END SUBROUTINE R8_AGCULEV 
      END INTERFACE

      INTERFACE AGRCFR
      SUBROUTINE R4_AGRCFR(
     > X,IMIN,IMAX,ISTEP,Y,JMIN,JMAX,JSTEP,IGRID)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER IMIN
      INTEGER IMAX
      INTEGER ISTEP
      INTEGER JMIN
      INTEGER JMAX
      INTEGER JSTEP
      INTEGER IGRID
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      END SUBROUTINE R4_AGRCFR

      SUBROUTINE R8_AGRCFR(
     > R8_X,IMIN,IMAX,ISTEP,R8_Y,JMIN,JMAX,JSTEP,IGRID)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER IMIN
      INTEGER IMAX
      INTEGER ISTEP
      INTEGER JMIN
      INTEGER JMAX
      INTEGER JSTEP
      INTEGER IGRID
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      END SUBROUTINE R8_AGRCFR
      END INTERFACE

      INTERFACE AGCFRAM
      SUBROUTINE R4_AGCFRAM(
     > X,NX,Y,NY,IGRID)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER NX
      INTEGER NY
      INTEGER IGRID
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      END SUBROUTINE R4_AGCFRAM

      SUBROUTINE R8_AGCFRAM(
     > R8_X,NX,R8_Y,NY,IGRID)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER NX
      INTEGER NY
      INTEGER IGRID
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      END SUBROUTINE R8_AGCFRAM
      END INTERFACE

!==============================================================
! sggrf.F

      INTERFACE CHECK

      SUBROUTINE R4_CHECK(X,Y)
      IMPLICIT NONE
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      end subroutine R4_CHECK

      SUBROUTINE    R8_CHECK(R8_X,R8_Y)
      IMPLICIT NONE
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      end subroutine R8_CHECK

      END INTERFACE

      INTERFACE DSPLAY
      SUBROUTINE R4_DSPLAY(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      END SUBROUTINE R4_DSPLAY

      SUBROUTINE R8_DSPLAY(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      END SUBROUTINE R8_DSPLAY
      END INTERFACE

      INTERFACE AGDSPL
      SUBROUTINE R4_AGDSPL(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      END SUBROUTINE R4_AGDSPL

      SUBROUTINE R8_AGDSPL(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      END SUBROUTINE R8_AGDSPL
      END INTERFACE

      INTERFACE AGMNMX
      SUBROUTINE R4_AGMNMX(ARRAY,AMIN,AMAX,NPTA,ITYPE)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: AMIN
      REAL(KIND=r4) :: AMAX
      INTEGER NPTA
      INTEGER ITYPE
      REAL(KIND=r4) :: ARRAY(:)
      END SUBROUTINE R4_AGMNMX

      SUBROUTINE R8_AGMNMX(
     > R8_ARRAY,R8_AMIN,R8_AMAX,NPTA,ITYPE)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_AMIN
      REAL(KIND=r8) :: R8_AMAX
      INTEGER NPTA
      INTEGER ITYPE
      REAL(KIND=r8) :: R8_ARRAY(:)
      END SUBROUTINE R8_AGMNMX
      END INTERFACE

      INTERFACE MNMX
      SUBROUTINE R4_MNMX(ARRAY,AMIN,AMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: AMIN
      REAL(KIND=r4) :: AMAX
      REAL(KIND=r4) :: ARRAY(:)
      END SUBROUTINE R4_MNMX

      SUBROUTINE R8_MNMX(R8_ARRAY,R8_AMIN,R8_AMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_AMIN
      REAL(KIND=r8) :: R8_AMAX
      REAL(KIND=r8) :: R8_ARRAY(:)
      END SUBROUTINE R8_MNMX

      END INTERFACE

      INTERFACE CPLOT
      SUBROUTINE R4_CPLOT(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      END SUBROUTINE R4_CPLOT
      SUBROUTINE R8_CPLOT(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      END SUBROUTINE R8_CPLOT
      END INTERFACE

      INTERFACE AGKEYS
      SUBROUTINE R4_AGKEYS(X,Y,IFASTX,IFASTY,LIMIT)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER IFASTX
      INTEGER IFASTY
      INTEGER LIMIT
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      END  SUBROUTINE R4_AGKEYS

      SUBROUTINE R8_AGKEYS(R8_X,R8_Y,IFASTX,IFASTY,LIMIT)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER IFASTX
      INTEGER IFASTY
      INTEGER LIMIT
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      END  SUBROUTINE R8_AGKEYS
      END INTERFACE

      INTERFACE BSYMS
      SUBROUTINE BSYMS(X,Y,ISYM)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      INTEGER ISYM
      END SUBROUTINE BSYMS
      SUBROUTINE R8_BSYMS(R8_X,R8_Y,ISYM)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      INTEGER ISYM
      END SUBROUTINE R8_BSYMS
      END INTERFACE 

      INTERFACE SYMOUT
      SUBROUTINE SYMOUT(ISYM,FACTR)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER ISYM
      REAL(KIND=r4) :: FACTR
      END SUBROUTINE SYMOUT
      SUBROUTINE R8_SYMOUT(ISYM,R8_FACTR)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER ISYM
      REAL(KIND=r8) :: R8_FACTR
      END SUBROUTINE R8_SYMOUT
      END INTERFACE 

      INTERFACE TEKSYM
      SUBROUTINE TEKSYM(
     > ISYM,AMULT)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER ISYM
      REAL(KIND=r4) :: AMULT
      END SUBROUTINE TEKSYM 
      SUBROUTINE R8_TEKSYM(
     > ISYM,R8_AMULT)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER ISYM
      REAL(KIND=r8) :: R8_AMULT
      END SUBROUTINE R8_TEKSYM 
      END INTERFACE  

!
!============================================================================
! sgext.F

      INTERFACE AGEYA
      SUBROUTINE R4_AGEYA(X,Y,E)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      REAL(KIND=r4) :: E(:)
      END SUBROUTINE R4_AGEYA

      SUBROUTINE R8_AGEYA(R8_X,R8_Y,R8_E)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      REAL(KIND=r8) :: R8_E(:)
      END SUBROUTINE R8_AGEYA
      END INTERFACE

      INTERFACE AGEXA
      SUBROUTINE R4_AGEXA(X,Y,E)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X(:)
      REAL(KIND=r4) :: Y(:)
      REAL(KIND=r4) :: E(:)
      END SUBROUTINE R4_AGEXA

      SUBROUTINE R8_AGEXA(R8_X,R8_Y,R8_E)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X(:)
      REAL(KIND=r8) :: R8_Y(:)
      REAL(KIND=r8) :: R8_E(:)
      END SUBROUTINE R8_AGEXA
      END INTERFACE

      INTERFACE AGEXS
      SUBROUTINE AGEXS(X,Y,E)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      REAL(KIND=r4) :: E
      END SUBROUTINE AGEXS
      SUBROUTINE R8_AGEXS(R8_X,R8_Y,R8_E)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      REAL(KIND=r8) :: R8_E
      END SUBROUTINE R8_AGEXS
      END INTERFACE

      INTERFACE AGEXSR
      SUBROUTINE AGEXSR(X,Y,ELO,EHI)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      REAL(KIND=r4) :: ELO
      REAL(KIND=r4) :: EHI
      END SUBROUTINE AGEXSR
      SUBROUTINE R8_AGEXSR(R8_X,R8_Y,R8_ELO, R8_EHI)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      REAL(KIND=r8) :: R8_ELO
      REAL(KIND=r8) :: R8_EHI
      END SUBROUTINE R8_AGEXSR
      END INTERFACE

      INTERFACE DLIMX
      SUBROUTINE DLIMX(XMIN,XMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4), intent(in) :: XMIN
      REAL(KIND=r4), intent(in) :: XMAX
      END SUBROUTINE DLIMX

      SUBROUTINE R8_DLIMX(R8_XMIN,R8_XMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8), intent(in) :: R8_XMIN
      REAL(KIND=r8), intent(in) :: R8_XMAX
      END SUBROUTINE R8_DLIMX
      END INTERFACE

      INTERFACE DLIMY
      SUBROUTINE DLIMY(XMIN,XMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4), intent(in) :: XMIN
      REAL(KIND=r4), intent(in) :: XMAX
      END SUBROUTINE DLIMY

      SUBROUTINE R8_DLIMY(R8_XMIN,R8_XMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8), intent(in) :: R8_XMIN
      REAL(KIND=r8), intent(in) :: R8_XMAX
      END SUBROUTINE R8_DLIMY
      END INTERFACE

      INTERFACE AGVCUR
      SUBROUTINE AGVCUR(UCH,X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      CHARACTER*1 UCH
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      END SUBROUTINE AGVCUR  
      SUBROUTINE R8_AGVCUR(UCH,R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      CHARACTER*1 UCH
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_AGVCUR  

      END INTERFACE
!=========================================================================
! sgtcs.f

      INTERFACE VCURSR
      SUBROUTINE VCURSR(ICHAR,X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER ICHAR
      REAL(KIND=r4) :: X 
      REAL(KIND=r4) :: Y
      END SUBROUTINE VCURSR
      SUBROUTINE R8_VCURSR(ICHAR,R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER ICHAR
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_VCURSR
      END INTERFACE

      INTERFACE MOVEA
      SUBROUTINE MOVEA(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      END SUBROUTINE MOVEA
      SUBROUTINE R8_MOVEA(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_MOVEA
      END INTERFACE

      INTERFACE MOVER
      SUBROUTINE MOVER(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      END SUBROUTINE MOVER
      SUBROUTINE R8_MOVER(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_MOVER
      END INTERFACE


      INTERFACE DRAWA
      SUBROUTINE DRAWA(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      END SUBROUTINE DRAWA
      SUBROUTINE R8_DRAWA(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_DRAWA
      END INTERFACE

      INTERFACE DRAWR
      SUBROUTINE DRAWR(DX,DY)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: DX
      REAL(KIND=r4) :: DY
      END SUBROUTINE DRAWR
      SUBROUTINE R8_DRAWR(R8_DX,R8_DY)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_DX
      REAL(KIND=r8) :: R8_DY
      END SUBROUTINE R8_DRAWR
      END INTERFACE



      INTERFACE POINTA
      SUBROUTINE POINTA(X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      END SUBROUTINE POINTA
      SUBROUTINE R8_POINTA(R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_POINTA
      END INTERFACE

      INTERFACE DASHA
      SUBROUTINE DASHA(X,Y,LDASH)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      INTEGER LDASH
      END SUBROUTINE DASHA
      SUBROUTINE R8_DASHA(R8_X,R8_Y,LDASH)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      INTEGER LDASH
      END SUBROUTINE R8_DASHA
      END INTERFACE

      INTERFACE WINCOT
      SUBROUTINE WINCOT(X,Y,IX,IY)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      INTEGER IX
      INTEGER IY
      END SUBROUTINE WINCOT
      SUBROUTINE R8_WINCOT(R8_X,R8_Y,IX,IY)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      INTEGER IX
      INTEGER IY
      END SUBROUTINE R8_WINCOT
      END INTERFACE


      INTERFACE REVCOT
      SUBROUTINE REVCOT(IX,IY,X,Y)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER IX
      INTEGER IY
      REAL(KIND=r4) :: X
      REAL(KIND=r4) :: Y
      END SUBROUTINE REVCOT
      SUBROUTINE R8_REVCOT(IX,IY,R8_X,R8_Y)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER IX
      INTEGER IY
      REAL(KIND=r8) :: R8_X
      REAL(KIND=r8) :: R8_Y
      END SUBROUTINE R8_REVCOT
      END INTERFACE


      INTERFACE SEEDW
      SUBROUTINE SEEDW(XMIN,XMAX,YMIN,YMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: XMIN
      REAL(KIND=r4) :: XMAX
      REAL(KIND=r4) :: YMIN
      REAL(KIND=r4) :: YMAX
      END  SUBROUTINE SEEDW
      SUBROUTINE R8_SEEDW(R8_XMIN,R8_XMAX,R8_YMIN,R8_YMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_XMIN
      REAL(KIND=r8) :: R8_XMAX
      REAL(KIND=r8) :: R8_YMIN
      REAL(KIND=r8) :: R8_YMAX
      END  SUBROUTINE R8_SEEDW
      END INTERFACE

!==========================================================================
! sgiso.f

      INTERFACE AGISOC
      SUBROUTINE AGISOC(
     > X,Y,Z,NXDIM,NX,NY,XU,YU,ZU,M)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER NXDIM
      INTEGER NX
      INTEGER NY
      CHARACTER*(*) XU
      CHARACTER*(*) YU
      CHARACTER*(*) ZU
      REAL(KIND=r4) ::  X(NXDIM)
      REAL(KIND=r4) ::  Y(NY)
      REAL(KIND=r4) ::  Z(NXDIM,NY)
      INTEGER M(2,NX,NY)
      END SUBROUTINE AGISOC
      SUBROUTINE R8_AGISOC(
     > R8_X,R8_Y,R8_Z,NXDIM,NX,NY,XU,YU,ZU,M)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER NXDIM
      INTEGER NX
      INTEGER NY
      CHARACTER*(*) XU
      CHARACTER*(*) YU
      CHARACTER*(*) ZU
      REAL(KIND=r8) ::  R8_X(NXDIM)
      REAL(KIND=r8) ::  R8_Y(NY)
      REAL(KIND=r8) ::  R8_Z(NXDIM,NY)
      INTEGER M(2,NX,NY)
      END SUBROUTINE R8_AGISOC
      END INTERFACE

      INTERFACE AGISOM
      SUBROUTINE AGISOM(
     > X,Y,Z,NXDIM,NX,NY,XU,YU,ZU)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      INTEGER NXDIM
      INTEGER NX
      INTEGER NY
      CHARACTER*(*) XU
      CHARACTER*(*) YU
      CHARACTER*(*) ZU
      REAL(KIND=r4) ::  X(NXDIM)
      REAL(KIND=r4) ::  Y(NY)
      REAL(KIND=r4) ::  Z(NXDIM,NY)
      END SUBROUTINE AGISOM  
      SUBROUTINE R8_AGISOM(
     > R8_X,R8_Y,R8_Z,NXDIM,NX,NY,XU,YU,ZU)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      INTEGER NXDIM
      INTEGER NX
      INTEGER NY
      CHARACTER*(*) XU
      CHARACTER*(*) YU
      CHARACTER*(*) ZU
      REAL(KIND=r8) ::  R8_X(NXDIM)
      REAL(KIND=r8) ::  R8_Y(NY)
      REAL(KIND=r8) ::  R8_Z(NXDIM,NY)
      END SUBROUTINE R8_AGISOM  
      END INTERFACE

      INTERFACE AGIDLX
      SUBROUTINE AGIDLX(XMIN,XMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: XMIN
      REAL(KIND=r4) :: XMAX
      END SUBROUTINE AGIDLX
      SUBROUTINE R8_AGIDLX(R8_XMIN,R8_XMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_XMIN
      REAL(KIND=r8) :: R8_XMAX
      END SUBROUTINE R8_AGIDLX
      END INTERFACE
      INTERFACE AGIDLZ
      SUBROUTINE AGIDLZ(ZMIN,ZMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: ZMIN
      REAL(KIND=r4) :: ZMAX
      END SUBROUTINE AGIDLZ
      SUBROUTINE R8_AGIDLZ(R8_ZMIN,R8_ZMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_ZMIN
      REAL(KIND=r8) :: R8_ZMAX
      END SUBROUTINE R8_AGIDLZ
      END INTERFACE
      INTERFACE AGIDLY
      SUBROUTINE AGIDLY(YMIN,YMAX)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) :: YMIN
      REAL(KIND=r4) :: YMAX
      END SUBROUTINE AGIDLY
      SUBROUTINE R8_AGIDLY(R8_YMIN,R8_YMAX)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) :: R8_YMIN
      REAL(KIND=r8) :: R8_YMAX
      END SUBROUTINE R8_AGIDLY
      END INTERFACE

      INTERFACE AGICAU
      SUBROUTINE AGICAU(
     > XXCOOR,YYCOOR,ZZCOOR,IXS,IZS)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      REAL(KIND=r4) ::  XXCOOR
      REAL(KIND=r4) ::  YYCOOR
      REAL(KIND=r4) ::  ZZCOOR
      INTEGER IXS
      INTEGER IZS
      END SUBROUTINE AGICAU
      SUBROUTINE R8_AGICAU(
     > R8_XXCOOR,R8_YYCOOR,R8_ZZCOOR,IXS,IZS)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      REAL(KIND=r8) ::  R8_XXCOOR
      REAL(KIND=r8) ::  R8_YYCOOR
      REAL(KIND=r8) ::  R8_ZZCOOR
      INTEGER IXS
      INTEGER IZS
      END SUBROUTINE R8_AGICAU
      END INTERFACE

      INTERFACE AGCLGEN
      SUBROUTINE AGCLGEN(
     > Z,MXD,NX,NY,CCLO,CHI,CINC,CL,NCL,ICNST)
      integer, PARAMETER :: r4 = SELECTED_REAL_KIND(6,37)
      integer   nlm
      parameter (nlm=40)
      INTEGER MXD
      INTEGER NX
      INTEGER NY
      REAL(KIND=r4) ::  CCLO
      REAL(KIND=r4) ::  CHI
      REAL(KIND=r4) ::  CINC
      INTEGER NCL
      INTEGER ICNST
      REAL(KIND=r4) ::  Z(MXD,NY)
      REAL(KIND=r4) ::  CL(NLM)
      END SUBROUTINE AGCLGEN  
      SUBROUTINE R8_AGCLGEN(
     > R8_Z,MXD,NX,NY,R8_CCLO,R8_CHI,R8_CINC,R8_CL,NCL,ICNST)
      integer, PARAMETER :: r8 = SELECTED_REAL_KIND(12,100)
      integer   nlm
      parameter (nlm=40)
      INTEGER MXD
      INTEGER NX
      INTEGER NY
      REAL(KIND=r8) ::  R8_CCLO
      REAL(KIND=r8) ::  R8_CHI
      REAL(KIND=r8) ::  R8_CINC
      INTEGER NCL
      INTEGER ICNST
      REAL(KIND=r8) ::  R8_Z(MXD,NY)
      REAL(KIND=r8) ::  R8_CL(NLM)
      END SUBROUTINE R8_AGCLGEN  
      END INTERFACE


      END MODULE sglib_mod





