PROGRAM corelb c Calculate correlation coefficient of B's with distance from origin REAL*8 s1, s2 REAL rad(10000), bb(10000) c First read information OPEN (unit=1, file='pcd.pdb.A', form='FORMATTED', status='OLD', 1 readonly) n = 1 DO WHILE (.TRUE.) READ (1, 1001, end=9) x, y, z, b 1001 FORMAT (30x, 3f8.3, 6x, f6.2) n = n + 1 rad(n) = SQRT(x*x+y*y+z*z) bb(n) = b endDO 9 CLOSE (unit=1) c Adjust means to zero s1 = 0.0d0 s2 = 0.0d0 DO i = 1,n s1 = s1 + rad(i) s2 = s2 + bb(i) endDO rm = s1/n bm = s2/n DO i = 1,n rad(i) = rad(i) - rm bb(i) = bb(i) - bm endDO c Calculate result s1 = 0.0d0 s2 = 0.0d0 s12 = 0.0d0 DO i = 1,n s1 = s1 + rad(i)**2 s2 = s2 + bb(i)**2 s12 = s12 + rad(i)*bb(i) endDO corr = s12/SQRT(s1*s2) WRITE (6, 1002) corr 1002 FORMAT (f10.4) end