Debian Codegraph @

packages/seacas/applications/gjoin/gj_rdgen.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 RDGEN (A, IA, C, FIRST, FILNAM,
9 & TITLE, NDIM, NUMNP, NUMEL, NELBLK,
10 & NUMNPS, LNPSNL, NUMESS, LESSEL, LESSDL,
11 & KXN, KYN, KZN, KMAPEL,
12 & KIDELB, KNELB, KNLNK, KNATR, KLINK, KATRIB,
13 & KIDNS, KNNNS, KIXNNS, KLTNNS, KFACNS,
14 & KIDSS, KNESS, KNDSS, KIXESS, KIXDSS, KLTESS, kltsss,
15 & kltsnc, kfacss, NQAREC, QAREC, NINFO, INFREC, KNMLB,
16 $ KNMBK, KNMNS, KNMSS, USESDF, *)
17 C=======================================================================
18
19 C --*** RDGEN *** (GJOIN) Read the GENESIS database
20 C -- Written by Amy Gilkey - revised 12/04/87
21 C --
22 C --RDGEN expands the memory for the GENESIS database then reads the
23 C --database. Note that the memory is reserved (with a length of zero)
24 C --in INIGEN. File may be deleted.
25 C --
26 C --Parameters:
27 C -- A - IN/OUT - the dynamic memory base array
28 C -- FIRST - IN - true iff file is NOT to be deleted
29 C -- FILNAM - IN - the database filename
30 C -- TITLE - OUT - the database title
31 C -- NDIM - OUT - the number of coordinates per node
32 C -- NUMNP - OUT - the number of nodes
33 C -- NUMEL - OUT - the number of elements
34 C -- NELBLK - OUT - the number of element blocks
35 C -- NUMNPS - OUT - the number of nodal point sets
36 C -- LNPSNL - OUT - the length of the nodal point sets node list
37 C -- NUMESS - OUT - the number of side sets
38 C -- LESSEL - OUT - the length of the element side sets element list
39 C -- KXN, KYN, KZN - OUT - index of XN, YN, ZN; nodal coordinates
40 C -- KMAPEL - OUT - index of MAPEL; the element order map
41 C -- KIDELB - OUT - index of IDELB; the element block IDs for each block
42 C -- KNELB - OUT - index of NUMELB; the number of elements in each block
43 C -- KNLNK - OUT - index of NUMLNK; the number of nodes per element
44 C -- in each block
45 C -- KNATR - OUT - index of NUMATR; the number of attributes in each block
46 C -- KLINK - OUT - index of LINK; the connectivity for each block
47 C -- KATRIB - OUT - index of ATRIB; the attributes for each block
48 C -- KIDNS - OUT - index of IDNPS; the nodal point set ID for each set
49 C -- KNNNS - OUT - index of NNNPS; the number of nodes for each set
50 C -- KIXNNS - OUT - index of IXNNPS; the index of the first node
51 C -- for each set
52 C -- KLTNNS - OUT - index of LTNNPS; the nodes for all sets
53 C -- KFACNS - OUT - index of FACNPS; the distribution factors for all sets
54 C ---------sidesets----------
55 C -- KIDSS - OUT - index of IDESS; the element side set ID for each set
56 C -- KNESS - OUT - index of NEESS; the number of elements for each set
57 C -- KNDSS - OUT - index of NDESS; the number of dist-fact for each set
58 C -- KIXESS - OUT - index of IXEESS; the index of the first element
59 C -- for each set
60 C -- KIXDSS - OUT - index of IXDESS; the index of the first dist-fact for each set
61 C -- KLTESS - OUT - index of LTEESS; the elements for all sets
62 C -- KFACSS - OUT - index of FACESS; the distribution factors for all sets
63 C -- kltsss - OUT - index of LTSESS; the sides for all sets
64 C -- kltsnc - OUT - index of LTSSNC; the df count for each element/face in the list
65 C -- NAMELB - OUT - names of the element blocks
66
67 include 'exodusII.inc'
68 include 'gj_params.blk'
69 include 'gj_namlen.blk'
70
71 DIMENSION A(*), IA(*)
72 CHARACTER*1 C(*)
73
74 LOGICAL FIRST, TEMP, USESDF
75
76 CHARACTER*(*) FILNAM
77 character*(MXLNLN) title, tmpstr
78 character*(MXSTLN) qarec(4,MAXQA)
79 character*(MXLNLN) infrec(MAXINF)
80 character*(MXSTLN) blname
81 character*132 errmsg, name
82 C --QAREC - the QA records
83 C --INFREC - the information records
84 CHARACTER*(MXSTLN) CDUMMY
85 CHARACTER*80 TMPFIL
86
87 character*20 stra, strb, strc
88
89 DATA TMPFIL /'%gjoin'/
90 DATA NPART /0/
91
92 C --Initialize
93
94 TITLE = ' '
95 NDIM = 0
96 NUMNP = 0
97 NUMEL = 0
98 NELBLK = 0
99 NUMNPS = 0
100 LNPSNL = 0
101 NUMESS = 0
102 LESSEL = 0
103
104 CALL SQZSTR(FILNAM, LNAM)
105 LNAM = LENSTR (FILNAM)
106 IF (FILNAM .EQ. TMPFIL) THEN
107 TEMP = .TRUE.
108 ELSE
109 TEMP = .FALSE.
110 ENDIF
111
112 C Make netCDF and exodus errors not show up
113
114 call exopts (0, ierr)
115
116 C --Open the netcdf file
117 icpuws = 0
118 iows = 0
119 netid = exopen(filnam(:lnam), EXREAD, icpuws, iows, vers, nerr)
120 if (nerr .lt. 0) then
121 write(errmsg,10) filnam(:lnam), nerr
122 10 format("Could not open exodusII file '",A,"', error = ",i3)
123 call exerr ('gjoin2', errmsg, exlmsg)
124 goto 960
125 endif
126
127 call exinq (netid, EXVERS, idummy, versi, cdummy, nerr)
128 write(*,'(A,F6.3)')
129 & 'This database was created by ExodusII version ', versi
130
131 C --Read global information from the database
132
133 call exgini (netid, title, ndim, numnp, numel,
134 & nelblk, numnps, numess, nerr)
135 if (nerr .lt. 0) then
136 call exerr ('gjoin2', 'Error from exgini', exlmsg)
137 goto 960
138 endif
139
140 C Get the length of the node sets node list
141
142 if (numnps .gt. 0) then
143 call exinq (netid, EXNSNL, lnpsnl, dummy, cdummy, nerr)
144 if (nerr .lt. 0) then
145 call exerr ('gjoin2', 'Error from exqini', exlmsg)
146 goto 960
147 endif
148 else
149 lnpsnl = 0
150 endif
151
152 if (numess .gt. 0) then
153
154 C Get the length of the side sets distribution factor list
155
156 call exinq (netid, EXSSDF, lessdl, dummy, cdummy, nerr)
157 if (nerr .lt. 0) then
158 call exerr ('gjoin2', 'Error from exqini', exlmsg)
159 goto 960
160 endif
161
162 C Get the length of the side sets element list
163
164 call exinq (netid, EXSSEL, lessel, dummy, cdummy, nerr)
165 if (nerr .lt. 0) then
166 call exerr ('gjoin2', 'Error from exqini', exlmsg)
167 goto 960
168 endif
169 else
170 lessel = 0
171 lessdl = 0
172 endif
173
174 IF (.NOT. TEMP) THEN
175 CALL DBPINI ('NTIS', NDB, TITLE, NDIM, NUMNP, NUMEL, NELBLK,
176 & NUMNPS, LNPSNL, lnpsnl, NUMESS, LESSEL,
177 & lessdl, IDUM, IDUM, IDUM, FILNAM(:LNAM))
178 ENDIF
179
180 C --Read the coordinates
181
182 CALL MDFIND ('XN', KXN, LOLD)
183 CALL MDLONG ('XN', KXN, LOLD+NUMNP)
184 CALL MDLONG ('YN', KYN, LOLD+NUMNP)
185 IF (NDIM .GE. 3) CALL MDLONG ('ZN', KZN, LOLD+NUMNP)
186 CALL MDSTAT (NERR, MEM)
187 IF (NERR .GT. 0) GOTO 950
188
189 if (ndim .ge. 3) then
190 call exgcor(netid, a(kxn+lold), a(kyn+lold), a(kzn+lold),
191 & nerr)
192 else
193 call exgcor(netid, a(kxn+lold), a(kyn+lold), dummy, nerr)
194 endif
195 if (nerr .lt. 0) then
196 call exerr ('gjoin2', 'Error from exgcor', exlmsg)
197 goto 960
198 endif
199
200 C --Read the element order map
201 C ... See note in gjoin.f about element map
202 c$$$ CALL MDFIND ('MAPEL', KMAPEL, LOLD)
203 c$$$ CALL MDLONG ('MAPEL', KMAPEL, LOLD+NUMEL)
204 c$$$ CALL MDSTAT (NERR, MEM)
205 c$$$ IF (NERR .GT. 0) GOTO 950
206 c$$$
207 c$$$ call exgmap (netid, a(kmapel+lold), nerr)
208 c$$$ if (nerr .ne. 0) then
209 c$$$ if (nerr .eq. 17) then
210 c$$$
211 c$$$C -- no element order map in the EXODUS II file
212 c$$$C -- create a dummy one
213 c$$$ do 30 i=1,numel
214 c$$$ ia(kmapel+lold+i-1) = i
215 c$$$ 30 continue
216 c$$$ else
217 c$$$ goto 950
218 c$$$ endif
219 c$$$ endif
220
221 C --Read in the element block ID array
222
223 CALL MDFIND ('IDELB', KIDELB, LOLD)
224 LOLDBL = LOLD
225 CALL MDLONG ('IDELB', KIDELB, LOLD+NELBLK)
226 CALL MDSTAT (NERR, MEM)
227 IF (NERR .GT. 0) GOTO 950
228
229 call exgebi (netid, a(kidelb+lold), nerr)
230 if (nerr .lt. 0) then
231 call exerr ('gjoin2', 'Error from exgebi', exlmsg)
232 goto 960
233 endif
234
235 call exmxnm(netid, namlen, ierr)
236
237 C --Read the element blocks
238
239 CALL MDLONG ('NUMELB', KNELB, LOLD+NELBLK)
240 CALL MDLONG ('NUMLNK', KNLNK, LOLD+NELBLK)
241 CALL MDLONG ('NUMATR', KNATR, LOLD+NELBLK)
242 CALL MCLONG ('NAMELB', KNMLB, (LOLD+NELBLK)*MXSTLN)
243 CALL MCLONG ('NAMBK', KNMBK, (LOLD+NELBLK)*namlen)
244 call mdfind ('LINK', klink, loldlk)
245 call mdfind ('ATRIB', katrib, loldat)
246
247 CALL MDSTAT (NERR, MEM)
248 IF (NERR .GT. 0) GOTO 950
249 loldlks = loldlk
250 loldats = loldat
251
252 do 40 ielb = 1, nelblk
253 ioff = lold+ielb-1
254 idelb = ia(kidelb+ioff)
255 call exgelb (netid, idelb, blname, num, numlnk,
256 & numatr, nerr)
257 if (nerr .lt. 0) then
258 call exerr ('gjoin2', 'Error from exgelb', exlmsg)
259 goto 960
260 endif
261
262 C ... Wrapper to deal with character*1 'C' array
263 call cpnam(blname, c(knmlb + mxstln*ioff))
264 ia(knelb+ioff) = num
265 ia(knlnk+ioff) = numlnk
266 ia(knatr+ioff) = numatr
267
268 lnewlk = loldlk+(num*numlnk)
269 loldlk = lnewlk
270
271 lnewat = loldat+(num*numatr)
272 loldat = lnewat
273 40 continue
274
275 call mdlong ('LINK', klink, lnewlk)
276 call mdlong ('ATRIB', katrib, lnewat)
277 call mdstat (nerr, mem)
278 if (nerr .gt. 0) goto 950
279
280 loldlk = loldlks
281 loldat = loldats
282 nel = 0
283 do 50 ielb = 1, nelblk
284 ioff = lold+ielb-1
285 idelb = ia(kidelb+ioff)
286 numlnk = ia(knlnk+ioff)
287 numatr = ia(knatr+ioff)
288 num = ia(knelb+ioff)
289
290 if (numlnk .gt. 0) then
291 lnewlk = loldlk+(num*numlnk)
292 call exgelc (netid, idelb, a(klink+loldlk), nerr)
293 if (nerr .lt. 0) then
294 call exerr ('gjoin2', 'Error from exgelc', exlmsg)
295 goto 960
296 endif
297 loldlk = lnewlk
298 endif
299
300 if (numatr .gt. 0) then
301 lnewat = loldat+(num*numatr)
302 call exgeat (netid, idelb, a(katrib+loldat), nerr)
303 if (nerr .lt. 0) then
304 call exerr ('gjoin2', 'Error from exgeat', exlmsg)
305 goto 960
306 endif
307 loldat = lnewat
308 endif
309 50 continue
310
311 call getnam(NETID, 1, nelblk, C(KNMBK+(lold*namlen)))
312
313 C --Read the node sets
314
315 CALL MDFIND ('IDNPS', KIDNS, LOLD)
316 CALL MDLONG ('IDNPS', KIDNS, LOLD+NUMNPS)
317 CALL MDLONG ('NNNPS', KNNNS, LOLD+NUMNPS)
318 call mdlong ('NDNPS', kndns, numnps) ! Node set df count array
319 CALL MDLONG ('IXNNPS', KIXNNS, LOLD+NUMNPS)
320 call mdlong ('IXDNPS', kixdns, numnps) ! Node set df index array
321 CALL MDFIND ('LTNNPS', KLTNNS, LOLD2)
322 CALL MDLONG ('LTNNPS', KLTNNS, LOLD2+LNPSNL)
323 CALL MDLONG ('FACNPS', KFACNS, LOLD2+LNPSNL)
324 call mdlong ('CFACNP', kcfacn, lnpsnl) ! Compressed df list array
325 if (numnps .gt. 0) then
326 CALL MCLONG ('NAMNS', KNMNS, (LOLD+NUMNPS)*namlen)
327 end if
328 CALL MDSTAT (NERR, MEM)
329 IF (NERR .GT. 0) GOTO 950
330
331 if (numnps .gt. 0) then
332 call exgcns (netid, a(kidns+lold), a(knnns+lold),
333 & a(kndns), a(kixnns+lold), a(kixdns),
334 & a(kltnns+lold2), a(kcfacn), nerr)
335 if (nerr .lt. 0) then
336 call exerr ('gjoin2', 'Error from exgcns', exlmsg)
337 goto 960
338 endif
339 endif
340
341 C Massage node sets distribution factors to include 'gj_1' for node sets
342 C without DFs by walking KNDNS array, checking for 0, and filling where
343 C necessary.
344
345 do 80 i=0, numnps-1
346 if (ia(kndns+i) .eq. 0) then
347 do 60 ii=0, ia(knnns+lold+i)-1
348 a(kfacns+lold2+ia(kixnns+lold+i)-1+ii) = 1.0
349 60 continue
350 else
351 do 70 ii=0, ia(kndns+i)-1
352 a(kfacns+lold2+ia(kixnns+lold+i)-1+ii) =
353 & a(kcfacn+ia(kixdns+i)-1+ii)
354 70 continue
355 endif
356 80 continue
357
358 if (numnps .gt. 0) then
359 call getnam(NETID, 2, numnps, C(KNMNS+(lold*namlen)))
360 end if
361
362 C --Read the side sets
363
364 CALL MDFIND ('IDESS', KIDSS, LOLD)
365 CALL MDLONG ('IDESS', KIDSS, LOLD+NUMESS)
366 CALL MDLONG ('NEESS', KNESS, LOLD+NUMESS)
367 call mdlong ('NDESS', kndss, LOLD+numess) ! number of dist factors array
368 CALL MDLONG ('IXEESS', KIXESS, LOLD+NUMESS)
369 call mdlong ('IXDESS', kixdss, LOLD+numess) ! index into dist factors array
370 CALL MDFIND ('LTEESS', KLTESS, LOLD2)
371 CALL MDLONG ('LTEESS', KLTESS, LOLD2+LESSEL)
372 call mdlong ('LTSESS', kltsss, lold2+lessel) ! side list
373 call mdlong ('LTSSNC', kltsnc, lold2+lessel)
374 call mdfind ('FACESS', KFACSS, LOLD3)
375 call mdlong ('FACESS', kfacss, lold3+lessdl) ! Compressed dist factors list
376 if (numess .gt. 0) then
377 CALL MCLONG ('NAMSS', KNMSS, (LOLD+NUMESS)*namlen)
378 end if
379 CALL MDSTAT (NERR, MEM)
380 IF (NERR .GT. 0) GOTO 950
381
382 if (numess .gt. 0) then
383 call exgcss (netid, a(kidss+lold), a(kness+lold),
384 & a(kndss+lold), a(kixess+lold), a(kixdss+lold),
385 & a(kltess+lold2), a(kltsss+lold2), a(kfacss+lold3), nerr)
386 if (nerr .lt. 0) then
387 call exerr ('gjoin2', 'Error from exgcss', exlmsg)
388 goto 960
389 endif
390
391 call exgcssc(netid, ia(kltsnc+lold2), nerr)
392 if (nerr .lt. 0) then
393 call exerr ('gjoin2', 'Error from exgcssc', exlmsg)
394 goto 960
395 endif
396
397 ioff = 0
398 ntot = 0
399 do 90 iess = 1, numess
400 id = ia(kidss+lold+iess-1)
401 call chksnc(ia(kltsnc+lold2+ioff), ia(kness+lold+iess-1),
402 * ncnt)
403 if (ncnt .ne. ia(kndss+lold+iess-1) .and.
404 * ia(kndss+lold+iess-1) .gt. 0 ) then
405
406 CALL INTSTR (1, 0, ncnt, STRA, LSTRA)
407 CALL INTSTR (1, 0, id, STRC, LSTRC)
408 CALL INTSTR (1, 0, ia(kndss+lold+iess-1), STRB, LSTRB)
409 CALL PRTERR ('ERROR',
410 & 'For sideset ' // STRC(:LSTRC)
411 & // ' the distribution factor count of '
412 $ // STRB(:LSTRB)
413 $ // ' does not match the face node count of '
414 $ // STRA(:LSTRA))
415 stop 'internal dist-factor count error'
416 end if
417 ntot = ntot + ncnt
418 ioff = ioff + ia(kness+lold+iess-1)
419 90 continue
420 if (ntot .ne. lessdl .and. lessdl .gt. 0) then
421 stop 'internal nodecount error'
422 end if
423
424 call getnam(NETID, 3, numess, C(KNMSS+(lold*namlen)))
425 endif
426
427 C --Read the QA and information records
428
429 IF (.NOT. TEMP) THEN
430
431 kqarec = 0
432 call exinq (netid, EXQA, kqarec, r, name, nerr)
433 if (nerr .lt. 0) then
434 call exerr ('gjoin2', 'Error from exinq', exlmsg)
435 goto 960
436 endif
437
438 if (kqarec .gt. 0) then
439 if ((nqarec + kqarec) .le. MAXQA) then
440 call exgqa (netid, qarec(1, nqarec+1), nerr)
441 if (nerr .lt. 0) then
442 call exerr ('gjoin2', 'Error from exgqa', exlmsg)
443 goto 960
444 endif
445 nqarec = nqarec + kqarec
446 endif
447 endif
448
449 kinfo = 0
450 call exinq (netid, EXINFO, kinfo, r, name, nerr)
451 if (nerr .lt. 0) then
452 call exerr ('gjoin2', 'Error from exinq', exlmsg)
453 goto 960
454 endif
455
456 if (kinfo .gt. 0) then
457 if ((ninfo + kinfo) .le. MAXINF) then
458 call exginf (netid, infrec(ninfo+1), nerr)
459 if (nerr .lt. 0) then
460 call exerr ('gjoin2', 'Error from exginf', exlmsg)
461 goto 960
462 endif
463
464 NPART = NPART + 1
465 DO 320 INFO = NINFO+1, (NINFO+KINFO)
466 TMPSTR = INFREC(INFO)
467 WRITE (INFREC(INFO), 310) NPART, TMPSTR(:77)
468 310 FORMAT (I2.2,'/',A)
469 320 CONTINUE
470 ninfo = ninfo + kinfo
471 endif
472 endif
473
474 C Add info block
475
476 IF (NINFO .LT. MAXINF) THEN
477 NINFO = NINFO + 1
478 WRITE (INFREC(NINFO), 310) NPART, FILNAM(:77)
479 ENDIF
480 ENDIF
481
482 IF (FIRST) THEN
483 call exclos (netid, ierr)
484 ELSE
485 IF (FILNAM .NE. TMPFIL) THEN
486 CALL PRTERR ('PROGRAM', 'in RDGEN')
487 ENDIF
488 call exclos (netid, ierr)
489 ENDIF
490
491 RETURN
492
493 950 CONTINUE
494 call memerr(6)
495
496 960 CONTINUE
497 RETURN 1
498 END
499
500 subroutine cpnam(namin, namout)
501 character*32 namin, namout
502 namout = namin
503 return
504 end
505
506 subroutine chksnc(lsnc, len, ncnt)
507 C ... Sum the face counts in 'lsnc' so can check that the sum equals the
508 C df count for this list
509 integer lsnc(len)
510 ncnt = 0
511 do 10 i=1, len
512 ncnt = ncnt + lsnc(i)
513 10 continue
514 return
515 end
516
517 subroutine fixdf(len, df)
518 real df(*)
519 return
520 end
521
522 subroutine getnam(ndb, itype, isiz, names)
523 include 'gj_namlen.blk'
524
525 character*(namlen) names(*)
526
527 call exgnams(ndb, itype, isiz, names, ierr)
528 return
529 end