C   18/07/79 106101752  MEMBER NAME  ERGTOT   (JADEGS)      FORTRAN
      SUBROUTINE ERGTOT(ECYL,ECAMI,ECAPL)
C
C                                  J.OLSSON 03.07.79
C                                     LAST CHANGE 13.07.79
C            CODE TAKEN FROM SUBROUTINE CAPMRK IN EVDISP
C      ECYL,ECAMI,ECAPL ARE ENERGIES OF MAIN CYLINDER AND ENDCAPS.
C                       THEY ARE RETURNED IN MEV.
C         SUPPOSES THAT ALL SPINNERS ARE REMOVED BY LGCALB
      IMPLICIT INTEGER*2 (H)
C
#include "cdata.for"
      COMMON /CLERGY/ ECYLM,ECYLP
C
      ECYL = 0.
      ECAMI = 0.
      ECAPL = 0.
      ECYLM = 0.
      ECYLP = 0.
      IALGN=IBLN('ALGN')
      IPJ=IDATA(IALGN)
      IF(IPJ.LE.0) GO TO 5018
      NWO=IDATA(IPJ)
      IF(NWO.LE.3) GO TO 5018
      IPJ=2*IPJ + 8
      NWO=IPJ+2*NWO-8
C
      DO 5004 IJK=IPJ,NWO,2
      IAD=HDATA(IJK-1)
      ECYL=ECYL+HDATA(IJK)
      IF(IAD.GT.2687) GO TO 5015
      JADE = IAD - (IAD/32)*32
      IF(JADE.LE.15) ECYLM = ECYLM + HDATA(IJK)
      IF(JADE.GT.15) ECYLP = ECYLP + HDATA(IJK)
      GO TO 5004
5015  IF((IAD-2687).LE.96) ECAMI = ECAMI + HDATA(IJK)
      IF((IAD-2687).GT.96) ECAPL = ECAPL + HDATA(IJK)
5004  CONTINUE
C
      ECYL = ECYL - ECAMI - ECAPL
5018  RETURN
      END
