*     ---------------
*     PROGRAM INSTALL
*     ---------------
*
*     BDL-GF9612
*
*     This program allows to copy the original sequential ASCII files
*     SLP96 into direct access binary files SLP96.
*
*     Uses the subroutine INSTALL.
*
* --- Declarations -----------------------------------------------------
*
      implicit double precision (a-h,o-z)
      character*40 a,fname1(8),fname2(8)
*
* --- Parameters -------------------------------------------------------
*
*     fname1  = names of the sequential ASCII files SLP96.
*     fname2  = names of the direct access binary files SLP96.
*     lu1     = logical unit of the sequential ASCII files SLP96.
*     lu2     = logical unit of the direct access binary files SLP96.
*
      data fname1/
     .'slp96.s16','slp96.s17','slp96.s18','slp96.s19',
     .'slp96.s20','slp96.s21','slp96.s22','slp96.s23'/
*
      data fname2/
     .'slp96.d16','slp96.d17','slp96.d18','slp96.d19',
     .'slp96.d20','slp96.d21','slp96.d22','slp96.d23'/
*
      data lu1/11/
      data lu2/12/
*
* --- Installation -----------------------------------------------------
*
      write (*,'(//2x,''SLP96 : INSTALLATION (BDL-GF9612)'')')
*
      do i=1,8
*
100      continue
*
         write (*,'(//2x,''Installation : '',a)') fname1(i)
*
         write (*,'(/2x,''Confirm this installation (y/n) ? '',$)')
         read (*,'(a)') a
         if (a(1:1).eq.'n'.or.a(1:1).eq.'N') goto 200
         if (a(1:1).ne.'y'.and.a(1:1).ne.'Y') goto 100
         write (*,'(/2x,''Executing .... '')')
*
         call INSTALL (fname1(i),lu1,fname2(i),lu2,ierr)
*
         if (ierr.ne.0) then
            write (*,'(/2x,''Error'',i3/)') ierr
            stop
         endif
*
         write (*,'(/2x,''Installed    : '',a)') fname2(i)
*
200      continue
*
      enddo
*
      write (*,'(/2x,''Program ended''/)')
      stop
*
      end
*
*
*
*     -----------------------------------------------
      subroutine INSTALL (fname1,lu1,fname2,lu2,ierr)
*     -----------------------------------------------
*
*     BDL-GF9612
*
*     Installation of Ephemerides SLP96.
*
*     This routine copies an original sequential ASCII file SLP96 into
*     a direct access binary file SLP96.
*
* --- Input ------------------------------------------------------------
*
*               Sequential ASCII file SLP96.
*     fname1    Name of the file (character*40)
*     lu1       Logical unit of the file (integer).
*
*               Direct access binary file SLP96.
*     fname2    Name of the file (character*40)
*     lu2       Logical unit of the file (integer).
*
* --- Ouput ------------------------------------------------------------
*
*     ierr      Error index (integer).
*
*               ierr=0 : no error.
*               ierr=1 : error in the sequential ASCII file SLP96.
*               ierr=2 : error in the direct access binary file SLP96.
*
* --- Declarations -----------------------------------------------------
*
      implicit double precision (a-h,o-z)
      character*40 fname1,fname2
      logical fexist
*
      parameter (lrec=5576,lcoef=lrec/8-1)
*
      dimension coef(lcoef),loc(11,3),fl(3),ie(3)
*
* --- Open the sequential ASCII file SLP96 -----------------------------
*
      inquire (file=fname1,exist=fexist)
*
      if (.not.fexist) then
         ierr=1
         return
      endif
*
      open (lu1,file=fname1,access='sequential',status='old',
     .     iostat=nerr)
*
      if (nerr.ne.0) then
         ierr=1
         return
      endif
*
      read (lu1,1001,iostat=nerr)
     .     idf,tla,tlb,delta,ncoef,nblock,nbytes,loc
*
      if (nerr.ne.0) then
         ierr=1
         return
      endif
*
* --- Open the direct access binary SLP96 ------------------------------
*
      inquire (file=fname2,exist=fexist)
*
      if (fexist) then
         ierr=2
         return
      endif
*
      open (lu2,file=fname2,access='direct',recl=lrec,status='new',
     .      iostat=nerr)
*
      if (nerr.ne.0) then
         ierr=2
         return
      endif
*
* --- Copy the sequential file into the direct access file -------------
*
      write (lu2,rec=1) idf,tla,tlb,delta,ncoef,nblock,nbytes,loc
*
      do n=2,nblock
         read (lu1,1002) num,tjd0
         do k=1,696,3
            read (lu1,1003) (fl(i),ie(i),i=1,3)
            do i=1,3
               l=k+i-1
               coef(l)=fl(i)*1.d1**ie(i)
            enddo
         enddo
         write (lu2,rec=n) tjd0,(coef(l),l=1,ncoef)
      enddo
*
* --- Exit -------------------------------------------------------------
*
      close (lu1)
      close (lu2)
*
      ierr=0
      return
*
* --- Formats ----------------------------------------------------------
*
1001  format (i10/f10.2/f10.2/f10.2/i10/i10/i10/
     .        3(11(i3.3,1x)/))
1002  format (i8.8,2x,f10.2)
1003  format (3(f20.16,i4))
*
      end
