1!$Id:$
2      subroutine comelm(id,ix, ir, ndf,nen, kpo,kp,neq,
3     &                  bycol,wdiag,all)
4
5!      * * F E A P * * A Finite Element Analysis Program
6
7!....  Copyright (c) 1984-2017: Regents of the University of California
8!                               All rights reserved
9
10!-----[--.----+----.----+----.-----------------------------------------]
11!      Purpose:  Compute equation numbers from elements
12
13!      Inputs:
14!         id(ndf,*)  -  Active unknowns at each node.
15!         ix(nen1,*) - List of nodes connected to each element
16!         ndf        -  Number of unknowns at each node.
17!         nen        -  Maximum number of nodes on any element
18!         kpo        -  Initial row entry
19!         bycol      -  Storage by columns if true
20!         wdiag      -  Include diagonal if true
21!         all        -  All terms in row/col if true
22
23!      Outputs:
24!         ir(*)      -  Row number of each nonzero in stiffness matrix.
25!         kp         -  Last entry in ir array
26!-----[--.----+----.----+----.-----------------------------------------]
27      implicit  none
28
29      include  'iofile.h'
30
31      logical   addeq, bycol, wdiag, all
32      integer   ndf,nen,kpo,kp,neq, i,l,m, kk,neqj
33      integer   id(ndf,*),ix(*),ir(*)
34
35      save
36
37      do l = 1,nen
38        kk = ix(l)
39        if(kk.gt.0) then
40          do m = 1, ndf
41              neqj = id(m,kk)
42
43!             Check if equation to be added
44
45              if(all) then                           ! all terms
46                addeq   = neqj.gt.0
47              elseif(bycol) then                     ! by columns
48                if(wdiag) then
49                  addeq = neqj.le.neq.and.neqj.gt.0  ! diagonal in
50                else
51                  addeq = neqj.lt.neq.and.neqj.gt.0  ! diagonal out
52                endif
53              else                                   ! by rows
54                if(wdiag) then
55                  addeq = neqj.ge.neq                ! diagonal in
56                else
57                  addeq = neqj.gt.neq                ! diagonal out
58                endif
59              endif
60
61!             Add equation to list
62
63              if(addeq) then
64
65!               Check if equation already in list.
66
67                do i = kpo, kp
68                  if(ir(i).eq.neqj) go to 200
69                end do ! i
70
71!               New equation, add to list
72
73                kp     = kp + 1
74                ir(kp) = neqj
75200             continue
76              endif
77          end do ! m
78        endif
79      end do ! l
80
81      end
82