      SUBROUTINE REALAN(BTYPE,LINE,DGLIM,VALUE,EVALUE,IMAIN,INCHN,      REAL001
     &            RESNAM,SEQNO,ENDFIL,OTHCHN,OTHNAM,OTHSEQ)             REAL002
C-----------------------------------------------------------------------REAL003
C                                                                       REAL004
C  SUBROUTINE REALAN  -  Read through the .lan file until find the next REAL005
C                        bond length/angle with geometry that is        REAL006
C                        sufficiently distorted to be plotted           REAL007
C                                                                       REAL008
C----------------------------------------------------------------------+REAL009
                                                                        REAL010
CHECK v.3.2-->                                                          REAL011
C     -            RESNAM,SEQNO,ENDFIL)                                 REAL012
CHECK v.3.2<--                                                          REAL013
                                                                        REAL014
      SAVE                                                              REAL015
                                                                        REAL016
      INCLUDE 'bplot.inc'                                               REAL017
                                                                        REAL018
CHECK v.3.2-->                                                          REAL019
C      CHARACTER*1   BTYPE, INCHN                                       REAL020
C      CHARACTER*3   RESNAM                                             REAL021
C      CHARACTER*5   SEQNO                                              REAL022
      CHARACTER*1   BTYPE, INCHN, OTHCHN                                REAL023
      CHARACTER*3   OTHNAM, RESNAM                                      REAL024
      CHARACTER*5   OTHSEQ, SEQNO                                       REAL025
      CHARACTER*20  SPANDT                                              REAL026
CHECK v.3.2<--                                                          REAL027
      CHARACTER*80  IREC                                                REAL028
      INTEGER       IMAIN, IRESID, LINE                                 REAL029
      LOGICAL       ENDFIL                                              REAL030
      REAL          DGLIM, DIFF, EVALUE, VALUE                          REAL031
                                                                        REAL032
C---- Initialise variables                                              REAL033
      VALUE = 0.0                                                       REAL034
                                                                        REAL035
C---- Loop while reading in records                                     REAL036
 100  CONTINUE                                                          REAL037
          READ(2,120,END=500,ERR=900) IREC                              REAL038
 120      FORMAT(A)                                                     REAL039
          LINE = LINE + 1                                               REAL040
                                                                        REAL041
C----     Check that this is not a planar group record                  REAL042
          IF (IREC(29:33).NE.'PLANE') THEN                              REAL043
                                                                        REAL044
C----         Read in the data from the record                          REAL045
              READ(IREC,140,ERR=902) IRESID, INCHN, SEQNO, RESNAM,      REAL046
CHECK v.3.2-->                                                          REAL047
C     -            IMAIN, VALUE                                         REAL048
C 140          FORMAT(I6,A1,A5,A3,I2,F9.4)                              REAL049
     &            IMAIN, VALUE, SPANDT                                  REAL050
 140          FORMAT(I6,A1,A5,A3,I2,F9.4,A20)                           REAL051
                                                                        REAL052
C----         If this bond length/angle spans two residues, then        REAL053
C             extract the appropriate residue names                     REAL054
              IF (SPANDT.NE.' ') THEN                                   REAL055
                  READ(SPANDT,200) INCHN, SEQNO, RESNAM, OTHCHN,        REAL056
     &                OTHSEQ, OTHNAM                                    REAL057
 200              FORMAT(2(1X,A1,A5,A3))                                REAL058
              ELSE                                                      REAL059
                  OTHCHN = ' '                                          REAL060
                  OTHSEQ = ' '                                          REAL061
                  OTHNAM = ' '                                          REAL062
              ENDIF                                                     REAL063
CHECK v.3.2<--                                                          REAL064
                                                                        REAL065
C----         Check that this is a valid length/angle                   REAL066
              IF (IMAIN.GT.0 .AND. IMAIN.LE.NMAIN) THEN                 REAL067
                                                                        REAL068
C----             Check that this is the required type (ie length/angle)REAL069
                  IF (AL(IMAIN).EQ.BTYPE) THEN                          REAL070
                                                                        REAL071
C----                 Calculate difference between value and Engh & HubeREAL072
C                     mean                                              REAL073
                      EVALUE = ENGMEA(IMAIN)                            REAL074
                      DIFF = ABS(VALUE - EVALUE)                        REAL075
                      IF (DIFF.GT.DGLIM) GO TO 999                      REAL076
                  ENDIF                                                 REAL077
              ENDIF                                                     REAL078
          ENDIF                                                         REAL079
                                                                        REAL080
C---- Loop back for next record in file                                 REAL081
      GO TO 100                                                         REAL082
                                                                        REAL083
C---- End of file reached                                               REAL084
 500  CONTINUE                                                          REAL085
      ENDFIL = .TRUE.                                                   REAL086
                                                                        REAL087
      GO TO 999                                                         REAL088
                                                                        REAL089
                                                                        REAL090
C---- Fatal errors                                                      REAL091
 900  CONTINUE                                                          REAL092
      PRINT*, '*** ERROR reading record from .lan file at line',        REAL093
     &    LINE + 1                                                      REAL094
      GO TO 990                                                         REAL095
                                                                        REAL096
 902  CONTINUE                                                          REAL097
      PRINT*, '*** ERROR. Data error in .lan file at line:', LINE       REAL098
      GO TO 990                                                         REAL099
                                                                        REAL100
990   CONTINUE                                                          REAL101
      IFAIL = .TRUE.                                                    REAL102
                                                                        REAL103
999   CONTINUE                                                          REAL104
      RETURN                                                            REAL105
      END                                                               REAL106
