	character*80 f1,f2,f3,head(72)
	real a(2048*2048)
	real b(2048*2048)

	if(iargc().lt.3)then
	  write(*,*)
          write(*,*)'    subfit f1 f2 outfit'
          write(*,*)
	  stop
	endif

	call getarg(1,f1)
	call gethead(f1,head)
	call readata(a,f1)	

	call getarg(2,f2)
	call readata(b,f2)	

	call getarg(3,f3)
	do 10 i=1,2048*2048
10	a(i)=a(i)-b(i)+5000.

	call swap4(a,2048*2048*4)
	k=2048*2048*4+5760
	open(50,file=f3,status='unknown',access='direct',recl=k)
	write(50,rec=1)head,a
	close(50)
	end

        subroutine readata(a,f1)
        integer c(720),a(1)
        character*80 f1,ch*2880
        equivalence (c,ch)
        nn=720         
        open(1,file=f1,status='old',access='direct',recl=nn*4)
        read(1,rec=1)ch
        n1=2048   
        n2=2048
        n=1   
55      k=index(ch,'END          ')
        if(k.eq.0)then
          n=n+1    
          read(1,rec=n)ch
          goto 55  
        endif   
        i=0
        k1=n+1
        k2=n+(n1*n2-1)/nn
        do 60 k=k1,k2
        if(mod(k,200).eq.0)call dispdot()
        read(1,rec=k)ch
        do 60 j=1,nn
        i=i+1
60      a(i)=c(j)
        close (1)
	call swap4(a,n1*n2*4)
        end
 
	subroutine gethead(f1,head)
	character*80 f1,head(72)
	open(52,file=f1,status='old',access='direct',recl=5760)
	read(52,rec=1)head
	close (52)
	end
