program perpes real,allocatable::x3(:,:),xe(:,:) real per(2),mi(2),ma(2) character*6 xx(2) character*80 fn data xx/'del X ','del Y '/ write(6,*)'Completes 2D PES for Sigmaplot plotting' if(iargc().ne.7)then write(6,*)'Usage: perpes filename ' 1 //' per-x per-y min-x max-x min-y max-y' stop endif call getarg(7,fn) read(fn,*)ma(2) call getarg(6,fn) read(fn,*)mi(2) call getarg(5,fn) read(fn,*)ma(1) call getarg(4,fn) read(fn,*)mi(1) call getarg(3,fn) read(fn,*)per(2) call getarg(2,fn) read(fn,*)per(1) call getarg(1,fn) do 1 ic=1,2 i=0 open(9,file=fn) 2 read(9,*,end=99,err=99)x,y,z i=i+1 if(ic.eq.2)then x3(1,i)=x x3(2,i)=y x3(3,i)=z endif goto 2 99 if(ic.eq.1)allocate(x3(3,i)) 1 close(9) write(6,*)i,' lines in ',fn c x and y=completion: do 6 ic=1,2 call sort(x3,ic,i) call mm(x3,ic,i,del) write(6,60)xx(ic),del 60 format(a6,f12.4) c how many extra points - first cycle count, second assign: do 4 jc=1,2 ie=i do 41 ii=1,i t=x3(ic,ii) 411 t=t+per(ic) if(t.lt.ma(ic))then ie=ie+1 if(jc.eq.2)then xe(ic,ie)=t if(ic.eq.1)then xe(2,ie)=x3(2,ii) else xe(1,ie)=x3(1,ii) endif xe(3,ie)=x3(3,ii) endif goto 411 endif t=x3(ic,ii) 412 t=t-per(ic) if(t.gt.mi(ic))then ie=ie+1 if(jc.eq.2)then xe(ic,ie)=t if(ic.eq.1)then xe(2,ie)=x3(2,ii) else xe(1,ie)=x3(1,ii) endif xe(3,ie)=x3(3,ii) endif goto 412 endif 41 continue if(jc.eq.1)then write(6,*)ie-i,' extra points' if(ic.eq.2)deallocate(xe) allocate(xe(3,ie)) do 5 jj=1,i do 5 k=1,3 5 xe(k,jj)=x3(k,jj) endif 4 continue deallocate(x3) i=ie allocate(x3(3,ie)) do 6 jj=1,ie do 6 k=1,3 6 x3(k,jj)=xe(k,jj) call sort(x3,1,i) call sort(x3,2,i) open(9,file='new.txt') it=0 do 7 ii=1,i if(x3(1,ii).ge.mi(1).and.x3(1,ii).le.ma(1).and. 1 x3(2,ii).ge.mi(2).and.x3(2,ii).le.ma(2))then write(9,90)(x3(k,ii),k=1,3) it=it+1 endif 7 continue 90 format(2f12.4,f14.6) close(9) write(6,*)it,' points within desired range' write(6,*)'new.txt written' end subroutine mm(x,ic,n,del) real x(3,n) tol=0.01 del=x(ic,2)-x(ic,1) do 1 i=2,n-1 d=x(ic,i+1)-x(ic,i) 1 if((d.lt.del.or.del.lt.tol).and.abs(d).gt.tol)del=d return end subroutine sort(x,ic,n) real x(3,n) do 1 i=1,n do 1 j=i+1,n if(x(ic,j).lt.x(ic,i))then do 2 k=1,3 t=x(k,i) x(k,i)=x(k,j) 2 x(k,j)=t endif 1 continue return end