!+ Subroutine to read a blank-delimited substring from a string.
!
! Method:
!	Straightforward.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE READ_WORD(IERR
     &   , STRING, LENGTH
     &   , I_BEGIN, I_END, WORD
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
      CHARACTER
     &     STRING*(*)
!             MAIN STRING
      INTEGER	!, INTENT(IN)
     &     LENGTH
!             LENGTH OF STRING
      INTEGER	!, INTENT(INOUT)
     &     I_BEGIN
!             BEGINNING OF WORD
      CHARACTER	!, INTENT(OUT)
     &     WORD*16
!             WORD READ (RIGHT JUSTIFIED IN FIELD)
      INTEGER	!, INTENT(OUT)
     &     I_END
!             END OF WORD
!
!     LOCAL VARIABLES
      INTEGER
     &     K
!             LOOP VARIABLE
!
!
!     ADVANCE THE BEGINNING OF THE WORD TO A NON-BLANK CHARACTER.
      IF (I_BEGIN.GT.LENGTH) THEN
         WRITE(IU_ERR, '(/A, A)')
     &      '*** ERROR: ATTEMPT TO READ BEYOND END OF STRING'
     &      , STRING
         IERR=I_ERR_FATAL
         RETURN
      ENDIF
!
      DO WHILE ( (STRING(I_BEGIN:I_BEGIN).EQ.' ').AND.
     &           (I_BEGIN.LT.LENGTH) )
         I_BEGIN=I_BEGIN+1
      ENDDO
      I_END=I_BEGIN
      DO WHILE ( (STRING(I_END+1:I_END+1).NE.' ').AND.
     &           (I_END.LT.LENGTH) )
          I_END=I_END+1
      ENDDO
!
!     CHECK LIMITS ON LENGTH OF WORD.
      IF ((I_END-I_BEGIN+1).GT.16) THEN
         WRITE(IU_ERR, '(/A, A)')
     &      '*** ERROR: A SUBSTRING IS TOO LONG IN THE STRING:'
     &      , STRING
         IERR=I_ERR_FATAL
      ENDIF
      DO K=0, I_END-I_BEGIN
         WORD(16-K:16-K)=STRING(I_END-K:I_END-K)
      ENDDO
      DO K=I_END-I_BEGIN+1, 15
         WORD(16-K:16-K)=' '
      ENDDO
!
!
      RETURN
      END
