      SUBROUTINE GETRMS(COORD,NPOINT,NORMAL,RMSDIF)                     GETR001
C-----------------------------------------------------------------------GETR002
C                                                                       GETR003
C  SUBROUTINE GETRMS  Calculate the RMS distance of the atoms from the  GETR004
C                     best-fit plane                                    GETR005
C                                                                       GETR006
C----------------------------------------------------------------------+GETR007
                                                                        GETR008
CHECK v.3.2-->                                                          GETR009
C      SUBROUTINE GETRMS(COORD,NPOINT,CENTRE,NORMAL,RMSDIF)             GETR010
CHECK v.3.2<--                                                          GETR011
                                                                        GETR012
      INTEGER       IPT, NPOINT                                         GETR013
CHECK v.3.2-->                                                          GETR014
C      REAL          CENTRE(3), COORD(3,NPOINT), DOTPRD, NORMAL(3),     GETR015
C     -              RMSDIF, VECTPQ(3)                                  GETR016
      REAL          COORD(3,NPOINT), DOTPRD, NORMAL(3), RMSDIF,         GETR017
     &              VECTPQ(3)                                           GETR018
CHECK v.3.2<--                                                          GETR019
                                                                        GETR020
C---- Initialise values                                                 GETR021
      RMSDIF = 0.0                                                      GETR022
                                                                        GETR023
C---- Loop through all the data points                                  GETR024
      DO 1500, IPT = 1, NPOINT                                          GETR025
                                                                        GETR026
C----     Calculate distance of point from plane                        GETR027
                                                                        GETR028
C----     Form vector between point and an arbitrary point in the plane GETR029
C         (here the CofG is used as the arbitrary point)                GETR030
          VECTPQ(1) = COORD(1,IPT)                                      GETR031
          VECTPQ(2) = COORD(2,IPT)                                      GETR032
          VECTPQ(3) = COORD(3,IPT)                                      GETR033
                                                                        GETR034
C----     Calculate dot product PQ.n                                    GETR035
          DOTPRD = VECTPQ(1) * NORMAL(1) + VECTPQ(2) * NORMAL(2)        GETR036
     &        + VECTPQ(3) * NORMAL(3)                                   GETR037
                                                                        GETR038
C----     Add distance squared to RMS-diff summation                    GETR039
          RMSDIF = RMSDIF + DOTPRD * DOTPRD                             GETR040
1500  CONTINUE                                                          GETR041
                                                                        GETR042
C---- Calculate and print RMS difference                                GETR043
      RMSDIF = SQRT(RMSDIF / REAL(NPOINT))                              GETR044
                                                                        GETR045
      RETURN                                                            GETR046
      END                                                               GETR047
