c PIPELINE 2             97,8,22 
c 97,11,20
c 98,7,14
	character*60 f1,c*1

	if(iargc().lt.1)then
	  write(*,*)
	  write(*,*)'         Usage:  pip2 batc_fits_file'
	  write(*,*)
	  write(*,*)'                         2000,1,5'
	  write(*,*)
	  write(*,*)'   to get low_exp.fit *.lst'
	  stop
	endif

	call getarg(1,f1)
	c=' '
	if(iargc().gt.1)then
          call getarg(2,c)
	  if(c.ne.'!')c=' '
	endif

	k=index(f1,'.')
        if(k.eq.0)f1=f1(1:lnblnk(f1))//'.fit'
        inquire(file=f1,exist=i)
        if(i.eq.0)stop ' file not found !'

	k1=index(f1,'.')
	k=k1-1
c 1.
	call system('j_find '//f1(1:k))
c 2.
	call system('j_phot '//f1(1:k))
c 2.1
	call system('j_1to9  '//f1(1:k))

	do 10 i=1,9
	call system('mv '//f1(1:k1)//char(i+48)//'ap '//f1(1:k1)//'ap')
c 3. 
	call system('j_auto9 '//f1(1:k))
c 4.
	call system('mv '//f1(1:k)//'.lst '//f1(1:k)//char(i+48)//'.lst')
10	continue
	call system('j_9to1 '//f1(1:k))
	call system('rm '//f1(1:k)//'?.lst')
	call system('rm *.ap')
	call system('rm *.0ap')
	call system('rm *.coo')
	
	end
