      subroutine subsr(kstartsr,kendsr,ksr1,ksr2,glasr1,glasr2)
C............................................................Feb 2023
C determine gla1,gla2 for sunrise on terminatop
C kstartsr,kendsr - input limits
C ksr1,ksr2 - output actual limits between [lower, upper] peaks
C
      DIMENSION	 slat(360)
	  common /BL/slat
C
       glamax=0.0
	ksr2=kendsr
	DO kk=kstartsr,kendsr
	if (slat(kk).gt.glamax) then
	glamax=slat(kk)
	ksr2=kk
	endif
	ENDDO
C
	glamin=glamax
	ksr1=ksr2
      DO kk=ksr2,kstartsr,-1
	if (slat(kk).lt.glamin) then
	glamin=slat(kk)
	ksr1=kk
	endif
	ENDDO
	IF (slat(ksr1).eq.-89.5) THEN
	ksr1=ksr1+1
	endif
C
	glasr1=slat(ksr1)
      glasr2=glamax
	if (ksr1.eq.ksr2) glasr2=glasr1
C
	RETURN
	END