C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C****************************
C**     LDM_SET_BEAM       **
C****************************
C
C
CD-Doc:
C BEAM_axis        SUBROUTINE LDM_SET_BEAM (VALSTR, IVAL, IERR, ERRSTR)
CD-end
      SUBROUTINE LDM_SET_BEAM (VALSTR, IVAL, IERR, ERRSTR)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Set value of code/integer parameter BEAM_AXIS
C
C Author:  John W. Campbell, June 1993
C
C Arguments:
C
      CHARACTER*(*) VALSTR
      INTEGER IVAL
      INTEGER IERR
      CHARACTER*(*) ERRSTR

C  VALSTR    (R)   Code to be checked and decoded; if blank use IVAL instead
C                  All 3 characters checked (case insensitive) for the
C                  following strings: +a* +b* +c* -a* -b* -c*
C  IVAL      (R)   Value for the parameter (used if VALSTR = ' ') (1,2,3,
C                  -1,-2,-3 for above strings)
C  IERR      (W)   Error flag =0 OK
C                             =1 Invalid code or syntax error in string
C                             =4 Value out of range (other)
C  ERRSTR    (W)   Error description string if error found
C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      INCLUDE 'ldm_lrl.finc'
      EXTERNAL LDM_BDAT
C
C====== LOCALS:
C
      INTEGER I
      INTEGER IAX
      CHARACTER*3 AX_STR(6)
      CHARACTER*3 CODE

C     INTEGER I             !Loop variable
C     INTEGER IAX           !Axis no.
C     CHARACTER*3 AX_STR(6) !Axis code strings
C     CHARACTER*3 CODE      !Code for matching (upper case)
C
      DATA AX_STR /'+A*','+B*','+C*','-A*','-B*','-C*'/
C
C-------------------------------------------------------------------------------
C
      IERR = 0
      ERRSTR = ' '
      IF (VALSTR.NE.' ') THEN
         CODE = VALSTR
         CALL CCPUPC(CODE)
         DO 100 I = 1,6
            IAX = I
            IF (CODE.EQ.AX_STR(I)) GO TO 120
100      CONTINUE
         IERR = 1
         ERRSTR = 
     +   'Invalid code must be +a*, +b*, +c*, -a*, -b* or -c*'
         RETURN
120      BEAM = IAX
         IF (BEAM.GT.3) BEAM = 3 - BEAM
      ELSE
         IF (IABS(IVAL).LT.1.OR.IABS(IVAL).GT.3) THEN
            IERR = 4
            ERRSTR = 'Invalid value - must be 1, 2, 3, -1, -2 or -3'
            RETURN
         END IF
         BEAM = IVAL
      END IF
      IS_BEAM = 1
      CH_BEAM = CH_MASK
      CALL LDM_CLR_GEN (-1, -1, 1)
      RETURN
      END
