C This could be made a great deal more automated, but I figure we are only C going to be doing this once per cluster.... C C First, pick the V "sum" files you want to define the MasterList: C Put them in "allfiles" C Pick one of them as the "MasterList". Run matchxy. This will produce C the file allshifts. C Had to complicte this some so it would deal with the case that C only the smallest mag was good... C Run this program (combine.f): parameter(maxstars=100000) parameter(maxfiles=9) character*80 infile character*120 inline dimension x(maxstars,maxfiles),y(maxstars,maxfiles), & a(maxstars,maxfiles),e(maxstars,maxfiles) dimension istat(maxstars,maxfiles) dimension num(maxfiles) dimension nv(maxstars),xv(maxstars),yv(maxstars),av(maxstars), & ev(maxstars) data hit2/3.0/ C Now read the data in one by one, correcting each by the values in allshifts... do 51 i=1,maxstars nv(i)=0 do 51 j=1,maxfiles istat(i,j)=0 51 continue open(unit=1,file='allshifts') ifile=0 1 read(1,2,end=99) infile 2 format(a80) ifile=ifile+1 if(ifile.gt.maxfiles) stop 'too many files...' do 3 i=1,80 if(infile(i:i).eq.' ') go to 4 3 continue stop 'problem Here' 4 open(unit=2,file=infile(1:i-1),status='old') read(infile(i:80),*) ang,xshift,yshift,ashift write(6,*) ang,xshift,yshift,ashift istar=0 6 read(2,5,end=88) inline 5 format(a120) C eliminate INDEF's... do 80 i=1,115 if(inline(i:i+4).eq.'INDEF') inline(i:i+4)='99.99' 80 continue read(inline,*,err=6) xc,yc,amag,d1,d2,aerr if(amag.eq.99.99) go to 6 istar=istar+1 if(istar.gt.maxstars) stop 'too many stars' x(istar,ifile)=xc*cos(ang)+yc*sin(ang)+xshift y(istar,ifile)=yc*cos(ang)-xc*sin(ang)+yshift a(istar,ifile)=amag+ashift e(istar,ifile)=aerr go to 6 88 close(unit=2) num(ifile)=istar go to 1 99 close(unit=1) write(6,100) ifile,(num(i),i=1,ifile) 100 format((i5)) C OK, now go looking for matches.... nums=0 do 200 ik=1,ifile do 201 i=1,num(ik) if(istat(i,ik).ne.0) go to 201 istat(i,ik)=1 nums=nums+1 if(nums.gt.maxstars) stop 'too many TOTAL stars...' xv(nums)=x(i,ik) yv(nums)=y(i,ik) av(nums)=a(i,ik) ev(nums)=e(i,ik)**2 nv(nums)=1 if(nums.eq.2) write(6,*) x(i,ik),y(i,ik),a(i,ik),e(i,ik) C Now go looking for this star in each additional file....unless it's the last C file... if(ik.eq.ifile) go to 201 do 202 j=ik+1,ifile do 203 k=1,num(j) if(istat(k,j).ne.0) go to 203 C already counted dist2=(x(k,j)-x(i,ik))**2+(y(k,j)-y(i,ik))**2 if(dist2.lt.hit2) then istat(k,j)=1 av(nums)=av(nums)+a(k,j) ev(nums)=ev(nums)+e(k,j)**2 nv(nums)=nv(nums)+1 if(nums.eq.2) write(6,*) x(k,j),y(k,j),a(k,j),e(k,j) go to 202 end if 203 continue 202 continue 201 continue 200 continue do 300 i=1,nums av(i)=av(i)/nv(i) ev(i)=sqrt(ev(i))/nv(i) write(3,301) xv(i),yv(i),av(i),ev(i),nv(i) 301 format(2f8.2,f8.3,f8.3,i5) 300 continue stop end