      SUBROUTINE C2LELL (ELM,ELF,SIDNUM,GEOM,NODEL,KSW,ALFA,UEXT,DT)
      INTEGER SIDNUM, NODEL, KSW
      DOUBLE PRECISION ELM(NODEL,*),ELF(*),GEOM(NODEL,*),ALFA,UEXT,DT 

      DOUBLE PRECISION ZERO, PII2, SQRT2
      PARAMETER (ZERO = 0.D0, PII2 = 2.0D0*3.141592653589793D0)
      PARAMETER (SQRT2 = 1.4142135623731D0)
      INTEGER DIM, DOFNOD, MNODEL, MNQP, MDOFEL
      PARAMETER (DIM = 2, DOFNOD = 1)
      PARAMETER (MNODEL = 16, MNQP = 4, MDOFEL = MNODEL*DOFNOD)
      DOUBLE PRECISION JAC(DIM,DIM)
      DOUBLE PRECISION SFUN(MNODEL), LDER(DIM*MNODEL), XK(DIM)
      DOUBLE PRECISION WG(MNQP), ZETA(MNQP), GG(8)
      DOUBLE PRECISION DETK, AMUL, CXK, GXK, XI, ETA
      INTEGER DOFEL, NQP, I, K
      INTEGER NN(4), NODSID, II, JJ, J, NODEL2
      DOFEL = DOFNOD*NODEL
      NODEL2 = NODEL
      CALL VFILL (DOFEL,ELF,ZERO)
      CALL VFILL (DOFEL*DOFEL,ELM,ZERO)
      CALL GAUSL3 (WG,ZETA,NQP)
      NODSID = 3
      NN(1) = 2*SIDNUM-1
      NN(2) = NN(1) + 1
      NN(3) = NN(2) + 1
      IF (NN(3).GT.NODEL2) NN(3)=1
      DO 10 J=1,DIM
         DO 20 I=1,NODSID
            GG((J-1)*NODSID+I) = GEOM(NN(I),J)
20       CONTINUE
10    CONTINUE
      DO 100 K=1,NQP
         XI   = ZETA(K)
         ETA  = -1.D0
         DETK = 1.D0
         CALL SQUAD8(SFUN,LDER,XI,ETA)
         CALL MXM (SFUN,1,GG,NODSID,XK,DIM)
         CALL MXM (LDER,DIM,GG,NODSID,JAC,DIM)

         CXK=ALFA
         GXK=ALFA*UEXT
         DETK = DETK*SQRT(JAC(1,1)**2+JAC(1,2)**2)
         IF (KSW.EQ.1) THEN
            AMUL = WG(K)*DETK*DT
         ELSE
            AMUL = WG(K)*PII2*XK(1)*DETK*DT
         ENDIF
         DO 30 I=1,NODSID
            II = NN(I)
            DO 40 J=1,NODSID
               JJ = NN(J)
               ELM(II,JJ)=ELM(II,JJ)+AMUL*CXK*SFUN(I)*SFUN(J)
  40        CONTINUE
            ELF(II) = ELF(II) + AMUL*GXK*SFUN(I)
  30     CONTINUE
 100  CONTINUE
      RETURN
      END
