
      SUBROUTINE gtnen(infile, nenrgy, contxt, status)

      CHARACTER*(*) infile, contxt
      INTEGER nenrgy, status

c Subroutine to read the input ASCII file and find out how
c many lines it has.
c Arguments :
c     infile      c*(*)      i: ASCII filename
c     nenrgy      i          r: Number of lines in the file
c     contxt      c*(*)      r: Error context
c     status      i          r: Status    0 = OK

      REAL rjunk

      INTEGER ierr

      LOGICAL qend

c Open the ASCII file

      OPEN (unit=1, file=infile, status='old', iostat=status)
      contxt = ' Failed to open input ASCII file in GTNEN'
      IF ( status .NE. 0 ) RETURN

c Loop round lines in file till we get to the end

      nenrgy = 0

      READ(1,*,iostat=ierr) rjunk
      IF ( ierr .NE. 0 ) THEN
         qend = .TRUE.
      ELSE
         qend = .FALSE.
      ENDIF

      DO WHILE ( .NOT.qend )

         nenrgy = nenrgy + 1

         READ(1,*,iostat=ierr) rjunk
         IF ( ierr .NE. 0 ) qend = .TRUE.

      ENDDO

      CLOSE(1)

      RETURN
      END

