Debian Codegraph @

packages/seacas/applications/exotxt/et_dbielb.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 SUBROUTINE DBIELB (NDB, OPTION, NELBS, NELBE, IDELB, NUMELB,
9 & NUMLNK, NUMATR, NAMELB, A, IELNK, IEATR, IOERR)
10 C=======================================================================
11
12 C --*** DBIELB *** (EXOLIB) Read database element blocks
13 C -- Written by Amy Gilkey - revised 10/14/87
14 C -- Modified to Read EXODUSIIV2
15 C --
16 C --DBIELB reads the element block information from the database.
17 C --An error message is displayed if the end of file is read.
18 C --
19 C --The dynamic memory arrays LINK and ATRIB must be reserved
20 C --if the connectivity and attributes are to be stored. These arrays
21 C --will be expanded by this routine to hold the new data.
22 C --
23 C --Parameters:
24 C -- NDB - IN - the database file
25 C -- OPTION - IN - ' ' to not store, '*' to store all, else store options:
26 C -- 'I' to store the element block IDs. The element block IDs
27 C -- must be read if the H, C, or A option is selected
28 C -- 'H' to store all header information
29 C -- 'C' to store connectivity (+ NUMLNK + NUMELB)
30 C -- 'A' to store attributes (+ NUMATR + NUMELB)
31 C -- NELBS - IN - the number of the first element block to read
32 C -- NELBE - IN - the number of the last element block to read
33 C -- IDELB - OUT - the element block IDs for each block
34 C -- NUMELB - OUT - the number of elements in each block (if OPTION)
35 C -- NUMLNK - OUT - the number of nodes per element in each block
36 C -- (if OPTION)
37 C -- NUMATR - OUT - the number of attributes in each block (if OPTION)
38 C -- NAMELB - OUT - the type of elements in the each block
39 C -- A - IN/OUT - the dynamic memory base array
40 C -- IELNK - OUT - the size of the connectivity array
41 C -- IEATR - OUT - the size of the attribute array
42 C -- IOERR - OUT - error flag
43 C --
44 C --Reserving the space for the connectivity and attribute
45 C --arrays will be rewritten. MDGET will be used to reserve a
46 C --contiguous space for both the LINK and ATRIB arrays. This
47 C --will speed up the program and reserve the dynamic memory
48 C --in a more efficient manner.
49 C --Element block ID's are always read in this subroutine,
50 C --therefore, do not need to check if option id 'I'
51
52 include 'exodusII.inc'
53
54 INTEGER NDB
55 CHARACTER*(*) OPTION
56 INTEGER NELBS, NELBE
57 INTEGER IDELB(*)
58 INTEGER NUMELB(*)
59 INTEGER NUMLNK(*)
60 INTEGER NUMATR(*)
61 DIMENSION A(1)
62 INTEGER KLINK, KATRIB
63 CHARACTER*(MXSTLN) NAMELB(*)
64 INTEGER IELNK, IEATR
65 INTEGER IOERR
66 LOGICAL ALL, HOPT, COPT, AOPT
67
68 IOERR = 0
69 IELNK = 0
70 IEATR = 0
71
72 C Set option flags
73 ALL = (OPTION .EQ. '*')
74 HOPT = ALL .OR. (INDEX (OPTION, 'H') .GT. 0)
75 COPT = ALL .OR. (INDEX (OPTION, 'C') .GT. 0)
76 AOPT = ALL .OR. (INDEX (OPTION, 'A') .GT. 0)
77 C No need to check if option = 'I' because the element block
78 C IDs are always read in this subroutine. The header, connectivity
79 C and attribute arrays need the element block IDs.
80
81 C Read the element block ID's
82 CALL EXGEBI (NDB, IDELB, IERR)
83
84 IF (ALL .OR. HOPT) THEN
85 DO 100 IELB = NELBS, NELBE
86 C Read element block parameters - returns:
87 C 1. element block ID's
88 C 2. element type in the element block
89 C 3. number of elements in the element block
90 C 4. number of nodes per element in the element block
91 C 5. number of attributes per element in the element block
92 C 6. error id
93 call exgelb(ndb, idelb(ielb), namelb(ielb), numelb(ielb),
94 & numlnk(ielb), numatr(ielb), ierr)
95 call exupcs(namelb(ielb))
96 call pckstr(1, namelb(ielb))
97 100 CONTINUE
98 END IF
99
100 IF (ALL .OR. COPT) THEN
101 C Assumption: space has been reserved for 'LINK'
102 C call MxFIND(array_name, ret_index, array_size)
103 CALL MDFIND ('LINK', KLINK, IELNK)
104 CALL MDSTAT (NERR, MEM)
105 IF (NERR .GT. 0) then
106 CALL MEMERR
107 IOERR = 1
108 RETURN
109 END IF
110 DO 110 IELB = NELBS, NELBE
111 C number of elements in a block
112 NEL = NUMELB(IELB)
113 C number of nodes per element in the element block
114 NLNK = NUMLNK(IELB)
115 ISLNK = IELNK + 1
116 IELNK = IELNK + NLNK * NEL
117 CALL MDLONG ('LINK', KLINK, IELNK)
118 CALL EXGELC(NDB, IDELB(IELB), A(KLINK+ISLNK-1), IERR)
119 110 CONTINUE
120 CALL MDSTAT (NERR, MEM)
121 IF (NERR .GT. 0) then
122 CALL MEMERR
123 IOERR = 1
124 RETURN
125 END IF
126 END IF
127
128 IF (ALL .OR. AOPT) THEN
129 C Assumption: space has been reserved for 'ATRIB'
130 C call MxFIND(array_name, ret_index, array_size)
131 CALL MDFIND ('ATRIB', KATRIB, IEATR)
132 CALL MDSTAT (NERR, MEM)
133 IF (NERR .GT. 0) then
134 CALL MEMERR
135 IOERR = 1
136 RETURN
137 END IF
138 DO 120 IELB = NELBS, NELBE
139 C number of elements in a block
140 NEL = NUMELB(IELB)
141 C number of attributes in this block
142 NATR = NUMATR(IELB)
143 IF (NATR .GT. 0) THEN
144 ISATR = IEATR + 1
145 IEATR = IEATR + NATR * NEL
146 CALL MDLONG ('ATRIB', KATRIB, IEATR)
147 CALL EXGEAT(NDB, IDELB(IELB), A(KATRIB+ISATR-1), IERR)
148 END IF
149 120 CONTINUE
150 CALL MDSTAT (NERR, MEM)
151 IF (NERR .GT. 0) then
152 CALL MEMERR
153 IOERR = 1
154 END IF
155 END IF
156
157 RETURN
158 END