*      --------------------
*	SEQDIRXYZ.F
*      --------------------

*      convert sequential files to direct access files


       IMPLICIT DOUBLE PRECISION (A-H,O-Z)
       CHARACTER*20 INFILE,OUTFILE

       DIMENSION CMX(6),CMY(6),CFX(4),CFY(4),cmz(6),cfz(4)
       dimension freq(8),idn(8),dellt(8)

       write(*,*) ' Mumber of the planet '
       write(*,*) ' Mars: 4 , Jupiter: 5 , Saturn: 6 , Uranus: 7'
       read(*,*) num

       WRITE(*,*) ' Input file '
       READ(*,'(A)') INFILE
       WRITE(*,*) ' Output file '
       READ(*,'(A)') OUTFILE

       OPEN(10,FILE=OUTFILE,ACCESS='DIRECT',RECL=284,STATUS='NEW')
       OPEN(1,FILE=INFILE,ACCESS='SEQUENTIAL')

       write(*,*) ' print to control ?'
       write(*,*) ' yes => #0 , no => return or 0  '
       read(*,3) iecr

3      format(i1)
       IDD=1
        read(1,*) npla,isat
	write(*,*) npla,isat
        rewind 01

        if (num.eq.4) then
            read(1,*) npla,nsat,(idn(i),i=1,isat),
     .                (freq(i),i=1,isat),(dellt(i),i=1,isat)
     .                ,ienrf,djj,jan
4	format(2i2,2i5,2f8.4,2f5.1,i5,f15.3,i5)
	write(*,*) ienrf,djj,jan
       endif

        if (num.eq.5) then
            read(1,*) npla,nsat,(idn(i),i=1,isat),
     .                (freq(i),i=1,isat),(dellt(i),i=1,isat)
     .                ,ienrf,djj,jan
5	format(2i2,4i5,4f8.4,4f5.1,i5,f15.3,i5)
       endif

        if (num.eq.6) then
            read(1,6) npla,nsat,(idn(i),i=1,isat),
     .                (freq(i),i=1,isat),(dellt(i),i=1,isat)
     .                ,ienrf,djj,jan
	print *, npla,nsat,(idn(i),i=1,isat),
     .                (freq(i),i=1,isat),(dellt(i),i=1,isat)
     .                ,ienrf,djj,jan
6	format(2i2,8i5,8f8.4,8f5.1,i5,f15.3,i5)
       endif

        if (num.eq.7) then
            read(1,*) npla,nsat,(idn(i),i=1,isat),
     .                (freq(i),i=1,isat),(dellt(i),i=1,isat)
     .                ,ienrf,djj,jan
7	format(2i2,5i5,5f8.4,5f5.1,i5,f15.3,i5)
       endif
       write(*,*) npla,nsat,(idn(i),i=1,isat),
     .            (freq(i),i=1,isat),(dellt(i),i=1,isat),
     .             ienrf,djj,jan
       write(10,rec=idd) npla,nsat,(idn(i),i=1,isat),
     .                   (freq(i),i=1,isat),(dellt(i),i=1,isat)
     .                   ,ienrf,djj,jan
       IDD=2
1      CONTINUE
        read(1,9,end=2)  isat,idx,ldat1,ldat2,t0,cmx,cfx,cmy,cfy,
     .       cmz,cfz
9	format(i1,i5,2i8,f9.1,30d17.10)
       if (iecr.ne.0)
     . write(*,*) isat,idx,ldat1,ldat2,t0,cmx,cfx,cmy,cfy,cmz,cfz
       write(10,rec=idd) isat,idx,ldat1,ldat2,t0,cmx,cfx,cmy,cfy,
     .  cmz,cfz
       IDD=IDD+1
       GO TO 1
2      CONTINUE
       print *, ' idd=',idd

       STOP 223
       END
