      subroutine pedin
      include 'TThead.f'

      character*12  oid
      real*8 x,v,z

      open(10,file='PEDA4S.d',form='formatted',status='old')
c
      adiag = 0.0
      sir = 0
      dam = 0
      bii = 1.d0
      jped = 0
      mam=0
c
 10   read(10,1001,end=50)ka,ks,kd,x,z,oid
 1001 format(1x,3i10,1x,d20.12,2x,d20.12,2x,a12)
      
      mam = mam + 1

      sir(ka) = nam
        if(ks.gt.0)sir(ka) = ks
      dam(ka) = nam
        if(kd.gt.0)dam(ka) = kd
      bii(ka) = x

      adiag(ka) = adiag(ka) + x
      v = 0.25*x
      if(ks.gt.0)adiag(ks)=adiag(ks)+v
      if(kd.gt.0)adiag(kd)=adiag(kd)+v
c
      go to 10
 50   close(10)
      print *,'pedin, mam= ',mam,nam
c
c read and store coded pedigree file
c
      open(11,file='CPEDA4S.d',form='formatted',status='old')
      mped = 0
 60   read(11,1101,end=90)ia,ic,is,id
 1101 format(1x,i10,i3,1x,2i10)
        mped = mped + 1
        if(mped.gt.nped)go to 89
        cpa(mped)=ia
        cpc(mped)=ic
          if(is.lt.1)is = nam
          if(id.lt.1)id = nam
        cps(mped)=is
        cpd(mped)=id
        if(ic.eq.0)then
           jped(ia)=mped
        endif
        go to 60
c
 89   print *,'nped limit exceeded in TTpedin.f'
 90   close(11)
      print *,'pedin, mped = ',mped,nped
c
      return
      end
