c all t359i.cat 1.3 i.cat
c all t359n.cati 1.4 n.cat
c all t359o.catin 1.5 o.cat
c all t359e.catino 1.6 e.cat
c all t359g.catinoe 1.7 g.cat
c all t359d.catinoeg 1.8 d.cat
c all t359p.catinoegd 1.9 p.cat
c all t359k.catinoegdp 1.a k.cat
c all t359b.catinoegdpk 1.b b.cat
c all t359m.catinoegdpkb 1.c m.cat
c all t359f.catinoegdpkbm 1.d f.cat
c all t359j.catinoegdpkbmf 1.e j.cat
c all t359c.catinoegdpkbmfj 1.f c.cat
c pick3

	character*60 f0,f1,f2(16)
	character*1  ic
	integer len(16)
	k=iargc()
        if(k.lt.1)then
	  write(*,*)
	  write(*,*)'   Usage: getapcat batch'
	  stop
	endif
	call getarg(1,f0)	
c read filenames
100	open(1,file=f0,status='old')
	i=0
11	i=i+1
	read(1,'(a)',end=10)f2(i)
	goto 11
10	m=i-1
	close(1)
	if(m.eq.2)goto 200
c get filesizes
	do 12 i=1,m
	f1=f2(i)
	k=lnblnk(f1)+1
        f1(k:k)=char(0)
	call filesize(f1,k)
12	len(i)=k
c get max filesize
	k=len(1)
        do 13 i=1,m
	if(len(i).ge.k)then
	  j=i
          k=len(i)
	endif
13	continue
	k=index(f2(j),'.')
	ic=f2(j)(k-1:k-1)
	f1='all '//f2(j)(1:lnblnk(f2(j))+1)//f0(1:lnblnk(f0)+1)//ic//'.cat'
	  write(*,*)f1,ic
	call  system(f1)
	f0='getapcat.tmp '
	f1='ls *'//f2(j)(k:lnblnk(f2(j)))//ic//' >'//f0
	call  system(f1)
	goto 100
200	call system('cat ?.cat >1.tmp')
	call pick3
	end
	
	subroutine pick3
	character*133 dis,err
	byte b(133)
	character*30 f1,f2
	logical logi
	equivalence (dis,b)
	f1='1.tmp'
	f2='getapcat.cat'
	open(1,file=f1,status='old')
	open(2,file=f2,status='unknown')
	kk=0
10	do 9 i=1,133
9	b(i)=32
	read(1,'(a)',end=100)dis
	if(dis(3:3).eq.'c')goto 10
	read(1,'(a)')err
	k=0	
	do 91 i=1,16
	j=36+i*6
91	if(b(j).ne.32)k=k+1
	if(k.ge.3)then
	  if(dis(13:13).eq.'-')dis(13:14)=' -'
	  write(2,'(a)')dis(1:23)
	  kk=kk+1
	endif
	goto 10
100	close(1)
	close(2)
	write(*,*)'all ap_star:',kk
	end
  
