C   12/03/84 406181741  MEMBER NAME  SRSUM    (S)           FORTRAN
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C    THIS SUBROUTINES SUMS ALLL ADC DATA IN ARRAY CATAG ONE END OR THE
C    OTHER TO GIVE THE VALUE OF SUM.
C
C JPART - INPUT - SIGN DETERMINES WHICH END TAGGER IS ANALYSED
C                  JPART > 0 = > +Z
C                  JPART < 0 = > -Z
C
C  SUM - OUTPUT - SUM OF ENERGY
C
C RETURN 1 IF SUM IS A CRAZY VALUE
C
C   A.J.FINCH  10/12/92
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
       SUBROUTINE SRSUM(JPART,SUM,*)
C
#include "cgraph.for"
C
#include "cwktag.for"
C
       DATA ICOUNT / 0 /
C
C = == CODE ===
C
C GET THE RELEVANT POINTERS
C
       ISTART = ISTMZ
       IEND   = IENDMZ
       IF ( JPART .GT. 0 ) ISTART = ISTPZ
       IF ( JPART .GT. 0 ) IEND   = IENDPZ
C
C CALCULATE SUM
C
       SUM = 0.0
       DO 10 I = ISTART,IEND
          SUM = SUM + CATAG(I)
 10    CONTINUE
       IF ( (SUM .LT. 50000.0) .AND. (SUM .GE. 0.0) ) RETURN
C
C
C----------------------------------- ERROR MESSAGES -------------------
C
C
       IF ( NDDINN .NE.  0 ) RETURN 1
       IF ( ICOUNT .GE. 10 ) RETURN 1
       WRITE(6,600) SUM
 600   FORMAT(/,' **** WARNING MESSAGE FROM TAGGING ROUTINE  - SRSUM -',
     *        /,'  SUM HAS A CRAZY VALUE  ',E10.2)
       WRITE(6,603)
 603   FORMAT(1X,' LARGE VALUES MAY BE CAUSED BY DIRTY',
     *           ' BEAM CONDITIONS OR EXTREME PEDESTAL FLUCTUATION')
       WRITE(6,602)
 602   FORMAT(1X,' RAW TAGGING ADC BANK -ATAG- WILL BE PRINTED ',/,/)
       CALL HPRS('ATAG',0)
       ICOUNT = ICOUNT + 1
       IF ( ICOUNT .EQ. 10 ) WRITE(6,601)
 601   FORMAT(1X,' * NO MORE ERROR MESSAGES FROM SRSUM WILL BE PRINTED')
       RETURN 1
       END
