C   28/02/79 209070859  MEMBER NAME  LGMESG   (SOURCE)      FORTRAN
C
      SUBROUTINE LGMESG(INDPR,INDEX)
C
C     T. KOBAYASHI     26.02.79    11:00
C     MODIFIED ON      07.09.82     8:55   BY S.YAMADA
C
C     THIS IS A SUBROUTINE TO PRINT ERROR MESSAGES ON L-P.
C
C --- INDPR IS GIVEN AN OWN NUMBER CORRESPONDING TO EACH CALLING
C     PROGRAMS.
C        1 = @TESTBOS
C        2 = LGANAL
C        3 = LGDCPY
C        4 = LGCLUS
C        5 = LGAVRZ
C        6 = LGCLPB/LGCLPC
C        7 = LGCDIR
C        8 = ILCTRC
C        9 = LGCHC2
C       10 = LGAVDP
C     INDEX(=1,2,3,---) : INDEX FOR DIFFERENT MESSAGES IN A
C                         CALLING PROGRAM
C
C --- PARAMETERS TO BE PRINTED ARE HANDED VIA COMMON /CLGMSB/.
C --- COMMON /CMSGCT/ IS USED AS ERROR COUNTERS.
C
      IMPLICIT INTEGER *2 (H)
C
#include "cdata.for"
      COMMON /CMSGCT/LGMMAX,LGMSG(20)
      COMMON /CLGMSB/MSGVAL(5)
      DIMENSION AMSGVL(5)
      EQUIVALENCE (MSGVAL(1),AMSGVL(1))
C
      COMMON /CLGPRM/ ITH,MAXCLS,IRLTHD,IRLTH2,IRLTH3,ZVRTX,DZVTX
C
      REAL*8 SUBP(10)
      DATA SUBP/'@MAIN-LG','LGANAL  ','LGDCPY  ','LGCLUS  ',
     @          'LGAVRZ  ','LGCLPB/C','LGCDIR  ','ILCTRC  ',
     @          'LGCHC2  ','LGAVDP  '/
C
      IF(INDPR.LE.0.OR.INDPR.GE.11) RETURN
C
C ----- PRINT ERROR MESSAGE
C
      IF(LGMSG(INDPR).LT.0) RETURN
      LGMSG(INDPR)=LGMSG(INDPR)+1
      IF(LGMSG(INDPR).GT.LGMMAX) RETURN
C
      IF(INDEX.EQ.0) GO TO 100
C
C ----- PRINT EVENT#
C
      DATA INITP/0/
      IF(INITP.GT.0) GO TO 44
      INITP=1
      NPPNHD= IBLN('HEAD')
44    CONTINUE
C      NPPNHD = IBLN('HEAD')
       NHEAD = IDATA(NPPNHD)
       NHEAD = NHEAD+NHEAD
       IF(NHEAD.LE.0) GO TO 900
       IEXP=HDATA(NHEAD+9)
       IRUN=HDATA(NHEAD+10)
       IREC=HDATA(NHEAD+11)
       GO TO 300
CC
  900 WRITE(6,200)
  200 FORMAT(' ***** ERROR IN LGMESG   ''HEAD'' NOT FOUND *****')
      GO TO 100
C
  300 WRITE(6,600) SUBP(INDPR), IEXP, IRUN, IREC
  600 FORMAT('0*****  ERROR IN ',A8,' *****',10X,
     1         'IEXP =',I5,5X,'IRUN =',I5,5X,'IREC =',I5)
C
C
  100 GO TO (1,2,3,4,5,6,7,8,9,10),INDPR
      RETURN
C
    1 GO TO (101,102),INDEX
      GO TO 1000
  101 WRITE(6,110) MSGVAL(1)
  110 FORMAT(' DATA END AT N =',I6)
      GO TO 1000
  102 WRITE(6,120) (MSGVAL(I),I=1,3)
  120 FORMAT(' NPPATR,NPR,NPCL =',3I6)
      GO TO 1000
