	program txtconvert	!converts multiple .txt files to .grd files for use in Surfer
	implicit none
	integer*4 i,j,N,x,k,p
	integer*4 original(2048,2048),newform(2048,2048)
	character*100 FN,FN2
c
	N = 4	!arbitrary # of Frames
	do k=1,N
		p = k-1
		write(FN,10)p
		write(10,*)FN
		open(10,file = FN,action = 'read')
		do j=1,2048
			read(10,*) (original(i,j),i=1,2048)
		enddo
		print *, FN
		close(10)
c
		newform = original(:,2048:1:-1)
c
		write(FN2,11)p
		write(11,*)FN2
		open(20,file = FN2)
		write(20,15)
		do j = 1,2048
			write(20,23) (newform(i,j),i=1,2048)
		enddo
c		print *, FN2
		close(20)
	enddo
c
 10	format('../dat/Txt_Files/Distortion_',i5.5,'.txt')	!set to read location
 11	format('../dat/Distortion_',i5.5,'.grd')	!set to save destination
 15	format('DSAA'/'2048 2048'/'0 2048'/'0 2048'/'0 2000')
 16	format('DSAA'/'2048 2048'/'0 2048'/'0 2048'/'185 2048')
 23	format(10i6)
	stop
	end
