1 subroutine refsys(i2,i3,i4,e1,e2,e3,fail)
2 implicit real*8 (a-h,o-z)
4 include 'DIMENSIONS.ZSCOPT'
5 c this subroutine calculates unity vectors of a local reference system
6 c defined by atoms (i2), (i3), and (i4). the x axis is the axis from
7 c atom (i3) to atom (i2), and the xy plane is the plane defined by atoms
8 c (i2), (i3), and (i4). z axis is directed according to the sign of the
9 c vector product (i3)-(i2) and (i3)-(i4). sets fail to .true. if atoms
10 c (i2) and (i3) or (i3) and (i4) coincide or atoms (i2), (i3), and (i4)
11 c form a linear fragment. returns vectors e1, e2, and e3.
13 double precision e1(3),e2(3),e3(3)
14 double precision u(3),z(3)
15 include 'COMMON.IOUNITS'
16 include "COMMON.CHAIN"
17 data coinc /1.0d-13/,align /1.0d-13/
30 if (s1.gt.coinc) goto 2
31 write (iout,1000) i2,i3,i1
34 2 if (s2.gt.coinc) goto 4
35 write(iout,1000) i3,i4,i1
40 v1=z(2)*u(3)-z(3)*u(2)
41 v2=z(3)*u(1)-z(1)*u(3)
42 v3=z(1)*u(2)-z(2)*u(1)
43 anorm=sqrt(v1*v1+v2*v2+v3*v3)
44 if (anorm.gt.align) goto 6
45 write (iout,1010) i2,i3,i4,i1
55 e2(1)=e1(3)*e3(2)-e1(2)*e3(3)
56 e2(2)=e1(1)*e3(3)-e1(3)*e3(1)
57 e2(3)=e1(2)*e3(1)-e1(1)*e3(2)
58 1000 format (/1x,' * * * error - atoms',i4,' and',i4,' coincide.')
59 1010 format (/1x,' * * * error - atoms',2(i4,2h, ),i4,' form a linear')