      SUBROUTINE TOTROT(X,Y,Z)
      INCLUDE 'SIZES'
C THIS ROUTINE WILL PERFORM THE ROTATION SPECIFIED IN
C  COMMON /ALLROT/ ABOUT ATOM 1 (AT THE ORIGIN) AND THEN
C  TRANSLATE ATOM 1 TO THE COORDINATES "X,Y,Z"
      IMPLICIT REAL(A-H,O-Z)
      LOGICAL DEBUG, DEBUGL, DEBUGN, DEBUGO, DEBUGP, DEBUGI
      COMMON /DEBCOM/ DEBUG, DEBUGL, DEBUGN, DEBUGO, DEBUGP, DEBUGI
      COMMON /ATOMS/ CO(3, NUMATM),IE( NUMATM),NATOMS, ATCHG( NUMATM)
      COMMON /ALLROT/ ROTPRD(3,3)
C
      IF (DEBUG) THEN
         CALL PLOT(0,0,8)
         WRITE (*,3000) ((ROTPRD(I,J),J=1,3),I=1,3)
3000     FORMAT ( 1X,'TOTROT:',9F7.3)
         DO 1 I=1,4
 1       WRITE (*,3010) I,(CO(J,I),J=1,3)
3010     FORMAT ( 1X, 'TOTROT: CO(*,',I1,')=',3F9.4 )
         CALL PLOT (0,0,9)
      ENDIF
C
      DO 10 IA=1,NATOMS
      COXOLD=CO(1,IA)
      COYOLD=CO(2,IA)
      COZOLD=CO(3,IA)
      CO(1,IA)= ROTPRD(1,1)*COXOLD + ROTPRD(1,2)*COYOLD + 
     .          ROTPRD(1,3)*COZOLD+X
      CO(2,IA)=ROTPRD(2,1)*COXOLD + ROTPRD(2,2)*COYOLD +
     .          ROTPRD(2,3)*COZOLD+Y
   10 CO(3,IA)=ROTPRD(3,1)*COXOLD + ROTPRD(3,2)*COYOLD +
     .          ROTPRD(3,3)*COZOLD+Z
C
      IF (DEBUG) THEN
         DO 2 I=1,4
 2       WRITE (*,3010) I,(CO(J,I),J=1,3)
      ENDIF
C
      RETURN
      END
