Debian Codegraph @

packages/seacas/applications/ex1ex2v2/ex1ex2v2.f

raw
1 C Copyright(C) 1999-2021 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 PROGRAM EX1EX2V2
9 C=======================================================================
10
11 C --*** EX1EX2V2 *** EXODUS I to EXODUS II translator
12 C --
13 C --EX1EX2V2 reads EXODUS I database and writes an EXODUS II V2.03 database
14 C --
15
16 include 'exodusII.inc'
17 INCLUDE 'argparse.inc'
18
19 CHARACTER*8 QAINFO(6)
20
21 CHARACTER*80 TITLE
22
23 PARAMETER (MAXQA = 100, MAXINF = 100)
24 PARAMETER (MAXDIM=6, MAXELB=512, MAXVAR=512)
25 CHARACTER*8 QAREC(4,MAXQA)
26 CHARACTER*80 INFO(MAXINF)
27 CHARACTER*8 NAMECO(MAXDIM)
28 CHARACTER*8 NAMELB(MAXELB)
29 CHARACTER*8 NAMES(MAXVAR)
30 character*2048 exofil, netfil, scratch
31 character*8 name
32
33 integer cpuws,wsout
34
35 DIMENSION A(1)
36 DIMENSION IA(1)
37 EQUIVALENCE (A(1), IA(1))
38 C --A - the dynamic memory base array
39
40 CHARACTER*8 STR8
41 LOGICAL EXODUS
42 LOGICAL WHOTIM
43
44 data (qainfo(i), i=1,3) / 'ex1ex2v2', '20210128', 'v 2.13 ' /
45 data iin,iout/5,6/
46 data nsteps /0/
47 data cpuws,wsout /0,0/
48
49 CALL STRTUP (QAINFO)
50
51 CALL BANNER (0, QAINFO,
52 & 'EXODUS I TO EXODUS II FILE TRANSLATOR',
53 & ' ', ' ')
54
55 C --Open the input and output files
56
57 NDB = 11
58 NET = 20
59
60 c make netCDF and exodus errors not show up
61
62 call exopts(0,ierr)
63
64 C .. Get filename from command line. If not specified, emit error message
65 NARG = argument_count()
66 if (narg .lt. 2) then
67 CALL PRTERR ('FATAL', 'Filenames not specified.')
68 CALL PRTERR ('FATAL',
69 * 'Syntax is: "ex1ex2v2 exo1_file exo2_file"')
70 GOTO 140
71 else if (narg .gt. 2) then
72 CALL PRTERR ('FATAL', 'Too many arguments specified.')
73 CALL PRTERR ('FATAL',
74 * 'Syntax is: "ex1ex2v2 exo1_file exo2_file"')
75 GOTO 140
76 end if
77
78 CALL get_argument(1,exofil, lnam)
79 write(*,*)'Input filename: ',exofil(1:lnam)
80 open(unit=ndb, file=exofil(:lnam), form='unformatted',
81 * status='old', iostat=ierr)
82 IF (IERR .NE. 0) THEN
83 SCRATCH = 'Database "'//exofil(:lnam)//'" does not exist.'
84 CALL PRTERR ('FATAL', SCRATCH(:LENSTR(SCRATCH)))
85 GOTO 140
86 END IF
87
88 CALL get_argument(2,netfil, lnam)
89 write(*,*)'Output filename: ',netfil(1:lnam)
90
91 wsout = 8
92 write(*,*)'Output word size: ',wsout
93 CALL MDINIT (A)
94 CALL MDSTAT (NERR, MEM)
95 IF (NERR .GT. 0) GOTO 130
96 CALL MDFILL(-1)
97
98 C --Read the initial variables from exodusI database
99
100 CALL DBIINI (NDB, '*', NVERS, TITLE, NDIM, NUMNP, NUMEL, NELBLK,
101 & NUMNPS, LNPSNL, NUMESS, LESSEL, LESSNL, *150)
102
103 c create the a netcdf file
104 idexo = excre (netfil(1:lnam), EXCLOB, cpuws, wsout, ierr)
105 if (ierr .lt. 0) then
106 call exerr('ex1ex2v2','Error from excre', EXLMSG)
107 go to 140
108 end if
109
110 c write initial variables to netcdf file
111 call expini (idexo, title, ndim, numnp, numel, nelblk, numnps,
112 & numess, ierr)
113 if (ierr .lt. 0) then
114 call exerr ('ex1ex2v2',' Error from expini', EXLMSG)
115 goto 150
116 end if
117
118 CALL DBPINI ('NTIS', NDB, TITLE, NDIM, NUMNP, NUMEL, NELBLK,
119 & NUMNPS, LNPSNL, NUMESS, LESSEL, LESSNL,
120 & IDUM, IDUM, IDUM, IDUM)
121 WRITE(*,*)
122
123 C --Read the coordinates from the exodusI database
124
125 CALL MDRSRV ('XN', KXN, NUMNP)
126 CALL MDRSRV ('YN', KYN, NUMNP)
127 IF (NDIM .GE. 3) THEN
128 CALL MDRSRV ('ZN', KZN, NUMNP)
129 ELSE
130 KZN = 1
131 END IF
132 CALL MDSTAT (NERR, MEM)
133 IF (NERR .GT. 0) GOTO 130
134
135 CALL DBIXYZ (NDB, '*', NDIM, NUMNP, A(KXN), A(KYN), A(KZN), *150)
136
137 c write the coordinates to the regular netcdf file
138
139 call expcor (idexo, a(kxn), a(kyn), a(kzn), ierr)
140
141 if (ierr .lt. 0) then
142 call exerr ('ex1ex2v2','Error from expcor', EXLMSG)
143 goto 150
144 end if
145 CALL MDDEL ('XN')
146 CALL MDDEL ('YN')
147 IF (NDIM .GE. 3) CALL MDDEL ('ZN')
148 C --Read the element order map from the exodusI database
149
150 CALL MDRSRV ('MAPEL', KMAPEL, NUMEL)
151 CALL MDSTAT (NERR, MEM)
152 IF (NERR .GT. 0) GOTO 130
153
154 CALL DBIMAP (NDB, '*', NUMEL, IA(KMAPEL), *150)
155
156 c write the element order map to the regular netcdf file
157
158 call expmap (idexo, ia(kmapel), ierr)
159 if (ierr .lt. 0) then
160 call exerr ('ex1ex2v2','Error from expmap', EXLMSG)
161 goto 150
162 end if
163 CALL MDDEL ('MAPEL')
164
165 C --Read the element blocks
166
167 CALL MDRSRV ('NUMELB', KNELB, NELBLK)
168 CALL MDRSRV ('LINK', KLINK, 0)
169 CALL MDRSRV ('ATRIB', KATRIB, 0)
170 call MDRSRV ('IDELB', KIDELB, NELBLK)
171 call MDRSRV ('NUMLNK', KNMLNK, NELBLK)
172 call MDRSRV ('NUMATR', KNMATR, NELBLK)
173 CALL MDSTAT (IERR, MEM)
174 IF (IERR .GT. 0) goto 150
175
176 CALL DBIELB (NDB, '*', 1, nelblk, IA(KIDELB), IA(KNELB),
177 * IA(KNMLNK), IA(KNMATR), A, KLINK, KATRIB, *150)
178 CALL MDSTAT (IERR, MEM)
179 IF (IERR .GT. 0) goto 150
180
181 C --Read the nodal points sets
182
183 CALL MDRSRV ('IDNPS', KIDNS, NUMNPS)
184 CALL MDRSRV ('NNNPS', KNNNS, NUMNPS)
185 CALL MDRSRV ('IXNNPS', KIXNNS, NUMNPS)
186 CALL MDRSRV ('LSTNPS', KLSTNS, LNPSNL)
187 CALL MDRSRV ('FACNPS', KFACNS, LNPSNL)
188 CALL MDSTAT (NERR, MEM)
189 IF (NERR .GT. 0) GOTO 130
190
191 CALL DBINPS (NDB, '*', NUMNPS, LNPSNL,
192 & IA(KIDNS), IA(KNNNS), IA(KIXNNS), IA(KLSTNS), A(KFACNS), *150)
193
194 C --Read the element side sets
195
196 CALL MDRSRV ('IDESS', KIDSS, NUMESS)
197 CALL MDRSRV ('NEESS', KNESS, NUMESS)
198 CALL MDRSRV ('NNESS', KNNSS, NUMESS)
199 CALL MDRSRV ('IXEESS', KIXESS, NUMESS)
200 CALL MDRSRV ('IXNESS', KIXNSS, NUMESS)
201 CALL MDRSRV ('LTEESS', KLTESS, LESSEL)
202 CALL MDRSRV ('LTNESS', KLTNSS, LESSNL)
203 CALL MDRSRV ('FACESS', KFACSS, LESSNL)
204 CALL MDRSRV ('SACESS', KLTSSS, LESSEL)
205 CALL MDSTAT (NERR, MEM)
206 IF (NERR .GT. 0) GOTO 130
207
208 CALL DBIESS (NDB, '*', NUMESS, LESSEL, LESSNL,
209 & IA(KIDSS), IA(KNESS), IA(KNNSS), IA(KIXESS), IA(KIXNSS),
210 & IA(KLTESS), IA(KLTNSS), A(KFACSS), *150)
211
212 C --Read the QA and info records
213 C ... Exodus set to .FALSE. if end of file during this read
214 CALL DBIQA (NDB, '*', MAXQA, MAXINF, NQAREC, QAREC, NINFO, INFO,
215 & EXODUS, *150)
216
217 c**********************************************************************
218 C --Read the database names
219
220 if (exodus) then
221 C ... Exodus set to .FALSE. if end of file during this read
222 CALL DBINAM (NDB, '*', NDIM, NELBLK,
223 & NNDIM, NNELB, NVARHI, NVARGL, NVARNP, NVAREL,
224 & NAMECO, NAMELB, NAMES, IXHV, IXGV, IXNV, IXEV,
225 & A, KIEVOK, EXODUS, *150)
226 CALL MDSTAT (NERR, MEM)
227 IF (NERR .GT. 0) GOTO 130
228
229 if (.not. exodus) then
230 nvarhi = 0
231 nvargl = 0
232 nvarnp = 0
233 nvarel = 0
234 end if
235 CALL DBPINI ('V', NDB, TITLE, NDIM, NUMNP, NUMEL, NELBLK,
236 & NUMNPS, LNPSNL, NUMESS, LESSEL, LESSNL,
237 & NVARHI, NVARGL, NVARNP, NVAREL)
238 else
239 C ... Assign dummy coordinate names...
240 NAMECO(1) = 'X'
241 NAMECO(2) = 'Y'
242 NAMECO(3) = 'Z'
243 C ... Try to infer the element block names also
244 do 50 ielb = 0, nelblk-1
245 namelb(ielb+1) = 'UNKNOWN'
246 npe = ia(knmlnk+ielb)
247 if (ndim .eq. 2) then
248 if (npe .eq. 4) then
249 namelb(ielb+1) = 'QUAD'
250 else if (npe .eq. 8) then
251 namelb(ielb+1) = 'QUAD8'
252 else if (npe .eq. 3) then
253 namelb(ielb+1) = 'TRIANGLE'
254 end if
255 else if (ndim .eq. 3) then
256 if (npe .eq. 4) then
257 if (ia(knmatr+ielb) .eq. 0) then
258 namelb(ielb+1) = 'TETRA'
259 else
260 namelb(ielb+1) = 'SHELL'
261 end if
262 else if (npe .eq. 8) then
263 if (ia(knmatr+ielb) .eq. 0) then
264 namelb(ielb+1) = 'HEX'
265 else
266 namelb(ielb+1) = 'SHELL8'
267 end if
268 else if (npe .eq. 6) then
269 namelb(ielb+1) = 'WEDGE'
270 end if
271 end if
272 50 continue
273 END IF
274
275 c*********
276 ioff = 0
277 DO 100 IELB = 1, NELBLK
278
279 c write element block parameters to the netcdf file
280
281 call expelb (IDEXO, IA(KIDELB+IELB-1), namelb(IELB),
282 1 IA(KNELB+IELB-1),
283 2 IA(KNMLNK+IELB-1), IA(KNMATR+IELB-1), IERR)
284 IF (IERR .lt. 0) THEN
285 CALL exerr('ex1ex2v2','Error from expelb',EXLMSG)
286 ENDIF
287
288 c write block attributes to the netcdf file
289
290 IF (IA(KNMATR+IELB-1) .GT. 0) THEN
291 call expeat (IDEXO, IA(KIDELB+IELB-1), A(KATRIB+ioff), IERR)
292 IF (IERR .lt. 0) THEN
293 CALL exerr ('rdelb','Error from expeat', EXLMSG)
294 ENDIF
295 end if
296
297 ioff = ioff + ia(knmatr + ielb-1) * ia(knelb + ielb-1)
298
299 c CALL MDLONG ('LINK', KLINK, 0)
300 c CALL MDLONG ('ATRIB', KATRIB, 0)
301 100 CONTINUE
302
303 iptr = klink
304 do 101 ielb = 1, nelblk
305
306 c write the element block connectivity to the netcdf file
307 c skipping null element blocks
308
309 if (IA(KNELB+IELB-1) .eq. 0) then
310 write(*,*)'Null element block: ',ielb
311 else
312 call expelc (idexo, ia(kidelb+ielb-1), ia(iptr), ierr)
313 if (ierr .lt. 0) then
314 call exerr ('ex1ex2v2','Error from expelc', exlmsg)
315 goto 150
316 end if
317 end if
318
319 iptr = iptr + ( ia(knmlnk+ielb-1) * ia(knelb+ielb-1) )
320
321 101 continue
322
323 c write out the nodal point sets to the regular netcdf file
324 c Note: For exodus I data, dist factors always exist.
325
326 if (numnps .gt. 0) then
327 call expcns (idexo, ia(kidns), ia(knnns), ia(knnns),
328 * ia(kixnns), ia(kixnns), ia(klstns), a(kfacns), ierr)
329 if (ierr .lt. 0) then
330 call exerr ('ex1ex2v2','Error from expcns', exlmsg)
331 goto 150
332 end if
333 endif
334
335 c write element side sets
336
337 c Note: Exodus II V2.0 represents a major change for side sets:
338 c They are represented as side IDs - not node IDs and
339 c must be translated.
340 if (numess .gt. 0) then
341 call excn2s (idexo, ia(kness), ia(knnss), ia(kixess),
342 1 ia(kixnss), ia(kltess), ia(kltnss), ia(kltsss), ierr)
343 if (ierr .lt. 0) then
344 call exerr ('ex1ex2v2','Error from excn2s', exlmsg)
345 goto 150
346 end if
347
348 call expcss (idexo, ia(kidss), ia(kness), ia(knnss), ia(kixess),
349 & ia(kixnss), ia(kltess), ia(kltsss), a(kfacss), ierr)
350 if (ierr .lt. 0) then
351 call exerr ('ex1ex2v2','Error from expcss', exlmsg)
352 goto 150
353 end if
354 endif
355
356 call mddel ('LINK')
357 call mddel ('NUMLNK')
358 CALL MDDEL ('ATRIB')
359 CALL MDDEL ('NUMATR')
360
361 CALL MDDEL ('IDNPS')
362 CALL MDDEL ('NNNPS')
363 CALL MDDEL ('IXNNPS')
364 CALL MDDEL ('LSTNPS')
365 CALL MDDEL ('FACNPS')
366
367 CALL MDDEL ('IDESS')
368 CALL MDDEL ('NEESS')
369 CALL MDDEL ('NNESS')
370 CALL MDDEL ('IXEESS')
371 CALL MDDEL ('IXNESS')
372 CALL MDDEL ('LTEESS')
373 CALL MDDEL ('LTNESS')
374 CALL MDDEL ('FACESS')
375 CALL MDDEL ('SACESS')
376 CALL MDSTAT (NERR, MEM)
377 IF (NERR .GT. 0) GOTO 130
378
379 c write the QA records
380
381 IF (NQAREC .GT. 0) then
382 call expqa (idexo, NQAREC, QAREC, ierr)
383 if (ierr .lt. 0) then
384 call exerr ('ex1ex2v2','Error from expqa', exlmsg)
385 goto 150
386 end if
387 end if
388
389 c write the info records
390
391 if (NINFO .gt. 0) then
392 call expinf (idexo, ninfo, info, ierr)
393 if (ierr .lt. 0) then
394 call exerr ('ex1ex2v2','Error from expinf', exlmsg)
395 goto 150
396 end if
397 end if
398
399 c**********************************************************************
400
401 c write coordinate names
402
403 call expcon (idexo, nameco, ierr)
404 if (ierr .lt. 0) then
405 call exerr ('ex1ex2v2','Error from expcon', exlmsg)
406 goto 150
407 end if
408
409 if (.not. EXODUS) goto 150
410
411 c write the number of global variables
412
413 if (nvargl .gt. 0) then
414 call expvp (idexo, 'G', nvargl, ierr)
415 if (ierr .lt. 0) then
416 call exerr ('ex1ex2v2','Error from expvp', exlmsg)
417 goto 140
418 end if
419
420 c write the global variable names
421
422 call expvan (idexo, 'G', nvargl, names(ixgv), ierr)
423 if (ierr .lt. 0) then
424 call exerr ('ex1ex2v2','Error from expvan', exlmsg)
425 goto 140
426 end if
427 end if
428
429 c write the number of nodal variables
430
431 if (nvarnp .gt. 0) then
432 call expvp (idexo, 'N', nvarnp, ierr)
433 if (ierr .lt. 0) then
434 call exerr ('ex1ex2v2','Error from expvp', exlmsg)
435 goto 140
436 end if
437
438 c write the nodal variable names
439
440 call expvan (idexo, 'N', nvarnp, names(ixnv), ierr)
441 if (ierr .lt. 0) then
442 call exerr ('ex1ex2v2','Error from expvan', exlmsg)
443 goto 140
444 end if
445 end if
446
447 c write the number of element variables
448
449 if (nvarel .gt. 0) then
450 call expvp (idexo, 'E', nvarel, ierr)
451 if (ierr .lt. 0) then
452 call exerr ('ex1ex2v2','Error from expvp', exlmsg)
453 goto 140
454 end if
455
456 c write the element variable names
457
458 call expvan (idexo, 'E', nvarel, names(ixev), ierr)
459 if (ierr .lt. 0) then
460 call exerr ('ex1ex2v2','Error from exvan', exlmsg)
461 goto 140
462 end if
463 end if
464
465 c write the element variable truth table
466
467 call mdrsrv ('ebids', kebids, nelblk)
468 call exgebi (idexo, ia(kebids), ierr)
469 if (ierr .lt. 0) then
470 call exerr ('ex1ex2v2','Error from exgebi', exlmsg)
471 goto 140
472 end if
473
474 if (nvarel .gt. 0) then
475 call expvtt(idexo, nelblk, nvarel, ia(kievok), ierr)
476 if (ierr .lt. 0) then
477 call exerr ('ex1ex2v2','Error from expvtt', exlmsg)
478 goto 140
479 end if
480 end if
481
482 call mddel ('ebids')
483
484 IF (.NOT. EXODUS) GOTO 140
485
486 C --Read the database time steps
487
488 CALL MDRSRV ('VARHI', KVARHI, NVARHI)
489 CALL MDRSRV ('VARGL', KVARGL, NVARGL)
490 CALL MDRSRV ('VARNP', KVARNP, NVARNP * NUMNP)
491 CALL MDRSRV ('VAREL', KVAREL, NVAREL * NUMEL)
492 CALL MDSTAT (NERR, MEM)
493 IF (NERR .GT. 0) GOTO 130
494
495 nwstep = 0
496 nhstep = 0
497
498 110 CONTINUE
499 IF (.TRUE.) THEN
500
501 CALL DBISTE (NDB, '*', NhSTEP+1,
502 & NVARHI, NVARGL, NVARNP, NUMNP, NVAREL, NELBLK,
503 & ia(knelb), IA(KIEVOK), TIME, WHOTIM, A(KVARHI),
504 & A(KVARGL), A(KVARNP), A(KVAREL), *120)
505
506 nhstep = nhstep + 1
507 if (whotim) then
508 nwstep = nwstep+1
509 write (*,'(4x, "processing whole time step ", i4)') nwstep
510
511 c write global variables
512
513 if (nvargl .gt. 0) then
514 call expgv (idexo, nwstep, nvargl, a(kvargl), ierr)
515 if (ierr .lt. 0) then
516 call exerr ('ex1ex2v2','Error from expgv', exlmsg)
517 goto 140
518 end if
519 end if
520
521 c write nodal variable values
522
523 if (nvarnp .gt. 0) then
524 do 111 i= 1,nvarnp
525 call expnv (idexo, nwstep, i, numnp,
526 & a(kvarnp+(i-1)*numnp), ierr)
527 if (ierr .lt. 0) then
528 call exerr ('ex1ex2v2','Error from expnv', exlmsg)
529 goto 140
530 end if
531 111 continue
532 end if
533
534 c write element variable values
535
536 if (nvarel .gt. 0) then
537 call putev (idexo, nwstep, nelblk, nvarel,
538 & ia(knelb), a(kvarel), ia(kidelb), ia(kievok), ierr)
539 if (ierr .lt. 0) then
540 call exerr ('ex1ex2v2','Error from putev', exlmsg)
541 goto 140
542 end if
543 end if
544
545 c write whole time step
546
547 call exptim (idexo, nwstep, time, ierr)
548 if (ierr .lt. 0) then
549 call exerr ('ex1ex2v2','Error from exptim', exlmsg)
550 goto 140
551 end if
552
553 end if
554 GOTO 110
555 END IF
556
557 120 CONTINUE
558
559 call mddel ('IDELB')
560
561 WRITE (STR8, '(I8)', IOSTAT=K) NwSTEP
562 CALL SQZSTR (STR8, LSTR)
563 WRITE (*, 10010) STR8(:LSTR)
564 10010 FORMAT (/, 4X, A,
565 & ' time steps have been written to the file')
566
567 GOTO 140
568
569 130 CONTINUE
570 CALL MEMERR
571 CALL MDSTAT (NERR, MEM)
572 WRITE(*,10020) QAINFO(1), MEM
573 10020 FORMAT(1x,A8,' currently using ', I10, ' words of memory')
574
575 140 CONTINUE
576
577 150 if (idexo .gt. 0) call exclos (idexo, ierr)
578
579 IF (NDB .NE. 0) CLOSE (NDB, IOSTAT=K)
580
581 call addlog (QAINFO(1)(:lenstr(QAINFO(1))))
582 CALL WRAPUP (QAINFO(1))
583 STOP
584 END