C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_ERR_R        **
C**************************
C
C
      SUBROUTINE LDM_ERR_R (VALUE, ITYP, VALMIN, VALMAX, ND,
     +                      IERR, ERRSTR)
C
C      INCLUDE 'implicit_none.finc'
C
C Purpose: Check for real value within range and set error flag and
C          error string for LDM 'set' routines.
C
C ***** 'LDM' SERVICE ROUTINE ONLY *****
C
C Author:  John W. Campbell, June 1993
C
C Arguments:
C
      REAL VALUE
      INTEGER ITYP
      REAL VALMIN
      REAL VALMAX
      INTEGER ND
      INTEGER IERR
      CHARACTER*(*) ERRSTR

C VALUE      (R)  The value to be tested
C ITYP       (R)  1 = test value for >=0.0 (ignore VALMIN)
C                 2 = test value for >0.0  (ignore VALMIN)
C                 3 = test value for <=0.0 (ignome VALMAX)
C                 4 = test value for <0.0  (ignore VALMAX)
C                 0 = test value for >VALMIN
C VALMIN     (R)  The minimum value allowed (0.0 = no limit for ityp>2)
C VALMAX     (R)  The maximum value allowed (0.0 if no max.)
C ND         (R)  No. of decimal places for out of range value in error msg.
C IERR       (W)  Error flag 0 = OK
C                            2 = value must be >= 0.0
C                            3 = value must be >0.0
C                            4 = value must be <= 0.0
C                            5 = value must be <0.0
C                            6 = other out of range value
C ERRSTR     (W)  Error string if error (blank if not)
C
C
C====== LOCALS:
C

C
C-------------------------------------------------------------------------------
C
      IERR = 0
      ERRSTR = ' '
      IF (ITYP.EQ.1) THEN
         IF (VALUE.LT.0.0) THEN
            IERR = 2
            ERRSTR = 'Value must be >= zero'
            RETURN
         END IF
      ELSE IF (ITYP.EQ.2) THEN
         IF (VALUE.LE.0.0) THEN
            IERR = 3
            ERRSTR = 'Value must be > zero'
            RETURN
         END IF
      ELSE IF (ITYP.EQ.3) THEN
         IF (VALUE.GT.0.0) THEN
            IERR = 4
            ERRSTR = 'Value must be <= zero'
            RETURN
         END IF
      ELSE IF (ITYP.EQ.4) THEN
         IF (VALUE.GE.0.0) THEN
            IERR = 5
            ERRSTR = 'Value must be < zero'
            RETURN
         END IF
      ELSE
         IF (VALUE.LT.VALMIN) THEN
            IERR = 6
            ERRSTR = 'Value must be >='
            CALL STR_ADDF (ERRSTR, VALMIN, ND, 1)
            RETURN
         END IF
      END IF
      IF (ITYP.LT.3) THEN
         IF (VALMAX.EQ.0.0) RETURN
         IF (VALUE.LE.VALMAX) RETURN
         IERR = 6
         ERRSTR = 'Value must be <='
         CALL STR_ADDF (ERRSTR, VALMAX, ND, 1)
      ELSE
         IF (VALMIN.EQ.0.0) RETURN
         IF (VALUE.GE.VALMIN) RETURN
         IERR = 6
         ERRSTR = 'Value must be >='
         CALL STR_ADDF (ERRSTR, VALMIN, ND, 1)
      END IF
      RETURN
      END
