        program split4orb
c
c       program splits up file orbits.5 into individual files for each binary,
c       creating input files for orbgrid
c
        character*100 data
        character*10 wds
        character*18 fileout
        character*1 pcode,tcode
c
        open(10,file='orbits.5',status='UNKNOWN')
c
  100   read(10,901,end=999) data,wds
  901   format(a100,t1,a10)
        fileout='wds'//wds//'.dat'
        open(11,file=fileout,status='UNKNOWN')
        write(11,902) data
  902   format(a100)
c
c       read in orbital elements, write P, T, and e, as well as step sizes.
c       As default, use P/20 for pstep and tstep. For estep use 0.05 for e < 0.8
c       and estep=0.02 for e > 0.8
c
        read(10,903) p,pcode,t,tcode,e
  903   format(t2,f12.6,a1,t45,f12.6,a1,f9.6)
        if (pcode .eq. 'c') p=p*100.
        if (pcode .eq. 'd') p=p/365.2422
	if (pcode .eq. 'h') p=p/365.2421987/24.
	if (pcode .eq. 'm') p=p/365.2421987/24./60.
        if (tcode .eq. 'd') t=(t-33282.423)/365.2421987+1950.
        pstep=p/20.
        tstep=pstep
        estep = 0.05
        if (e .gt. 0.8) estep=0.02
        write(11,904) p,t,e,pstep,tstep,estep
  904   format(2f15.6,f11.6,2f10.6,f6.2)
c
  200   read(10,901) data,wds
        if (wds .eq. '          ') go to 300
        write(11,902) data
        go to 200
  300   close(11)
        go to 100
c
  999   stop
        end

