      subroutine subss(kstartss,kendss,kss1,kss2,glass1,glass2)
C............................................................Feb 2023
C determine gla1,gla2 for sunset on terminatop
C kstartss,kendss - input limits
C kss1,kss2 - output actual limits between [upper, lower] peaks
C
      DIMENSION	 slat(360)
	  common /BL/slat
C
	glamin=slat(kstartss)
	kss2=kstartss
      DO kk=kstartss,kendss
	if (slat(kk).lt.glamin) then
	glamin=slat(kk)
	kss2=kk
	endif
	ENDDO
	IF (slat(kss2).eq.-89.5) THEN
	kss2=kss2-1
	endif

C
       glamax=glamin
	kss1=kstartss
	DO kk=kss2,kstartss,-1
	if (slat(kk).gt.glamax) then
	glamax=slat(kk)
	kss1=kk
	endif
	ENDDO
C
      glass1=glamax
	glass2=slat(kss2)
	RETURN
	END