Debian Codegraph @

packages/seacas/applications/algebra/ag_rweval.f

raw
1 C Copyright(C) 1999-2020, 2023, 2024 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 C=======================================================================
7 SUBROUTINE RWEVAL (NDBIN, NDBOUT, A, ia, C, NPTIMS, NUMSTO,
8 & LTMENT, MAXSTK, NWRIT, IOERR, MERR)
9 C=======================================================================
10
11 C --*** RWEVAL *** (ALGEBRA) Read, evaluate, write database
12 C -- Written by Amy Gilkey - revised 07/13/89
13 C -- Modified for EXODUSIIV2 format 8/28/95
14 C --
15 C --RWEVAL writes the output database. It first writes the header
16 C --information, then it processes and writes the time steps.
17 C --
18 C --Parameters:
19 C -- A - IN - the dynamic memory base array int's, reals, logicals
20 C -- C - IN - the dynamic memory base array for characters
21 C -- NPTIMS - IN - the number of selected times
22 C -- NUMSTO - IN - total number of input and output variable storage
23 C -- locations needed, including 1 for time/global
24 C -- variables
25 C -- LTMENT - IN - the length of the time/global variable
26 C -- storage entry
27 C -- MAXSTK - IN - the maximum stack size for any equation
28 C -- NWRIT - OUT - the number of times steps written
29 C -- IOERR - OUT - Input/Output error flag
30 C -- MERR - OUT - memory error flag
31 C --
32 C --Common Variables:
33 C -- Uses QAINFO of /PROGQA/
34 C -- Uses NUMEQN, NUMENT, NAMENT, TYPENT, INXENT, VALENT, VSZENT of /ENT../
35 C -- Sets NUMNPO, NUMELO, NELBO of /DBOUT/
36 C -- Uses ICOBEG, ICOEND of /DBXVAR/
37 C -- Uses NDBIN of /DBASE/
38 C -- Uses TITLEO of /DBTITL/
39 C -- Uses NDIM, NUMNP, NUMEL, NSTEPS of /DBNUMS/
40 C -- Uses ISZOOM of /ZOOM/
41
42 include 'exodusII.inc'
43 include 'ag_namlen.blk'
44 include 'ag_numeqn.blk'
45 include 'ag_progqa.blk'
46 include 'ag_ent.blk'
47 include 'ag_var.blk'
48 include 'ag_dbtitl.blk'
49 include 'ag_dbout.blk'
50 include 'ag_dbxvar.blk'
51 include 'ag_dbnums.blk'
52 include 'ag_dbnumg.blk'
53 include 'ag_dbnumq.blk'
54 include 'ag_zoom.blk'
55 include 'ag_filter.blk'
56 include 'ag_remove.blk'
57 include 'ag_dbws.blk'
58
59 DIMENSION A(1)
60 integer ia(1)
61 CHARACTER*1 C(1)
62 INTEGER NPTIMS
63 INTEGER NUMSTO
64 INTEGER LTMENT
65
66 LOGICAL STEP1, WSTEP1
67 INTEGER MERR
68 INTEGER CERR, NERR
69 LOGICAL MEMBUG
70 DATA MEMBUG /.FALSE./
71
72 IF (MEMBUG) THEN
73 CALL MLIST()
74 END IF
75
76 MERR = 0
77 IOERR = 0
78 NWRIT = 0
79
80 C************************************************************
81 C Reserve Dynamic arrays needed to process information
82 C************************************************************
83 C Cumulative element counts for each element block
84 CALL MDRSRV ('IXELB' , KIXELB, 1+NELBLK)
85 C Cumulative element counts for each output block
86 CALL MDRSRV ('IXELBO', KIXEBO, 1+NELBLK)
87
88 C************************************************************
89 C Find dynamic array indices for element block information
90 C************************************************************
91 C Find element block indices of arrays already reserved
92 CALL MDFIND ('IDELB' , KIDELB, NELBLK)
93 CALL MDFIND ('NUMELB', KNELB, NELBLK)
94 CALL MDFIND ('NUMLNK', KNLNK, NELBLK)
95 CALL MDFIND ('NUMATR', KNATR, NELBLK)
96 CALL MCFIND ('BLKTYP', KNMLB, NELBLK * MXSTLN)
97 CALL MDFIND ('LINK', KLINK, IELNK)
98 CALL MDFIND ('ATRIB', KATRIB, IEATR)
99
100 IF (NSTEPS .GT. 0) THEN
101 CALL MDFIND ('IPTIMS', KPTIMS, NSTEPS)
102 CALL MDFIND ('TIMES', KTIMES, NSTEPS)
103 END IF
104 CALL MDFIND ('VISELB', KVISEB, NELBLK)
105 IF (NVAREL .GT. 0) THEN
106 CALL MDFIND ('ISEVOK', KIEVOK, NELBLK * NVAREL)
107 END IF
108 CALL MCFIND ('NAMECO', KNACOR, namlen*NDIM)
109
110 C Check for errors
111 CALL MDSTAT (NERR, MEM)
112 CALL MCSTAT (CERR, MEM)
113 IF ((NERR .GT. 0) .AND. (CERR .GT. 0)) THEN
114 CALL MEMERR
115 MERR = 1
116 RETURN
117 END IF
118
119 C ****************************************************************
120 C Calculate the zoom mesh, if any
121 C numeql - count number of occurrences of logical in a list
122 C ****************************************************************
123
124 IF ((NUMEQL (.TRUE., NELBLK, A(KVISEB)) .LT. NELBLK)
125 & .OR. ISZOOM .OR. ISFILTER .OR. ISREMOVE) THEN
126 C Read the coordinates (if needed for zoom)
127 IF (ISZOOM) THEN
128 CALL MDRSRV ('XN', KXN, NUMNP)
129 CALL MDRSRV ('YN', KYN, NUMNP)
130 IF (NDIM .GE. 3) THEN
131 CALL MDRSRV ('ZN', KZN, NUMNP)
132 ELSE
133 KZN = 1
134 END IF
135 CALL MDSTAT (NERR, MEM)
136 IF (NERR .GT. 0) THEN
137 CALL MEMERR
138 MERR = 1
139 RETURN
140 END IF
141 C Read the coordinates of the nodes
142 CALL EXGCOR(NDBIN, A(KXN), A(KYN), A(KZN), IERR)
143 ELSE
144 KXN = 1
145 KYN = 1
146 KZN = 1
147 END IF
148
149 C Indices of the zoomed node
150 CALL MDRSRV ('IXNODE', KXNODE, NUMNP)
151 C The zoom mexh index for each node
152 CALL MDRSRV ('NODIX' , KNODIX, NUMNP)
153 C Indices of the zoomed elements
154 CALL MDRSRV ('IXELEM', KXELEM, NUMEL)
155 CALL MDSTAT (NERR, MEM)
156 IF (NERR .GT. 0) THEN
157 CALL MEMERR
158 MERR = 1
159 RETURN
160 END IF
161
162 CALL NUM2IX (NELBLK, A(KNELB), A(KIXELB))
163 C A(KIXELB) - stores a cumulative count of the number of elements
164 C in each element block
165 C A(KIXELB+0)= 0
166 C A(KIXELB+1)= num_elem_blk1
167 C A(KIXELB+2)= num_elem_blk1 + num_elem_blk2
168 C A(KIXELB+3)= num_elem_blk1 + num_elem_blk2 + num_elem_blk3 ...
169 C ZMFIXD finds the nodes within the zoomed coordinates and the elements
170 C within the zoomed mesh (if any nodes are in). The connectivity
171 C array is fixed to point to the renumbered nodes. The number of
172 C element blocks is recalculated.
173 if (isfilter) then
174 C ... Get space to hold the element variable used for filtering...
175 call mdrsrv('ELVAR', KELVAR, numel)
176 CALL MDSTAT (NERR, MEM)
177 IF (NERR .GT. 0) THEN
178 CALL MEMERR
179 MERR = 1
180 RETURN
181 END IF
182
183 C ... Find the step
184 istep = locrea(timflt, nsteps, a(ktimes))
185
186 IEL = 0
187 DO IELB = 1, NELBLK
188 IDEB = iarray(ia(kidelb), ielb)
189 NELEM = iarray(ia(knelb), ielb)
190 IF (i2array(ia(kievok), nelblk, ielb, idxflt) .ne. 0) THEN
191 call exgev(ndbin, istep, idxflt, IDEB, NELEM,
192 * a(kelvar+iel), ierr)
193 ELSE
194 C --Make sure values for undefined elements are zero
195 DO I = IEL, IEL+iarray(ia(knelb), ielb) - 1
196 a(kelvar+i) = 0.0
197 end do
198 END IF
199 IEL = IEL + NELEM
200 end do
201 CALL FILTEL (A(KIXELB), A(KNLNK), A(KLINK), A(KVISEB),
202 * A(KXNODE), A(KIXEBO), A(KXELEM), A(KNODIX),
203 * ia(KIEVOK+(idxflt-1)*nelblk), a(kelvar))
204 call MDDEL('ELVAR')
205 else if (isremove) then
206 CALL MDRSRV ('mapel', kmapel, NUMEL)
207 CALL MDSTAT (NERR, MEM)
208 IF (NERR .GT. 0) THEN
209 CALL MEMERR
210 MERR = 1
211 RETURN
212 END IF
213 call exgenm (ndbin, a(kmapel), ierr)
214 CALL REMEL (A(KIXELB), A(KNLNK), A(KLINK), A(KVISEB),
215 * A(KXNODE), A(KIXEBO), A(KXELEM), A(KNODIX), A(KMAPEL))
216 call mddel('mapel')
217 else
218 CALL ZMFIXD (A(KXN), A(KYN), A(KZN),A(KIXELB),
219 & A(KNLNK), A(KLINK), A(KVISEB), A(KXNODE),
220 & A(KIXEBO), A(KXELEM), A(KNODIX))
221 end if
222 IF ((NUMNPO .EQ. 0) .AND. (NUMELO .EQ. 0) .AND.
223 & (NELBO .EQ. 0)) THEN
224 WRITE(*,500)
225 WRITE(*,500)'ERROR - Output database will not be complete'
226 500 FORMAT(A)
227 IOERR = 1
228 RETURN
229 END IF
230
231 C delete coordinate arrays - no longer needed
232 IF (ISZOOM) THEN
233 CALL MDDEL ('XN')
234 CALL MDDEL ('YN')
235 IF (NDIM .GE. 3) CALL MDDEL ('ZN')
236 END IF
237
238 C Resize the dynamic memory arrays
239 C IXNODE - number of nodes to output - indices of zoomed nodes
240 C IXELEM - number of elements to output - indices of zoomed elements
241 C NUMNPO and NUMELO are computed in ZMFIXD
242 CALL MDLONG ('IXNODE', KXNODE, NUMNPO)
243 CALL MDLONG ('IXELEM', KXELEM, NUMELO)
244 CALL MDSTAT (NERR, MEM)
245 IF (NERR .GT. 0) THEN
246 CALL MEMERR
247 MERR = 1
248 RETURN
249 END IF
250
251 C ****************************************************************
252 C Read and munch the node sets
253 C ****************************************************************
254
255 C output number of node sets
256 NNPSO = NUMNPS
257 C output length of the concatenated node sets node list
258 LNPSNO = LNPSNL
259
260 C IF (num_nodes_in <> num_nodes_out) THEN
261 IF ((NUMNP .NE. NUMNPO).AND. (numnps .gt. 0)) THEN
262 C KIDNS - array containing the node set ID's for each node set
263 CALL MDRSRV ('IDNPS', KIDNS, NUMNPS)
264 C KNNNS - array containing the number of nodes for each node set
265 CALL MDRSRV ('NNNPS', KNNNS, NUMNPS)
266 C KNDNPS - array containing number of dist. fact for each node set
267 CALL MDRSRV ('NDNPS', KNDNPS, NUMNPS)
268 C KIXNNS - array containing indices into the LTNNPS array which
269 C are the location of the 1st nodes for each set
270 CALL MDRSRV ('IXNNPS', KIXNNS, NUMNPS)
271 C KDISNS - array containing indices into the FACNPS array which
272 C are the location of the 1st dist factor for each set
273 CALL MDRSRV ('IXDNPS', KDISNS, NUMNPS)
274 C KLTNNS - Returned array containing the nodes for all node sets
275 C Internal node IDs
276 CALL MDRSRV ('LTNNPS', KLTNNS, LNPSNL)
277 C KFACNS - Returned array containing the distribution factors
278 C for all node sets
279 CALL MDRSRV ('FACNPS', KFACNS, LNPSNL)
280 CALL MDSTAT(NERR,MEM)
281 IF (NERR .GT. 0) THEN
282 CALL MEMERR
283 MERR = 1
284 RETURN
285 END IF
286
287 C if (num_of_node_sets > 0) then
288 IF (numnps .gt. 0) then
289 if (LNPSNL .gt. 0) THEN
290 C Read the concatenated node sets
291 CALL EXGCNS(ndbin, ia(kidns), ia(knnns), ia(kndnps),
292 & ia(kixnns), ia(kdisns), ia(kltnns), a(kfacns),
293 $ ierr)
294
295 C Reserve scratch arrays for subroutine ZMNPS
296 CALL MDRSRV ('NEWIX', KNEWIX, NUMNP)
297 CALL MDRSRV ('IXNPS', KIXNPS, LNPSNO)
298 CALL MDSTAT (NERR, MEM)
299 IF (NERR .GT. 0) THEN
300 CALL MEMERR
301 MERR = 1
302 RETURN
303 END IF
304 C Compress the node set information by renumbering the
305 C nodes and removing deleted nodes
306 CALL ZMNPS (NUMNP, NUMNPO, A(KXNODE), NNPSO, LNPSNO,
307 & IA(KIDNS), IA(KNNNS), IA(KIXNNS), IA(KNDNPS),
308 $ IA(KDISNS), IA(KLTNNS), A(KFACNS), IA(KNEWIX),
309 $ IA(KIXNPS))
310 C Remove scratch arrays
311 CALL MDDEL ('NEWIX')
312 CALL MDDEL ('IXNPS')
313 CALL MDSTAT (NERR, MEM)
314 IF (NERR .GT. 0) THEN
315 CALL MEMERR
316 MERR = 1
317 RETURN
318 END IF
319 ELSE
320 C ... Even though there are no nodes in the node set, we have told the output
321 C database that there are (empty) node sets. We need to read and write
322 C the node set ids
323 CALL EXGNSI (NDBIN, IA(KIDNS), IERR)
324 END IF
325 END IF
326 END IF
327
328 C ****************************************************************
329 C Read and munch the side sets
330 C ****************************************************************
331
332 C Output number of side sets
333 NESSO = NUMESS
334 C Output length of the side set element list
335 LESSEO = LESSEL
336 C Output length of the side set distribution list
337 LESSDO = LESSDF
338
339 C if (num_of_elements <> number of elements to output) then
340 IF ((NUMEL .NE. NUMELO) .AND. (numess .gt. 0)) THEN
341 C Reserve Dynamic arrays needed to process information
342 C IDESS - array containing side set IDS
343 CALL MDRSRV ('IDESS' , KIDSS , NUMESS)
344 C NEESS - array containing the number of sides for each sets
345 CALL MDRSRV ('NEESS' , KNESS , NUMESS)
346 C KNDSS - Returned array containing the number of dist
347 C factors for each set
348 CALL MDRSRV ('NDESS' , KNDSS , NUMESS )
349 C IXEESS - returned array containing the indices into the
350 C LTEESS array which are the locations of the 1st
351 C element of each set
352 CALL MDRSRV ('IXEESS', KIXESS, NUMESS)
353 C IXDESS - Returned array containing the indices into the
354 C FACESS array which are the locations of the 1st
355 C distribution factor for each set.
356 CALL MDRSRV ('IXDESS', KIDESS, NUMESS)
357 C LTEESS - Returned array containing the elements for all side
358 C sets. Internal element IDS are used in this list
359 CALL MDRSRV ('LTEESS', KLTESS, LESSEL)
360 C LTSESS - Returned array containing the sides for all side sets
361 CALL MDRSRV ('LTSESS', KLTSSS, LESSEL)
362 C FACESS - Returned array containing dist factors for all side sets
363 CALL MDRSRV ('FACESS', KFACSS, LESSDF)
364 C LTNNN - array of number of nodes for each side in a side set
365 CALL MDRSRV ('LTNNN', KLTNNN, LESSEL)
366 CALL MDSTAT(NERR, MEM)
367 IF (NERR .GT. 0) THEN
368 CALL MEMERR
369 MERR = 1
370 RETURN
371 END IF
372
373 C if (number_of_side_sets > 0) then
374 IF (numess .gt. 0 .and. lessel .gt. 0) THEN
375 C Read concatenated side sets
376 CAll EXGCSS(NDBIN, A(KIDSS), A(KNESS), A(KNDSS),
377 & A(KIXESS), A(KIDESS), A(KLTESS), A(KLTSSS),
378 & A(KFACSS), IERR)
379
380 CALL EXGCSSC(NDBIN, A(KLTNNN), IERR)
381
382 C Reserve scratch arrays for ZMESS
383 CALL MDRSRV ('NEWIX', KNEWIX, MAX (NUMEL, NUMNP))
384 CALL MDRSRV ('NEWSD', KNEWSD, LESSEL)
385 CALL MDRSRV ('IXESS', KXESS, LESSEL)
386 CALL MDSTAT (NERR, MEM)
387 IF (NERR .GT. 0) THEN
388 CALL MEMERR
389 MERR = 1
390 RETURN
391 END IF
392
393 CALL ZMESS (NUMEL, NUMELO, A(KXELEM),
394 & NUMNP, NUMNPO, A(KXNODE), NESSO, LESSEO, LESSDO,
395 & A(KIDSS), A(KNESS), A(KIXESS), A(KLTESS), A(KLTSSS),
396 & A(KNDSS), A(KLTNNN), A(KFACSS), A(KNEWIX), A(KNEWSD),
397 & A(KXESS))
398
399 C Delete scratch arrays
400 CALL MDDEL ('LTNNN')
401 CALL MDDEL ('IXESS')
402 CALL MDDEL ('NEWSD')
403 CALL MDDEL ('NEWIX')
404 CALL MDSTAT(NERR, MEM)
405 IF (NERR .GT. 0) THEN
406 CALL MEMERR
407 MERR = 1
408 RETURN
409 END IF
410 END IF
411 END IF
412
413 ELSE
414
415 C Initialize the number of output variables
416 numnpo = numnp
417 numelo = numel
418 nelbo = nelblk
419 nnpso = numnps
420 lnpsno = lnpsnl
421 nesso = numess
422 lesseo = lessel
423 lessdo = lessdf
424 KXNODE = 1
425 KXELEM = 1
426 KNODIX = 1
427 END IF
428
429 C ***************************************************************
430 C WRITE TO THE OUTPUT FILE
431 C ***************************************************************
432
433 C ****************************************************************
434 C Write initialization parameters to the EXODUSII database
435 C ****************************************************************
436
437 call expini (ndbout, titleo, ndim, numnpo, numelo, nelbo,
438 & nnpso, nesso, ierr)
439
440 C ****************************************************************
441 C Write the QA and Information records
442 C ****************************************************************
443 C Find dynamic array indices for QA and Information record information
444 call MCFIND ('QAREC', kqarec, 4*(MXSTLN)*(nqarec+1))
445 call MCFIND ('INFREC', kinfo, (MXLNLN)*ninfo)
446
447 CALL DBOQA(NDBOUT, QAINFO, NQAREC, C(KQAREC),
448 * NINFO, C(KINFO))
449 C Delete unused dynamic memrory
450 CALL MCDEL ('QAREC')
451 CALL MCDEL ('INFREC')
452
453 C ****************************************************************
454 C Write element block information to the database
455 C including element block connectivity and attributed
456 C ****************************************************************
457
458 CALL WELB (NDBOUT, NELBLK, A(KVISEB),
459 & (NUMEL .EQ. NUMELO), C(KNMLB), A(KNLNK), A(KNATR),
460 & A(KLINK), A(KATRIB), A(KNELB), A(KIXELB), A(KIXEBO),
461 & A(KXELEM),(NUMNP .NE. NUMNPO), A(KNODIX),
462 & A(KIDELB), A, IA, C, MERR)
463
464 IF (NUMNP .NE. NUMNPO) CALL MDDEL ('NODIX')
465 CALL MDDEL ('LINK')
466 CALL MDDEL ('ATRIB')
467 CALL MDDEL ('NUMLNK')
468 CALL MDDEL ('NUMATR')
469
470 C ****************************************************************
471 C Write the database names
472 C ****************************************************************
473
474 C Write the element block variable truth table
475 C Reserve scratch arrays for writing truth table
476 if ((nelbo .gt. 0) .and. (nelblk .ne. nelbo)) then
477 CALL MDRSRV ('XEVOK', KEVOK, NELBO*NVAREO)
478 CALL MDRSRV ('NEWID', KNEWID, NELBO)
479 else
480 CALL MDRSRV ('XEVOK', KEVOK, NELBLK*NVAREO)
481 CALL MDRSRV ('NEWID', KNEWID, NELBLK)
482 end if
483 CALL MDSTAT(NERR, MEM)
484 CALL MCSTAT(CERR, MEM)
485 IF ((NERR .GT. 0) .OR. (CERR .GT. 0)) THEN
486 CALL MEMERR
487 MERR = 1
488 RETURN
489 END IF
490
491 CALL WNAM (NDBOUT ,NDIM, NELBLK, NELBO, A(KVISEB),
492 & NVARGO, NVARNO, NVAREO, C(KNACOR), C(KNMLB),
493 & NAMVAR(JGVBEG), NAMVAR(JNVBEG), NAMVAR(JEVBEG),
494 & IEVVAR(JEVBEG), A(KIEVOK), A(KIDELB), A(KNEWID),
495 & A(KEVOK))
496
497 CALL MDDEL ('XEVOK')
498 CALL MDDEL ('NEWID')
499 CALL MDSTAT (NERR, MEM)
500 IF (NERR .GT. 0)THEN
501 CALL MEMERR
502 MERR = 1
503 RETURN
504 END IF
505
506 C ****************************************************************
507 C Read and write the node sets and the side sets
508 C ****************************************************************
509
510 C ****************************************************************
511 C If number of nodes = number of nodes to output or
512 C If have not read concatenated nodes sets, read now
513 C ****************************************************************
514 IF (NUMNP .EQ. NUMNPO) THEN
515 C if (number of node sets > 0) then
516 IF (numnps .gt. 0) THEN
517 C KIDNS - array containing the node set ID's for each node set
518 CALL MDRSRV ('IDNPS', KIDNS, NUMNPS)
519 C KNNNS - array containing the number of nodes for each node set
520 CALL MDRSRV ('NNNPS', KNNNS, NUMNPS)
521 C KNDNPS - array containing number of dist. fact for each node set
522 CALL MDRSRV ('NDNPS',KNDNPS, NUMNPS)
523 C KIXNNS - array containing indices into the LTNNPS array which
524 C are the location of the 1st nodes for each set
525 CALL MDRSRV ('IXNNPS', KIXNNS, NUMNPS)
526 C KDISNS - array containing indices into the FACNPS array which
527 C are the location of the 1st dist factor for each set
528 CALL MDRSRV ('IXDNPS', KDISNS, NUMNPS)
529 C KLTNNS - Returned array containing the nodes for all node sets
530 C Internal node IDs
531 CALL MDRSRV ('LTNNPS', KLTNNS, LNPSNL)
532 C KFACNS - Returned array containing the distribution factors
533 C for all node sets
534 CALL MDRSRV ('FACNPS', KFACNS, LNPSNL)
535 CALL MDSTAT (NERR, MEM)
536 IF (NERR .GT. 0) THEN
537 CALL MEMERR
538 MERR = 1
539 RETURN
540 END IF
541
542 CALL EXGCNS(ndbin, ia(kidns), ia(knnns), ia(kndnps),
543 & ia(kixnns), ia(kdisns), ia(kltnns), a(kfacns), ierr)
544 END IF
545 END IF
546 C Write the node set information
547 if ((numnps .gt. 0) .AND. (nnpso .gt. 0)) then
548 CALL EXPCNS(ndbout, ia(kidns), ia(knnns), ia(kndnps),
549 & ia(kixnns), ia(kdisns), ia(kltnns), a(kfacns), ierr)
550
551 C Delete unneeded dynamic memory
552 CALL MDDEL ('IDNPS')
553 CALL MDDEL ('NNNPS')
554 CALL MDDEL ('NDNPS')
555 CALL MDDEL ('IXNNPS')
556 CALL MDDEL ('IXDNPS')
557 CALL MDDEL ('LTNNPS')
558 CALL MDDEL ('FACNPS')
559 CALL MDSTAT (NERR, MEM)
560 IF (NERR .GT. 0) THEN
561 CALL MEMERR
562 MERR = 1
563 RETURN
564 END IF
565 end if
566
567 C ****************************************************************
568 C If number of elements = number of elements to output or
569 C If have not read the concatenated side set information yet
570 C ****************************************************************
571 IF (NUMEL .EQ. NUMELO) THEN
572 IF (numess .gt. 0) THEN
573 C Reserve Dynamic arrays needed to process information
574 C IDESS - array containing side set IDS
575 CALL MDRSRV ('IDESS' , KIDSS , NUMESS)
576 C NEESS - array containing the number of sides/elements for each sets
577 CALL MDRSRV ('NEESS' , KNESS , NUMESS)
578 C KNDSS - Returned array containing the number of dist
579 C factors for each set
580 CALL MDRSRV ('NDESS' , KNDSS , NUMESS )
581 C IXEESS - returned array containing the indices into the
582 C LTEESS array which are the locations of the 1st
583 C element of each set
584 CALL MDRSRV ('IXEESS', KIXESS, NUMESS)
585 C IXDESS - Returned array containing the indices into the
586 C FACESS array which are the locations of the 1st
587 C distribution factor for each set.
588 CALL MDRSRV ('IXDESS', KIDESS, NUMESS)
589 C LTEESS - Returned array containing the elements for all side
590 C sets. Internal element IDS are used in this list
591 CALL MDRSRV ('LTEESS', KLTESS, LESSEL)
592 C LTSESS - Returned array containing the sides for all side sets
593 CALL MDRSRV ('LTSESS', KLTSSS, LESSEL)
594 C FACESS - Returned array containing dist factors for all side sets
595 CALL MDRSRV ('FACESS', KFACSS, LESSDF)
596 CALL MDSTAT (NERR, MEM)
597 IF (NERR .GT. 0) THEN
598 CALL MEMERR
599 MERR = 1
600 RETURN
601 END IF
602 CAll EXGCSS(ndbin, a(kidss), a(kness), a(kndss), a(kixess),
603 & a(kidess), a(kltess), a(kltsss), a(kfacss), ierr)
604 END IF
605 END IF
606
607 C Write the side set information
608 IF ((numess .gt. 0) .AND. (nesso .gt. 0)) THEN
609 CAll EXPCSS(ndbout, a(kidss), a(kness), a(kndss), a(kixess),
610 & a(kidess), a(kltess), a(kltsss), a(kfacss), ierr)
611
612 C Delete dynamic memory
613 CALL MDDEL ('IDESS')
614 CALL MDDEL ('NEESS')
615 CALL MDDEL ('NDESS')
616 CALL MDDEL ('IXEESS')
617 CALL MDDEL ('IXDESS')
618 CALL MDDEL ('LTEESS')
619 CALL MDDEL ('LTSESS')
620 CALL MDDEL ('FACESS')
621 END IF
622
623 C ****************************************************************
624 C Read and write the element map
625 C ****************************************************************
626
627 IF (NUMEL .NE. NUMELO) CALL MDRSRV ('SCREL', KSCREL, NUMEL)
628 CALL MDRSRV ('MAPEL', KMAPEL, NUMEL)
629 CALL MDSTAT (NERR, MEM)
630 IF (NERR .GT. 0) THEN
631 CALL MEMERR
632 MERR = 1
633 RETURN
634 END IF
635
636 CALL RWMAP (NDBIN, NDBOUT, NUMEL, NUMELO, A(KXELEM), A(KMAPEL),
637 & A(KSCREL))
638
639 CALL MDDEL ('MAPEL')
640 IF (NUMEL .NE. NUMELO) CALL MDDEL ('SCREL')
641
642 C ****************************************************************
643 C Read and write the node number map
644 C ****************************************************************
645
646 IF (NUMNP .NE. NUMNPO) CALL MDRSRV ('SCRND', KSCRND, NUMNP)
647 CALL MDRSRV ('MAPND', KMAPND, NUMNP)
648 CALL MDSTAT (NERR, MEM)
649 IF (NERR .GT. 0) THEN
650 CALL MEMERR
651 MERR = 1
652 RETURN
653 END IF
654
655 CALL RWNMAP (NDBIN, NDBOUT, NUMNP, NUMNPO, A(KXNODE), A(KMAPND),
656 & A(KSCRND))
657
658 CALL MDDEL ('MAPND')
659 IF (NUMNP .NE. NUMNPO) CALL MDDEL ('SCRND')
660
661 C ****************************************************************
662 C Read and write the coordinates (may be used later)
663 C ****************************************************************
664
665 if (numnp .ne. numnpo) then
666 CALL MDRSRV('CRDSCR', KCRDSC, NDIM*NUMNPO)
667 else
668 kcrdsc = 1
669 end if
670 CALL MDRSRV ('CORD', KCORD, NDIM*NUMNP)
671 CALL MDSTAT (NERR, MEM)
672 IF (NERR .GT. 0) THEN
673 CALL MEMERR
674 MERR = 1
675 RETURN
676 END IF
677
678 CALL RWXYZ (NDBIN, NDBOUT, NDIM, NUMNP, NUMNPO, A(KXNODE),
679 & A(KCORD), A(KCRDSC))
680
681 if (numnp .ne. numnpo) then
682 call mddel('CRDSCR')
683 end if
684 IF (ICOBEG .GT. ICOEND) THEN
685 CALL MDDEL ('CORD')
686 END IF
687
688 CALL MDCOMP ()
689 CALL MCCOMP ()
690 C Cumulative element counts for each element block
691 CALL MDFIND ('IXELB' , KIXELB, 1+NELBLK)
692 C Cumulative element counts for each output block
693 CALL MDFIND ('IXELBO', KIXEBO, 1+NELBLK)
694 CALL MDFIND ('IDELB' , KIDELB, NELBLK)
695 CALL MDFIND ('NUMELB', KNELB, NELBLK)
696 CALL MCFIND ('NAMECO', KNACOR, namlen*NDIM)
697 CALL MCFIND ('NAMES', KNAMES, namlen*(NVARGL+NVARNP+NVAREL))
698 CALL MCFIND ('BLKTYP', KNMLB, NELBLK * MXSTLN)
699 CALL MDFIND ('SELELB', KSELEB, NELBLK)
700
701 IF (NSTEPS .GT. 0) THEN
702 CALL MDFIND ('IPTIMS', KPTIMS, NSTEPS)
703 CALL MDFIND ('TIMES', KTIMES, NSTEPS)
704 END IF
705 CALL MDFIND ('VISELB', KVISEB, NELBLK)
706 IF (NVAREL .GT. 0) THEN
707 CALL MDFIND ('ISEVOK', KIEVOK, NELBLK * NVAREL)
708 END IF
709 if (iszoom .or. isfilter .or. (nelblk .ne. nelbo) .or.
710 $ (numnpo .ne. numnp)) then
711 call mdfind ('IXNODE', KXNODE, NUMNPO)
712 else
713 KXNODE = 1
714 end if
715 if (iszoom .or. isfilter .or. (nelblk .ne. nelbo) .or.
716 $ (numelo .ne. numel)) then
717 call mdfind ('IXELEM', KXELEM, NUMELO)
718 else
719 KXELEM = 1
720 end if
721 CALL MDSTAT (NERR, MEM)
722 IF (NERR .GT. 0) THEN
723 CALL MEMERR
724 MERR = 1
725 RETURN
726 END IF
727
728 C ****************************************************************
729 C Reserve space for variable stack
730 C ****************************************************************
731
732 MAXNE = MAX (LTMENT, NUMNP, NUMEL)
733 C --MAXNE - maximum dimension for the variable stack and the variable
734 C -- arrays; an entry must be large enough to hold the time /
735 C -- history/global entry, the coordinates, a nodal variable
736 C -- or an element variable
737
738 CALL MDRSRV ('VARVAL', KVVAL, MAXNE * NUMSTO)
739 C --VARVAL(1..MAXNE,1..NUMSTO) - the needed input variables and
740 C -- the output variables
741
742 C --Save any coordinates needed for equation evaluation
743
744 IF (ICOBEG .LE. ICOEND) THEN
745 call mdfind ('CORD', KCORD, NDIM*NUMNP)
746 CALL SVCORD (A(KCORD), MAXNE, A(KVVAL))
747 CALL MDDEL ('CORD')
748 END IF
749
750 C --Reserve space for the equation evaluation stack
751
752 CALL MDRSRV ('STACK', KSTACK, MAXNE * MAXSTK)
753 C --STACK(1.MAXNE,1..MAXSTK) - an area for evaluating equations
754 CALL MDRSRV ('GVSCR', KGVSCR, NVARGO)
755 CALL MDRSRV ('VARSCR', KVARSC, MAXNE)
756 CALL MDSTAT (NERR, MEM)
757 IF (NERR .GT. 0) THEN
758 CALL MEMERR
759 MERR = 1
760 RETURN
761 END IF
762
763 C --Initialize variable read routine
764 CALL DBIVIN (.TRUE.)
765
766 c NWHOL = 0
767
768 WRITE (*, *)
769
770 C Loop from 1 to the number of selected times
771 if (nptims .eq. 0) then
772 if (numeqn .gt. 0) then
773 istep = 1
774 STEP1 = (NPT .EQ. 1)
775
776 C --Evaluate the equations to get the output variables
777
778 DO NEQN = 1, NUMEQN
779 CALL EVAL (STEP1, WSTEP1, MAXNE, MAXSTK,
780 & A(KXNODE), A(KIXELB), A(KIXEBO), A(KXELEM), A(KIEVOK),
781 & NEQN, NUMENT(NEQN), NAMENT(1,NEQN), TYPENT(1,NEQN),
782 & INXENT(1,NEQN), VALENT(1,NEQN),
783 & ITMENT(1,NEQN), IEVENT(1,NEQN), VSZENT(1,NEQN),
784 & A(KVVAL), A(KSTACK), MERR)
785 IF (MERR .EQ. 1) RETURN
786 END DO
787
788 C --Write the variables for the time step
789
790 CALL WRSTEP (NDBOUT, 1, MAXNE, A(KVVAL), A(KVISEB),
791 * A(KXNODE), A(KIXELB), A(KIXEBO), A(KXELEM),
792 * A(KIDELB), A(KIEVOK), A(KGVSCR), A(KVARSC), MERR)
793 IF (MERR .EQ. 1) RETURN
794
795 WRITE (*, 10000) 1
796 end if
797 else
798 DO 110 NPT = 1, NPTIMS
799 istep = iarray(iA(KPTIMS), NPT)
800 STEP1 = (NPT .EQ. 1)
801
802 c WSTEP1 = (WHOTIM(ISTEP) .AND. (NWHOL .LE. 0))
803 C Flag was present when distinguishing between
804 C whole and history time steps
805 WSTEP1 = .TRUE.
806
807 C --Read variables for one time step
808
809 CALL RDSTEP (ISTEP, IARRAY(iA(KTIMES), ISTEP), A(KNELB),
810 & A(KIDELB), A(KIEVOK), A(KVISEB),MAXNE, A(KVVAL), MERR)
811 IF (MERR .EQ. 1) RETURN
812
813 C --Fix up the first time step for last and first time variables
814
815 IF (STEP1) THEN
816 CALL FIXONE (MAXNE, A(KVVAL))
817 END IF
818
819 C --Evaluate the equations to get the output variables
820
821 DO 100 NEQN = 1, NUMEQN
822 CALL EVAL (STEP1, WSTEP1, MAXNE, MAXSTK,
823 & A(KXNODE), A(KIXELB), A(KIXEBO), A(KXELEM), A(KIEVOK),
824 & NEQN, NUMENT(NEQN), NAMENT(1,NEQN), TYPENT(1,NEQN),
825 & INXENT(1,NEQN), VALENT(1,NEQN),
826 & ITMENT(1,NEQN), IEVENT(1,NEQN), VSZENT(1,NEQN),
827 & A(KVVAL), A(KSTACK), MERR)
828 IF (MERR .EQ. 1) RETURN
829 100 CONTINUE
830
831 C --Write the variables for the time step
832
833 CALL WRSTEP (NDBOUT, NPT, MAXNE, A(KVVAL), A(KVISEB),
834 * A(KXNODE), A(KIXELB), A(KIXEBO), A(KXELEM),
835 * A(KIDELB), A(KIEVOK), A(KGVSCR), A(KVARSC), MERR)
836 IF (MERR .EQ. 1) RETURN
837
838 C --Move the values for the current time step into locations for the
839 C --last time step
840
841 CALL NXTTIM
842
843 NWRIT = NWRIT + 1
844
845 WRITE (*, 10000) NWRIT
846 10000 FORMAT (' ', I8, ' time steps processed')
847 c CALL NCSNC (NDBOUT, IERR)
848 110 CONTINUE
849 end if
850
851 CALL MDDEL ('VARSCR')
852 CALL MDDEL ('STACK')
853 CALL MDDEL ('GVSCR')
854 CALL MDDEL ('VARVAL')
855 CALL MDDEL ('IXELB')
856 CALL MDDEL ('IXELBO')
857 if (iszoom .or. isfilter .or. (nelblk .ne. nelbo)
858 $ .or. isremove) then
859 call mddel ('IXNODE')
860 CALL MDdel ('IXELEM')
861 end if
862 CALL MDSTAT(NERR, MEM)
863 IF (NERR .GT. 0) THEN
864 CALL MEMERR
865 MERR = 1
866 END IF
867
868 RETURN
869 END
870
871 integer function iarray(intarr, ipos)
872
873 integer intarr(*)
874 integer ipos
875
876 iarray = intarr(ipos)
877 return
878 end
879
880 integer function i2array(intarr, irows, irow, icol)
881
882 integer intarr(irows,*)
883 integer irow, icol
884
885 i2array = intarr(irow, icol)
886 return
887 end