Debian Codegraph @

packages/seacas/applications/gjoin/gj_wrgen.f

raw
1 C Copyright(C) 1999-2022 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 WRGEN (A,IA, FILNAM, TITLE, NDIM, NUMNP, NUMEL, NELBLK,
9 & NUMNPS, LNPSNL, NUMESS, LESSEL, LESSDL,
10 & KXN, KYN, KZN, KMAPEL,
11 & KIDELB, KNELB, KNLNK, KNATR, KLINK, KATRIB,
12 & KIDNS, KNNNS, KIXNNS, KLTNNS, KFACNS,
13 & KIDSS, KNESS, KNDSS, KIXESS, KIXDSS, KLTESS, KFACSS,
14 & kltsss, NQAREC, QAREC, NINFO, INFREC, NAMELB, L64BIT, NC4,
15 $ NAMBK, NAMNS, NAMSS, *)
16 C=======================================================================
17
18 C --*** WRGEN *** (GJOIN) Writes the GENESIS database
19 C -- Written by Amy Gilkey - revised 02/22/88
20 C --
21 C --WRGEN writes the GENESIS database.
22 C --
23 C --Parameters:
24 C -- A - IN/OUT - the dynamic memory base array
25 C -- FILNAM - IN - the database filename
26 C -- TITLE - IN - the database title
27 C -- NDIM - IN - the number of coordinates per node
28 C -- NUMNP - IN - the number of nodes
29 C -- NUMEL - IN - the number of elements
30 C -- NELBLK - IN - the number of element blocks
31 C -- NUMNPS - IN - the number of nodal point sets
32 C -- LNPSNL - IN - the length of the nodal point sets node list
33 C -- NUMESS - IN - the number of side sets
34 C -- LESSEL - IN - the length of the element side sets element list
35 C -- LESSNL - IN - the length of the element side sets node list
36 C -- KXN, KYN, KZN - IN - index of XN, YN, ZN; nodal coordinates
37 C -- KMAPEL - IN - index of MAPEL; the element order map
38 C -- KIDELB - IN - index of IDELB; the element block IDs for each block
39 C -- KNELB - IN - index of NUMELB; the number of elements in each block
40 C -- KNLNK - IN - index of NUMLNK; the number of nodes per element
41 C -- in each block
42 C -- KNATR - IN - index of NUMATR; the number of attributes in each block
43 C -- KLINK - IN - index of LINK; the connectivity for each block
44 C -- KATRIB - IN - index of ATRIB; the attributes for each block
45 C ... Nodesets
46 C -- KIDNS - IN - index of IDNPS; the nodal point set ID for each set
47 C -- KNNNS - IN - index of NNNPS; the number of nodes for each set
48 C -- KIXNNS - IN - index of IXNNPS; the index of the first node for each set
49 C -- KLTNNS - IN - index of LTNNPS; the nodes for all sets
50 C -- KFACNS - IN - index of FACNPS; the distribution factors for all sets
51 C .... Sidesets
52 C -- KIDSS - IN - index of IDESS; the element side set ID for each set
53 C -- KNESS - IN - index of NEESS; the number of elements for each set
54 C -- KIXESS - IN - index of IXEESS; the index of the first element
55 C -- for each set
56 C -- KLTESS - IN - index of LTEESS; the elements for all sets
57 C -- KFACSS - IN - index of FACESS; the distribution factors for all sets
58 C -- NAMELB - IN - the names of the element blocks
59 C -- L64BIT - IN - true if use 64-bit integer output database
60
61 include 'exodusII.inc'
62 include 'gj_params.blk'
63 include 'gj_namlen.blk'
64
65 DIMENSION A(*), IA(*)
66 CHARACTER*(*) FILNAM
67 character*(MXLNLN) title
68 character*(MXSTLN) qarec(4,MAXQA)
69 character*(MXLNLN) infrec(MAXINF)
70 character*(MXSTLN) nameco(6), namelb(*)
71 character*(namlen) nambk(*), namns(*), namss(*)
72 LOGICAL l64bit, NC4
73
74 C --QAREC - the QA records
75 C --INFREC - the information records
76 integer cpuws,wsout
77
78 DATA NAMECO /'X', 'Y', 'Z', 'RX', 'RY', 'RZ'/
79
80 C Make netCDF and exodus errors not show up
81
82 call exopts (0,ierr)
83 wsout = iowdsz()
84 write(*,*)'Output word size: ',wsout
85
86 C --Open the database
87 C Create the netcdf file
88
89 CALL SQZSTR(FILNAM, LNAM)
90 LNAM = LENSTR (FILNAM)
91
92 cpuws = 0
93 MODE = EX_CLOBBER
94 if (l64bit) then
95 MODE = MODE + EX_ALL_INT64_DB + EX_ALL_INT64_API
96 end if
97 if (nc4) then
98 MODE = MODE + EX_NETCDF4
99 end if
100 idexo = excre (filnam(:lnam), MODE, cpuws, wsout, ierr)
101 if (ierr .lt. 0) then
102 call exerr('gjoin2', 'Error from excre', exlmsg)
103 go to 150
104 endif
105
106 C -- Set output name length
107 call exmxnm(idexo, namlen, ierr)
108
109 C --Write the QA records
110
111 if (nqarec .gt. 0) then
112 call expqa (idexo, nqarec, qarec, ierr)
113 if (ierr .lt. 0) then
114 call exerr ('gjoin2', 'Error from expqa', exlmsg)
115 goto 150
116 endif
117 endif
118
119 C --Write the info records
120
121 if (ninfo .gt. 0) then
122 call expinf (idexo, ninfo, infrec, ierr)
123 if (ierr .lt. 0) then
124 call exerr ('gjoin2', 'Error from expinf', exlmsg)
125 goto 150
126 endif
127 endif
128
129 lnpsdl = 0
130 if (numnps .gt. 0) then
131 call mdrsrv('NSDF', kansdf, numnps)
132 do 90 i=1, numnps
133 ia(kansdf+i-1) = ia(knnns+i-1)
134 lnpsdl = lnpsdl + ia(kansdf+i-1)
135 90 continue
136 end if
137
138 IDUM = 0
139 CALL DBPINI ('NTIS', idexo, TITLE, NDIM, NUMNP, NUMEL, NELBLK,
140 & NUMNPS, LNPSNL, lnpsdl, NUMESS, LESSEL, LESSDL,
141 & IDUM, IDUM, IDUM, FILNAM(:LNAM))
142
143 C --Write the initial variables
144
145 call expini (idexo, title, ndim, numnp, numel, nelblk, numnps,
146 & numess, ierr)
147 if (ierr .lt. 0) then
148 call exerr ('gjoin2', ' Error from expini', exlmsg)
149 goto 150
150 endif
151
152 C --Write the coordinates
153
154 call expcor (idexo, a(kxn), a(kyn), a(kzn), ierr)
155 if (ierr .lt. 0) then
156 call exerr ('gjoin2', 'Error from expcor', exlmsg)
157 goto 150
158 endif
159
160 call expcon (idexo, nameco, ierr)
161 if (ierr .lt. 0) then
162 call exerr ('gjoin2', 'Error from expcon', exlmsg)
163 goto 150
164 endif
165
166 C --Write out the nodal point sets
167
168 if (numnps .gt. 0) then
169 call expcns (idexo, ia(kidns), ia(knnns), ia(kansdf),
170 & ia(kixnns), ia(kixnns), ia(kltnns),
171 & a(kfacns), ierr)
172 if (ierr .lt. 0) then
173 call exerr ('gjoin2', 'Error from expcns', exlmsg)
174 goto 150
175 endif
176 call mddel('NSDF')
177 call expnams(idexo, 2, numnps, namns, ierr)
178 endif
179
180 C --Write element side sets
181 if (numess .gt. 0) then
182 call expcss (idexo, ia(kidss), ia(kness), ia(kndss),
183 & ia(kixess), ia(kixdss), ia(kltess),
184 & ia(kltsss), a(kfacss), ierr)
185 if (ierr .lt. 0) then
186 call exerr ('gjoin2', 'Error from expcss', exlmsg)
187 goto 150
188 endif
189 call expnams(idexo, 3, numess, namss, ierr)
190 endif
191
192 C --Write the element blocks
193
194 C Write concatenated element block parameters
195 call expclb (idexo, ia(kidelb), namelb,
196 & ia(knelb), ia(knlnk), ia(knatr), .FALSE., ierr)
197 if (ierr .lt. 0) then
198 call exerr('gjoin2', 'Error from expclb', exlmsg)
199 goto 150
200 endif
201
202 ioff = katrib
203 iptr = klink
204 do 100 ielb = 1, nelblk
205
206 C Write block attributes
207
208 if (ia(knatr+ielb-1) .gt. 0) then
209 call expeat (idexo, ia(kidelb+ielb-1), a(ioff), ierr)
210 if (ierr .lt. 0) then
211 call exerr ('gjoin2', 'Error from expeat', exlmsg)
212 goto 150
213 endif
214 endif
215
216 C Write the element block connectivity,
217 C skipping null element blocks
218
219 if (ia(knelb+ielb-1) .eq. 0) then
220 write(*,*)'Null element block: ',ielb
221 else
222 call expelc (idexo, ia(kidelb+ielb-1), ia(iptr), ierr)
223 if (ierr .lt. 0) then
224 call exerr ('gjoin2', 'Error from expelc', exlmsg)
225 goto 150
226 endif
227 endif
228
229 ioff = ioff + ( ia(knatr+ielb-1) * ia(knelb+ielb-1) )
230 iptr = iptr + ( ia(knlnk+ielb-1) * ia(knelb+ielb-1) )
231 100 continue
232 call expnams(idexo, 1, nelblk, nambk, ierr)
233
234 150 call exclos (idexo, ierr)
235
236 RETURN
237 END