C   08/11/78 203012152  MEMBER NAME  LGNBCK   (S)           FORTRAN
      SUBROUTINE LGNBCK( HPOS,NNBRO,LST)
C
C     S.YAMADA   26-12-77
C     LAST MODIFICATION   04-11-78  14:45
C     MODIFIED BY S.KOMAMIYA   5-11-79     COPIED FROM LGNBCL
C
C---- FILL THE NEIGHBOUR POSITIONS INTO LIST FOR THE POSITION HPOS.
C
      IMPLICIT INTEGER *2 (H)
      DIMENSION LST(5), HMAPEC(25),HLSTEC(92)
C---- HMAPEC,HLSTEC CONTAIN THE MAP AND THE NEIGHBOUR LIST OF
C     EACH COUNTER FOR THE ENDCAP PART.
C
      DATA HMAPEC/ 1,5,8,11,15,20,25,29,34,39,44,49,53,
     1             57,62,67,70,73,76,78,82,84,87,90,93/
C
      DATA HLSTEC/ 2,5,6,76, 1,6,7, 4,7,8, 3,8,9,25, 1,6,10,11,81,
     1            1,5,2,11,12, 2,3,12,13, 3,4,9,13,14, 4,8,14,15,29,
     2            5,11,16,17,87, 5,6,10,17,18, 6,7,18,20, 7,8,20,22,
     3            8,9,15,22,23, 9,14,23,24,34, 10,17,96, 10,11,16,
     4            11,12,19, 18,20, 12,13,19,21, 20,22, 13,14,21,
     5            14,15,24, 15,23,40/
C
      COMMON/ CLGVRN/ NVRSN(20)
      DATA NVCODE/178110414/
      NVRSN(14) = NVCODE
C
      IPOS = HPOS
      NNBR = 0
      IF(IPOS.GE.2688) GO TO 10
C
C---- THE BARREL PART.
      IZ = IPOS-IPOS/32*32
C
C---- +1 FOR IZ
      IF(IZ.EQ.31) GO TO 1
      NNBR = NNBR+1
      LST(NNBR) = IPOS+1
C---- -1 FOR IZ
    1 IF(IZ.EQ.0) GO TO 2
      NNBR = NNBR+1
      LST(NNBR) = IPOS-1
C
C----  +/-1 FOR PHI
    2 NNBR = NNBR+1
      IF(IPOS-2656) 5,6,6
    5 LST(NNBR) = IPOS+32
      GO TO 7
    6 LST(NNBR) = IPOS-2656
      GO TO 9
C
    7 IF(IPOS-32) 8,9,9
    8 NNBR = NNBR+1
      LST(NNBR) = IPOS+2656
      GO TO 50
    9 NNBR = NNBR+1
      LST(NNBR) = IPOS-32
C
C-- EXTRAPORATION OF THE DIFINITION FOR NEAREST NEIGHBOUR (BY S.K.)
C
C                IZ-1       IZ       IZ+1
C             +-----------------------------+
C     IPHI-1  | IPOS-33 | IPOS-32 | IPOS-31 |
C             +-----------------------------+
C     IPHI    | IPOS-1  |  IPOS   | IPOS+1  |
C             +-----------------------------+
C     IPHI+1  | IPOS+31 | IPOS+32 | IPOS+33 |
C             +-----------------------------+
C
      IPHI=IPOS/32
C-----IPOS-33
   50 IF(IZ.EQ.0) GO TO 51
      IF(IPHI.NE.0) GO TO 52
      NNBR=NNBR+1
      LST(NNBR)=IPOS+2655
      GO TO 51
   52 NNBR=NNBR+1
      LST(NNBR)=IPOS-33
C-----IPOS-31
   51 IF(IZ.EQ.31) GO TO 61
      IF(IPHI.NE.0) GO TO 62
      NNBR=NNBR+1
      LST(NNBR)=IPOS+2657
      GO TO 61
   62 NNBR=NNBR+1
      LST(NNBR)=IPOS-31
C-----IPOS+31
   61 IF(IZ.EQ.0) GO TO 71
      IF(IPHI.NE.83) GO TO 72
      NNBR=NNBR+1
      LST(NNBR)=IPOS-2657
      GO TO 71
   72 NNBR=NNBR+1
      LST(NNBR)=IPOS+31
C-----IPOS+33
   71 IF(IZ.EQ.31) GO TO 100
      IF(IPHI.NE.83) GO TO 82
      NNBR=NNBR+1
      LST(NNBR)=IPOS-2655
      GO TO 100
   82 NNBR=NNBR+1
      LST(NNBR)=IPOS+33
      GO TO 100
C
C---- THE ENDCAP PART
   10 CONTINUE
      ITB = 1
      IPOS = IPOS-2687
      IF(IPOS.LE.96) GO TO 11
C---- BOTTOM
      ITB = 2
      IPOS = IPOS-96
      IF(IPOS.GT.96) GO TO 90
   11 MM = (IPOS-1)/24
      MBASE = 24*MM
      IPTMP = IPOS-MBASE
C---- NEIGHBOUR LIST IS MADE BY LOOKING UP THE TABLE.
C---- THE TABLE IS PREPARED FOR THE 1-ST QUADRUNT,WHICH IS REFERENCED
C     BY IPTMP(MODULOUS 24 OF THE POSITION).
   12 NS = HMAPEC(IPTMP)
      NEXT = HMAPEC(IPTMP+1)
      LNG = NEXT-NS
      NB= NS-1
        DO 13 NN=1,LNG
        LSTNN = HLSTEC(NN+NB)+MBASE
        IF(LSTNN.GT.96) LSTNN = LSTNN-96
        LSTNN = LSTNN+2687
        IF(ITB.EQ.2) LSTNN = LSTNN+96
        LST(NN) = LSTNN
   13   CONTINUE
      NNBRO = LNG
      RETURN
   90 LST(1) = 0
  100 NNBRO = NNBR
      RETURN
      END
