C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C************************
C**     LDM_ANY_CH     **
C************************
C
CD-Routine: Check for Parameter Value Changes - LDM_ANY_CH
C This routine enables a check to be made on whether and LDM parameter
C values have been changed since the changes monitoring flag was set for
C a particular channel.
CD-end
CD-Fortran:
      LOGICAL FUNCTION LDM_ANY_CH (ICH)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: See if any LDM parameter changes since last rest of parameter value
C          changes flags (16 independent channels allowed)
C
C Author:  John W. Campbell, March 1994
C
C Return:  .TRUE. if any changes found, otherwise .FALSE.
C
C Arguments:
C
      INTEGER ICH
CD-Parameters: 
C ICH   i (R)  Examine flags for this channel (1-16, 0 = all channels)
C
C Return:  .TRUE. if any changes found, otherwise .FALSE.
CD-end
C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      INCLUDE 'ldm_extended.finc'
      EXTERNAL LDM_BDAT
C
C====== FUNCTION TYPES:
C
      INTEGER NBITST
C
C====== LOCALS:
C
      INTEGER I
      INTEGER J
      INTEGER ICHAN
      INTEGER MIN_CH
      INTEGER MAX_CH
      INTEGER ICOEFF
      INTEGER IFLAG
C
C-------------------------------------------------------------------------------
C
C
C====== Set loop parameters
C
      IF (ICH.LT.0.OR.ICH.GT.16) RETURN
      IF (ICH.EQ.0) THEN
         MIN_CH = 0
         MAX_CH = 15
      ELSE
         MIN_CH = ICH - 1
         MAX_CH = ICH - 1
      END IF
      LDM_ANY_CH = .FALSE.
C
C====== Examine flags
C
      DO 100 ICHAN = MIN_CH, MAX_CH
C
C====== Single value parameters
C
          IF (NBITST(CH_CRYST,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_TITLE,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_SYST,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_LATT,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_ROT,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_BEAM,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_IMTYP,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_IMDAT,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_DGEOM,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_AXORD,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDT,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDX1,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDY1,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDX2,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDY2,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDX3,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FIDY3,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_NXRAS,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_NYRAS,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_RAST,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_RMIN,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_RMAX,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_XLOW,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_XHIGH,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_YLOW,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_YHIGH,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_DSTOR,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FTHR,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_FBOX,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_STHR,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_OVPIX,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_NUMP,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_NPLAT,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_TEMPL,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_EPS,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_DTILT,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_N1OD,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_G1OD,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_BASE,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_NONL,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_DSPIN,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_A,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_B,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_C,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_ALPHA,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_BETA,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_GAMMA,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
          IF (NBITST(CH_SYMM,ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
C
C====== Pack parameters
C
         DO 20 I = 1, LDM_MAXPK
             IF (NBITST(CH_SPIN(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_PID(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_KEYP(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_LMIN(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_LMAX(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_DMIN(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_PHIX(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_PHIY(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
             IF (NBITST(CH_PHIZ(I),ICHAN,1).GT.0) LDM_ANY_CH = .TRUE.
20       CONTINUE
C
C====== Plate parameters
C
         DO 40 I = 1, LDM_MAXPK
            DO 30 J = 1, LDM_MAXPL
                IF (NBITST(CH_FNAME(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_XCENF(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_YCENF(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPAC(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_CTOF(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_YSCAL(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPOTL(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPOTW(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPOTF(I,J),ICHAN,1).GT.0)
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPOTB(I,J),ICHAN,1).GT.0)
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPOTD(I,J),ICHAN,1).GT.0)
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_XC(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_YC(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_WC(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_TWIST(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_TILT(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_BULGE(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_ROFF(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_TOFF(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPDXN(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPDYN(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPDXY(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPDXMIN(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPDXMAX(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                DO 28 ICOEFF = 1, LDM_MAXSPD
                   IF (NBITST(CH_SPDX(I,J,ICOEFF),ICHAN,1).GT.0) 
     +                 LDM_ANY_CH = .TRUE.
28              CONTINUE
                IF (NBITST(CH_SPDYMIN(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                IF (NBITST(CH_SPDYMAX(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
                DO 29 ICOEFF = 1, LDM_MAXSPD
                   IF (NBITST(CH_SPDY(I,J,ICOEFF),ICHAN,1).GT.0) 
     +                 LDM_ANY_CH = .TRUE.
29              CONTINUE
                IF (NBITST(CH_RFL(I,J),ICHAN,1).GT.0) 
     +              LDM_ANY_CH = .TRUE.
30          CONTINUE
40       CONTINUE

100   CONTINUE
     
      IF (EXTENDED) THEN
         CALL KDMF_ANY_CH (KDX_EXT, ICH, IFLAG)
         IF (IFLAG.EQ.1) LDM_ANY_CH = .TRUE.
      END IF

      RETURN
      END
