  
         program makent

         character*20 out
         character*8 filename

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

         call makentc(filename)

         end


         subroutine makentc(filename)

         integer itime(3), idata(96), mode
         real rtime(1)
         character*15 ctime(4)
         character*16 cdata(96)
         character*20 epoch
         character*8 filename
         character*40 file
         real*8 repoch
C
         parameter(npawc=500000)
	 common/pawc/hmemo(npawc)
C
         common /ntupr/ itime, rtime, idata
         common /ntupc/ epoch

         data ctime / 'pb5yr[0,2100]:I', 'pb5day[0,366]:I',
     +                'pb5ms:I', 'min95:R' /
         data cdata /  
     +           'G0:I',   'A00:I', 
     +          'A01:I',   'A02:I',
     +          'A03:I',   'A04:I',
     +          'A05:I',   'B00:I',
     +          'B01:I',   'B02:I',
     +          'B03:I',   'B04:I',
     +          'B05:I',    'C0:I',
     +           'D0:I',    'E0:I',
     +           'F0:I',  'P4GM:I',
     +         'P4GR:I',   'P4S:I',
     +         'P8GM:I',  'P8GR:I',
     +          'P8S:I',  'H4GM:I',
     +         'H4GR:I',  'H4S1:I',
     +        'H4S23:I',  'H8GM:I',
     +         'H8GR:I',  'H8S1:I',
     +        'H8S23:I',  'E150:I', 
     +         'E300:I', 'E1300:I',
     +        'E3000:I',   'INT:I',
     +        'P25GM:I', 'P25GR:I',
     +         'P25S:I', 'P41GM:I',
     +        'P41GR:I',  'P41S:I',
     +        'H25GM:I', 'H25GR:I', 
     +        'H25S1:I','H25S23:I',
     +        'H41GM:I', 'H41GR:I',
     +        'H41S1:I','H41S23:I',
     +          'CT0:I',   'CT1:I', 
     +          'CT2:I',   'CT3:I',
     +          'CT4:I',   'CT5:I',
     +        'HBin1:I', 'HBin2:I',
     +        'HBin3:I', 'HBin4:I',
     +        'HBin5:I', 'HBin6:I', 
     +        'HBin7:I', 'HBin8:I',
     +        'HBin9:I','HBin10:I',
     +       'HBin11:I','HBin12:I',
     +       'HBin13:I','HBin14:I',
     +       'HBin15:I','HBin16:I',
     +       'HBin17:I','HBin18:I',
     +       'HBin19:I','HBin20:I',
     +       'HBin21:I','HBin22:I',
     +       'HBin23:I','HBin24:I',
     +       'HBin25:I','HBin26:I',
     +       'HBin27:I','HBin28:I',
     +       'HBin29:I','HBin30:I',
     +       'HBin31:I','HBin32:I', 
     +        'stat1[0,255]:I',   'stat2[0,255]:I',
     +        'stat3[0,255]:I',   'stat4[0,255]:I', 
     +        'stat5[0,255]:I',  'liolen[0,368]:I',
     +      'ephlen[0,2000]:I', 'esulen[0,5756]:I' /

         lin=41 
         lout=42
         id=101
         call hlimit(npawc)
         file='platte30:[soho.nt]'//filename//'.ntc'
         call hropen(lout,'NTUPLE',file,'N',1024,istat)
         call hbnt(id,'EPHIN Counters L1',' ')
         do i=1,3
           call hbname(id,'ntupr',itime(i), ctime(i))
	 enddo
         call hbname(id,'ntupr',rtime, ctime(4))
         call hbnamc(id,'ntupc',epoch, 'epoch:C*20')
	 do i=1,96
           call hbname(id,'ntupr',idata(i), cdata(i))
	 enddo
         file='platte40:[soho.l1.sci]'//filename//'.sci'
         open(unit=lin,file=file,form='formatted',type='old',readonly)  
         ik=0
10       read(lin,*,err=20,iostat=ios)itime,rtime,repoch,idata
         ik=ik+1
         encode(20,12,epoch) repoch
12       format(f18.2) 

         if ((idata(95).gt.0).and.(idata(2).ge.0)) then
           mode=jbit(idata(89),7)+2*jbit(idata(89),8)
         else
           mode=0
         endif
         if (mode.ne.1) then
           print*,itime(1),itime(2),itime(3),'  Mode= ',mode,
     +            '  EphLen=',idata(95)
         endif

         call hfnt(id)
         go to 10
20       call hrout(id,icycle,' ')
	 print*,' CNT:  C entries:  ',ik,'  ios:  ',ios
         call hrend('NTUPLE')
         close (lin) 
         close (lout)
         end


