      SUBROUTINE WRIPLN(COORD,NPOINT,EIGVEC,ORDVEC,SRESID,SEQNO,SNAME,  WRIP001
     &    CHAIN,RMSDIF,TCOORD,ATNAME,PDBFIL,PLRES)                      WRIP002
C-----------------------------------------------------------------------WRIP003
C                                                                       WRIP004
C  SUBROUTINE WRIPLN  -  Write out the RMS distance of atoms from the   WRIP005
C                        best-fit plane, and transform so that can      WRIP006
c                        picture looking edge-on to plane               WRIP007
C                                                                       WRIP008
C----------------------------------------------------------------------+WRIP009
                                                                        WRIP010
CHECK v.3.2-->                                                          WRIP011
      INTEGER       NPOINT                                              WRIP012
CHECK v.3.2<--                                                          WRIP013
      CHARACTER*1   CHAIN                                               WRIP014
      CHARACTER*3   ATNAME(NPOINT), SNAME                               WRIP015
      CHARACTER*5   SEQNO                                               WRIP016
      CHARACTER*78  PDBFIL                                              WRIP017
      INTEGER       ICOORD, IPT, IVEC                                   WRIP018
CHECK v.3.2-->                                                          WRIP019
C      INTEGER       ILEN, NPOINT, ORDVEC(3), PLRES, SRESID             WRIP020
      INTEGER       ILEN, ORDVEC(3), PLRES, SRESID                      WRIP021
CHECK v.3.2<--                                                          WRIP022
      REAL          COORD(3,NPOINT), EIGVEC(3,3), RMSDIF,               WRIP023
     &              TCOORD(3,NPOINT)                                    WRIP024
                                                                        WRIP025
C---- Write out the RMS distance                                        WRIP026
      ILEN = INDEX(PDBFIL,' ')                                          WRIP027
      IF (ILEN.GT.40) ILEN = 40                                         WRIP028
      WRITE(2,100) SRESID, CHAIN, SEQNO, SNAME, PLRES, RMSDIF,          WRIP029
     &    PDBFIL(1:ILEN)                                                WRIP030
 100  FORMAT(I6,A1,A5,A3,I2,F9.4,'  PLANE ',A)                          WRIP031
                                                                        WRIP032
C---- Tranform the coordinates to the new axes                          WRIP033
      DO 400, IPT = 1, NPOINT                                           WRIP034
          DO 300, ICOORD = 1, 3                                         WRIP035
                                                                        WRIP036
C----         Calculate eigen vector required (chosen s.t. longest axis WRIP037
C             is along y, middle is in z-direction, and shortest in x)  WRIP038
              IF (ICOORD.EQ.1) IVEC = ORDVEC(3)                         WRIP039
              IF (ICOORD.EQ.2) IVEC = ORDVEC(1)                         WRIP040
              IF (ICOORD.EQ.3) IVEC = ORDVEC(2)                         WRIP041
                                                                        WRIP042
C----         Calculate transformed coordinates                         WRIP043
              TCOORD(ICOORD,IPT)                                        WRIP044
     &            = COORD(1,IPT) * EIGVEC(1,IVEC)                       WRIP045
     &            + COORD(2,IPT) * EIGVEC(2,IVEC)                       WRIP046
     &            + COORD(3,IPT) * EIGVEC(3,IVEC)                       WRIP047
 300      CONTINUE                                                      WRIP048
 400  CONTINUE                                                          WRIP049
                                                                        WRIP050
C---- Write the transformed coordinates out to file                     WRIP051
      DO 600, IPT = 1, NPOINT                                           WRIP052
          WRITE(3,420) PLRES, ATNAME(IPT), SNAME, CHAIN, SEQNO,         WRIP053
     &        (TCOORD(ICOORD,IPT), ICOORD = 1, 3), RMSDIF               WRIP054
 420      FORMAT('ATOM     ',I2,2X,A3,1X,A3,1X,A1,A5,3X,3F8.3,6X,F8.4)  WRIP055
 600  CONTINUE                                                          WRIP056
                                                                        WRIP057
      RETURN                                                            WRIP058
      END                                                               WRIP059
