  
         program makent

         character*20 out
         character*8 filename

         out='$Enter PHA-Filename:'
         write(6,2)out
2        format(a)
         read(5,2)filename


         call makentp(filename)

         end


         subroutine makentp(filename)

         integer itime(3), idata(14)
         real rtime(1)
         character*15 ctime(4)
         character*14 cdata(14)
         character*8 filename
         character*30 file
C
         parameter(npawc=500000)
	 common/pawc/hmemo(npawc)
         common/quest/iquest(100) 
C
         common /ntupr/ itime, rtime, idata

         data ctime / 'pb5yr[0,2100]:I', 'pb5day[0,366]:I',
     +                'pb5ms:I', 'min95:R' /
         data cdata /  
     +        'COINC[0,12]:I',  'ASEG[0,5]:I', 'BSEG[0,5]:I', 
     +        'APHA[0,1023]:I', 'ACHN[0,1]:I',
     +        'BPHA[0,1023]:I', 'BCHN[0,1]:I', 
     +        'CPHA[0,1023]:I', 'CCHN[0,1]:I',
     +        'DPHA[0,1023]:I', 'DCHN[0,1]:I',
     +        'EPHA[0,1023]:I', 'ECHN[0,1]:I', 'PRIO[0,1]:I' /

         lin=41
         lout=42
         id=100
         call hlimit(npawc)
         file='platte30:[soho.nt]'//filename//'.ntp' 
         iquest(10)=65000
         call hropen(lout,'NTUPLE',file,'NQ',1024,istat)
         call hbnt(id,'EPHIN PHA L1',' ')
         do i=1,3
           call hbname(id,'ntupr',itime(i), ctime(i))
	 enddo
         call hbname(id,'ntupr',rtime, ctime(4))
	 do i=1,14
           call hbname(id,'ntupr',idata(i), cdata(i))
	 enddo
         file=filename//'.pha'
         open(unit=lin,file=file,form='formatted',type='old',readonly) 
         ik=0
10       read(lin,*,err=20,iostat=ios)itime,rtime,idata
         ik=ik+1

         if ((idata(2).gt.5).or.(idata(3).gt.5)) then
            print*,itime,rtime,idata
         endif
 
         call hfnt(id)
         go to 10
20       call hrout(id,icycle,' ')
	 print*,' PHA:  C entries:  ',ik,'  ios:  ',ios
         call hrend('NTUPLE')
         close (lout)
         close (lin)
         end

