      subroutine wout

      include 'TThead.f'
c
c  write out solutions 
c
      character*8 tnam(25)
      character*12 sid

      real*8  z,x
      integer ka,ks,kd,mage,nofr,nofp

      open(10,file='Ped04S.d',form='formatted',status='old')

      open(15,file='Agesol.d',form='formatted',status='unknown')

      open(14,file='debv01.d',form='formatted',status='unknown')

c
 30   read(10,1631,end=50)ka,ks,kd,x,z,sid
 1631 format(1x,3i10,1x,d20.12,2x,d20.12,2x,a12)
      if(ka.lt.1)go to 30
      if(ka.gt.nam)go to 30
         nofr=itdr(ka)
         nofp=iprog(ka)
         write(14,3301)sid,nofr,nofp,(sanm(ka,m),m=1,no)
 3301    format(1x,a12,2i7,25f12.4)
      go to 30
 50      close(10)
         close(14)
      tnam(1)='20-24 '
      tnam(2)='25 '
      tnam(3)='26    '
      tnam(4)='27    '
      tnam(5)='28    '
      tnam(6)='29    '
      tnam(7)='30 '
      tnam(8)='31 '
      tnam(9)='32 '
      tnam(10)='33 '
      tnam(11)='34 '
      tnam(12)='35 '
      tnam(13)='36 '
      tnam(14)='37 '
      tnam(15)='38-39'
      tnam(16)='40-41'
      tnam(17)='42-43'
      tnam(18)='44-45'
      tnam(19)='46-47'
      tnam(20)='48-50'
      tnam(21)='51-53'
      tnam(22)='54-56'
      tnam(23)='57-59'
      tnam(24)='60-62'
      tnam(25)='63+ '
      mage=25

      do 61 ias=1,mage
         write(15,2201)tnam(ias),(sage(ias,mb),mb=1,no)
 61   continue
 2201 format(1x,a8,25f12.4)
      close(15)
      
      return
      end
