C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C****************************
C**     LDM_SET_FIDT       **
C****************************
C
C
CD-Doc:
C FIDType          SUBROUTINE LDM_SET_FIDT (VALSTR, IVAL, IERR, ERRSTR)
CD-end
      SUBROUTINE LDM_SET_FIDT (VALSTR, IVAL, IERR, ERRSTR)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Set value of code/integer parameter FIDTYPE
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                  1'st character of code checked 'y' or 'n'
C  IVAL      (R)   Value for the parameter (used if VALSTR = ' ') 0 or 1
C                  0=no, 1=yes
C  IERR      (W)   Error flag =0 OK
C                             =1 Invalid code or syntax error in string
C                             =2 Value must be >=0
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 IT
      CHARACTER*1 TYPE(2)
      CHARACTER*1 CODE

C     INTEGER I              !Loop variable
C     INTEGER IT             !Type code
C     CHARACTER*1 TYPE(2)    !Valid image type strings
C     CHARACTER*1 CODE       !Code for matching (upper case

      DATA TYPE /'N','Y'/
C
C-------------------------------------------------------------------------------
C
      IERR = 0
      ERRSTR = ' '
      IF (VALSTR.NE.' ') THEN
         CODE = VALSTR
         CALL CCPUPC(CODE)
         DO 100 I = 1,2
            IT = I
            IF (CODE.EQ.TYPE(I)) GO TO 120
100      CONTINUE
         IERR = 1
         ERRSTR = 
     +   'Invalid code - must be yes or no'
         RETURN
120      FIDT = IT - 1
      ELSE
         CALL LDM_ERR_I (IVAL, 0, 1, IERR, ERRSTR)
         IF (IERR.NE.0) RETURN
         FIDT = IVAL
      END IF
      IS_FIDT = 1
      CH_FIDT = CH_MASK
      CALL LDM_CLR_GEN (-1, -1, 2)
      RETURN
      END