C
    2 IF( INDEX-2) 201,202,203
  201 WRITE(6,210) ITH,MAXCLS,IRLTHD,IRLTH2,IRLTH3
  210 FORMAT('0***** LG-CLUSTER ANALYSIS PARAMETERS *****'/
     1    ' THRESHOLD OF CLUSTER SEARCH START=',I3/' MAX.CLUSTER#=',
     2     I3/' IRLTHD,IRLTH2,IRLTH3=',3I5)
      GO TO 1000
  202 WRITE(6,220) MSGVAL(1)
  220 FORMAT(' NOT ENOUGH SPACE IN /BCS/ TO PUT "LGCL", IER =',I2)
      GO TO 1000
  203 WRITE(6,230) MSGVAL(1)
  230 FORMAT(' WARNING; "LGCL" EXISTS ALREADY.BUT RECREATED., IER =',I2)
      GO TO 1000
C
    3 IF(INDEX-1) 1000, 301, 302
  301 WRITE(6,310) (MSGVAL(I),I=1,2)
  310 FORMAT(' LGER1 =',I5,5X,'PARM =',I5)
C     DUMP 'ALGN'/1                 <ADDED ON 14-12-81>
      CALL HPRS('ALGN',1)
      GO TO 1000
  302 WRITE(6,320) MSGVAL(1)
  320 FORMAT(' IER IN BCRE=',I3)
      GO TO 1000
C
    4 IF(INDEX-1) 1000,401,1000
  401 WRITE(6,410)
  410 FORMAT(' TOO MANY LG-CLUSTERS')
      GO TO 1000
C
    5 IF(INDEX-1) 1000,501,1000
  501 WRITE(6,510) MSGVAL(1),AMSGVL(2),AMSGVL(3)
  510 FORMAT(' NON-CONVERGENCE FOR DEPAV.  NTRY,DEPO,DEP =',I3,2F10.2)
      GO TO 1000
C
    6 IF(INDEX-1) 1000, 601, 602
  601 WRITE(6,610) (MSGVAL(I),I=1,3)
  610 FORMAT(' LG ENDCAP FORMAT ERROR.  ID,HLGADC(1,',I4,') =',2I5)
      GO TO 1000
  602 WRITE(6,620) AMSGVL(1)
  620 FORMAT(' NEGTV ENERGY BLOCK.W=',E10.3,' (CLEARED TO GET POSTN.)')
      GO TO 1000
C
    7 IF(INDEX-1) 1000, 701, 1000
  701 WRITE(6,710) (MSGVAL(I),I=1,3)
  710 FORMAT(' NPPREC,NPR,NPCL =',3I5)
      GO TO 1000
C
    8 IF(INDEX-2)  801,802,803
  801 WRITE(6,810) (MSGVAL(I),I=1,2)
  810 FORMAT(' BUFFER OVERFLOW.  NCHIND =',I3,'   AT N =',I6)
      GO TO 1000
  802 WRITE(6,820) MSGVAL(1),AMSGVL(2)
  820 FORMAT(' TOO SMALL DIR.COS. AT NTRK=',I3,'  DIRC**2=',E10.3)
      GO TO 1000
  803 WRITE(6,830) MSGVAL(1),(AMSGVL(K),K=2,4)
  830 FORMAT(' TRACK IS OUT OF I.C. AT NTRK=',I3,'  R=',3E10.3,'MM')
      GO TO 1000
C
    9 IF(INDEX-1) 1000,901,1000
  901 WRITE(6,910)
  910 FORMAT(' TOO MANY BLOCKS HIT BY CHARGED TRACKS. HCLADR OVERFLOW')
      GO TO 1000
C
   10 IF(INDEX-1) 1000,1001,1000
 1001 WRITE(6,510) MSGVAL(1),AMSGVL(2),AMSGVL(3)
CC
 1000 RETURN
      END
