	character*60 f1,c*1
	integer ix(9),iy(9)
	real dat(683*683),a(2048,2048)
	data ix/1,684,1366,1,684,1366,1,684,1366/
	data iy/1,1,1,684,684,684,1366,1366,1366/

	if(iargc().lt.2)then
	  write(*,*)
	  write(*,*)'         Usage:  j_writefits1 file n(1-9)'
	  write(*,*)
	  write(*,*)'                          99,2,3'
	  write(*,*)
	  stop
	endif

	call getarg(1,f1)
        call getarg(2,c)

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

	ic=ichar(c)-48
	if(ic.lt.1.or.ic.gt.9)stop ' param.err, 1-9 please'
	jx=ix(ic)
	jy=iy(ic)

	call readfits(f1,a,2048,2048)
	k=0
	do 10 j=jy,jy+682
	do 10 i=jx,jx+682
	k=k+1
10	dat(k)=a(i,j)	

	k=index(f1,'.')
	f1=f1(1:k)//c//'fits'
	k=683*683*4
	open(1,file=f1,status='unknown',access='direct',recl=k)
	write(1,rec=1)dat
	close(1)
	end
