!SUBS
!SUB1
        SUBROUTINE LS_D(ls,dmjd,dmjdls,vls,numls)
!******** determined the leap seconds for dmjd data *********
!******** before execution you have to load leap second data
!******** by calling subroutine  LS_L(dmjdls,vls,numls) *****
        REAL*8 dmjdls(100),vls(100),ls,dmjd
        INTEGER*4 numls
	     ls=vls(1)-1
	     if(dmjd.ge.dmjdls(numls)) then
	      ls=vls(numls)
	      goto 1
	     endif
	     if(numls.ge.2) then
	      do i=2,numls
           if(dmjd.ge.dmjdls(i-1).and.dmjd.lt.dmjdls(i)) then
	       ls=vls(i-1)
	       endif
          enddo
         endif
 1       continue
        END SUBROUTINE LS_D
!**********************************************************
        SUBROUTINE LS_L(dmjdls,vls,numls)
! ************ SUBROUTINES LOADS LEAP SECONDS DATA ********
! ************ form LS.INI file ***************************
!!!!!!!  CHECK THAT THE DATA IN LS.INI ARE ACTUAL   !!!!!!!
        REAL*8 dmjdls(100),vls(100),D,yyyy,mm,ch,dmjd
        INTEGER*4 IG,IM,ID,num,numls
        open(3,file="ls.ini")
		num=1
	    do while(.true.)
          READ(3,*,end=11) ig,im,id,vls(num)
		  yyyy=DFLOAT(IG)
		  mm=DFLOAT(IM)
		  ch=DFLOAT(ID)
          CALL juddy(DMJD,yyyy,mm,ch)
		  dmjdls(num)=dmjd
          num=num+1
        enddo
 11     continue
        close(3)
        numls=num-1
	END SUBROUTINE LS_L
!ESUB1
!SUB2
       SUBROUTINE juddy(DMJD,yyyy,mm,ch)
       REAL*8 B,CH,MM,YYYY,JD,DMJD
       if(mm.ne.1.and.mm.ne.2) goto 1
       yyyy=yyyy-1
       mm=mm+12
   1   continue
       if(yyyy.lt.0) goto 2
       B=yyyy+mm/100+ch/10000
       if(B.lt.1582.1015) goto 3
       B=2-dint(yyyy/100)+dint((yyyy/100)/4)
       goto 4
   3   B=0
   4   continue
       JD=int(365.25d0*yyyy)+int(30.6001d0*(mm+1))+ch+1720995.0d0+B
       goto 5
   2   B=0
       JD=int(365.25d0*yyyy-0.75d0)+int(30.6001d0*(mm+1))+ch+1720995.0d0+B
   5   continue
       JD=JD-0.5d0 ! for 0.0 hour
       DMJD=JD-2400000.5d0
       END SUBROUTINE juddy
!ESUB2
!ESUBS
