
	Program starframe
	Implicit None

	real*4		frame(318,64), q(4), arg, pattern(318,64)
	real*4		x, y, radius
	integer*4	i, j, k, mode, id, jd, ic
	character	outfile*25, infile*50

	    id=318
	    jd=64
	    mode=4
	    ic=2

	    do i=1,id
	    do j=1,jd
	      frame(i,j)=0.0
	      pattern(i,j)=0.0
	    enddo
	    enddo
	    
	    write(infile,'(A50)') '/mnt/big/Orbits/cam2_144/c2frm_2003_144_204015.nic'
	    write(outfile,'(A25)') 'c2frm_2003_144_204015.grd'

	    call read_frame_q(infile,mode,ic,id,jd,frame,q)
	    
	    do i=1,id
	    do j=1,jd
	        arg=frame(i,j)
	        arg = arg/0.75		!Headroom adjustment (may not comply with engineering data and cam3)
		if(i.gt.4.and.i.lt.318)arg=arg-pattern(i,j)*patcorr   !Remove dark current and pattern
		! was still subtracting dark separately as of 4-22-04 (i.e. up to orbit 120 for ic = 1 & 2)
		if(flatcorr(i,j).ne.0.)arg=arg/flatcorr(i,j)	   !Flat Field Correction
		if(frame(i,j).ne.0.)frame(i,j)=arg
	    enddo
	    enddo
	    
	    do i=1,id
	    do j=1,jd
	      x=float(i-75)
	      y=float(j-25)
	      radius=sqrt(x*x+y*y)
	      if(radius.lt.10)then

	      endif
	    enddo
	    enddo
	    
	    frame(76,25)=0.0

	    open (11,file = outfile, form = 'formatted')
	    write(11,11)
11	    format('DSAA'/'318 64'/'0 318'/'0 64'/'0 1400')
	    do j=1,jd
	      write(11,'(20i6)')(nint(frame(i,j)),i=1,id)
	    enddo
	    close(11)
	    
	    End
