      SUBROUTINE OPEHTM(FNAME,NEWFIL,IFAIL)                             OPEH001
C-----------------------------------------------------------------------OPEH002
C                                                                       OPEH003
C  SUBROUTINE OPEHTM  -  Open the html file, reading through to the     OPEH004
C                        end if the file already exists                 OPEH005
C                                                                       OPEH006
C----------------------------------------------------------------------+OPEH007
                                                                        OPEH008
      CHARACTER*80   IREC                                               OPEH009
      CHARACTER*(*)  FNAME                                              OPEH010
      LOGICAL        IFAIL, NEWFIL                                      OPEH011
                                                                        OPEH012
C---- Initialise variables                                              OPEH013
      IFAIL = .FALSE.                                                   OPEH014
                                                                        OPEH015
C---- Open the summary file                                             OPEH016
      OPEN(UNIT=15,FILE=FNAME,STATUS='UNKNOWN',ACCESS='SEQUENTIAL',     OPEH017
CVAX     -    CARRIAGECONTROL='LIST',                                   OPEH018
     &    ERR=900)                                                      OPEH019
                                                                        OPEH020
C---- If this is an existing file, then read through all its records    OPEH021
C     until get to the end of file                                      OPEH022
      IF (.NOT.NEWFIL) THEN                                             OPEH023
                                                                        OPEH024
C----     Loop through the file until reach the end                     OPEH025
 100      CONTINUE                                                      OPEH026
             READ(15,110,END=500) IREC                                  OPEH027
 110         FORMAT(A)                                                  OPEH028
          GO TO 100                                                     OPEH029
                                                                        OPEH030
C---- If this is a new file, then write the header records to it        OPEH031
      ELSE                                                              OPEH032
          WRITE(15,120)                                                 OPEH033
 120      FORMAT(/,'<h2>PROCHECK statistics</h2>')                      OPEH034
      ENDIF                                                             OPEH035
                                                                        OPEH036
C---- End of file reached                                               OPEH037
 500  CONTINUE                                                          OPEH038
                                                                        OPEH039
      GO TO 999                                                         OPEH040
                                                                        OPEH041
 900  CONTINUE                                                          OPEH042
      PRINT*, '*** ERROR opening summary file'                          OPEH043
      PRINT*, '* ', FNAME                                               OPEH044
      GO TO 990                                                         OPEH045
                                                                        OPEH046
 990  CONTINUE                                                          OPEH047
      IFAIL = .TRUE.                                                    OPEH048
      GO TO 999                                                         OPEH049
                                                                        OPEH050
 999  CONTINUE                                                          OPEH051
      RETURN                                                            OPEH052
      END                                                               OPEH053
