PROGRAM nearres c Looks for residues that are within criterion in one ORTH c file for atoms in a reference ORTH file. CHARACTER*80 filnam CHARACTER*8 res, list(0:999) REAL x(3,400), y(3), dist(999)/999*999./ c First open input files WRITE (6, 1000) 'Enter filename for input ORTH file:' 1000 FORMAT (10a) READ (5, 1000) filnam OPEN (unit=1, form='FORMATTED', status='OLD', file=filnam, 1 readonly) WRITE (6, 1000) 'Enter filename for input reference ORTH file:' READ (5, 1000) filnam OPEN (unit=2, form='FORMATTED', status='OLD', file=filnam, 1 readonly) c Get distance criteria WRITE (6, 1000) 'Enter distance criteria:' READ (5, 1001) crit 1001 FORMAT (3f10.6, 34x, a8) crit = crit*crit c Read header records DO i = 1,3 READ (1, 1000) READ (2, 1000) endDO c Read and store reference coordinates DO n = 1,400 READ (2, 1001, end=9) (x(i,n), i=1,3) endDO 9 num = n-1 c Loop through file nres = 0 DO WHILE (.TRUE.) 10 READ (1, 1001, end=19) y, res DO i = 1,num dd = (x(1,i)-y(1))**2 + (x(2,i)-y(2))**2 + (x(3,i)-y(3))**2 IF (dd .LE. crit) THEN isit = 0 DO n = 1,nres IF (res .EQ. list(n)) THEN isit = n GOTO 11 endIF endDO 11 IF (isit .EQ. 0) THEN nres = nres+1 list(nres) = res n = nres endIF d1 = (x(1,1)-y(1))**2 + (x(2,1)-y(2))**2 + (x(3,1)-y(3))**2 dist(n) = MIN(dist(n),d1) endIF endDO endDO c Write results 19 CLOSE (unit=1) CLOSE (unit=2) WRITE (6, 1002) (list(n), SQRT(dist(n)), n=1,nres) 1002 FORMAT (5(2x, a8, f6.2)) end