- #1
maria4376
- 2
- 0
Hi y'all
I am trying to compare two files, so make one line from one file be compared to alll the lines in the other file until it finds a match where the difference is less than 0.003.
This what I had thought of, but I still think it is just comparing line by line, instead of one line to all the other lines. Any suggestions would be great!
This is what I have so far:
program matchCoords
implicit none
real :: xcoord1, ycoord1,x1,y1,mag1,merr1,sharp1,chi1
real :: xcoord2, ycoord2,x2,y2,mag2,merr2,sharp2,chi2
real, parameter :: arcsec = 0.0003
character (len=50) :: inputfile1, inputfile2, outputfile
integer :: i
!Open input file as unit 15
write(*,*) 'Enter inputfile #1:'
read(*,*) inputfile1
write(*,*) 'Enter inputfile #2'
read(*,*) inputfile2
write(*,*) 'Enter output file name:'
read(*,*) outputfile
open(unit=15, file=inputfile1, status='old')
open(unit=16, file=inputfile2, status='old')
open(unit=17, file=outputfile, status='new')
do i=0,37200
read(16,*) xcoord2, ycoord2,x2,y2,mag2,merr2,sharp2,chi2
do j=0,37000
read(15,*) xcoord1(j), ycoord1(j),x1,y1,mag1,merr1,sharp1,chi1
if(ABS(xcoord1(j)-xcoord2).le.arcsec.and.ABS(ycoord1(i)-ycoor&
&d2).le.arcsec) then
write(17,*) xcoord1(j),ycoord1(j),x1,y1,mag1,merr1,&
&sharp1,chi1,xcoord2,ycoord2,x2,y2,&
&mag2,merr2,sharp2,chi2
I am trying to compare two files, so make one line from one file be compared to alll the lines in the other file until it finds a match where the difference is less than 0.003.
This what I had thought of, but I still think it is just comparing line by line, instead of one line to all the other lines. Any suggestions would be great!
This is what I have so far:
program matchCoords
implicit none
real :: xcoord1, ycoord1,x1,y1,mag1,merr1,sharp1,chi1
real :: xcoord2, ycoord2,x2,y2,mag2,merr2,sharp2,chi2
real, parameter :: arcsec = 0.0003
character (len=50) :: inputfile1, inputfile2, outputfile
integer :: i
!Open input file as unit 15
write(*,*) 'Enter inputfile #1:'
read(*,*) inputfile1
write(*,*) 'Enter inputfile #2'
read(*,*) inputfile2
write(*,*) 'Enter output file name:'
read(*,*) outputfile
open(unit=15, file=inputfile1, status='old')
open(unit=16, file=inputfile2, status='old')
open(unit=17, file=outputfile, status='new')
do i=0,37200
read(16,*) xcoord2, ycoord2,x2,y2,mag2,merr2,sharp2,chi2
do j=0,37000
read(15,*) xcoord1(j), ycoord1(j),x1,y1,mag1,merr1,sharp1,chi1
if(ABS(xcoord1(j)-xcoord2).le.arcsec.and.ABS(ycoord1(i)-ycoor&
&d2).le.arcsec) then
write(17,*) xcoord1(j),ycoord1(j),x1,y1,mag1,merr1,&
&sharp1,chi1,xcoord2,ycoord2,x2,y2,&
&mag2,merr2,sharp2,chi2