Debian Codegraph @

packages/seacas/applications/blot/rndvar.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 RNDVAR (A, IA, LA, IVAR, IELBLK, INSTEP, LENVAR, VAR)
9 C=======================================================================
10
11 C --*** RNDVAR *** (BLOT) Read variable
12 C -- Written by Amy Gilkey - revised 07/27/88
13 C --
14 C --RNDVAR returns the values for the requested variable for the
15 C --requested time step. It either reads the values from the sequential
16 C --database file and writes them to a direct access scratch file or it
17 C --reads the values from the direct access scratch file.
18 C --
19 C --This routine uses MDFIND to find the following dynamic memory arrays:
20 C -- NUMELB - the number of elements per element block
21 C -- ISEVOK - the element block variable truth table;
22 C -- variable i of block j exists iff ISEVOK(j,i)
23 C -- WHOTIM - true iff whole (versus history) time step
24 C --
25 C --Parameters:
26 C -- A - IN - the dynamic memory base array
27 C -- IVAR - IN - the variable index
28 C -- (0 to initialize random file only)
29 C -- IELBLK - IN - the element block number, <=0 for all
30 C -- (for element blocks only)
31 C -- INSTEP - IN - the time step number
32 C -- = +n to read time step n
33 C -- = -n to transfer time step n to random file only
34 C -- = 0 to transfer all time steps to random file
35 C -- LENVAR - IN - the length of VAR
36 C -- VAR - OUT - the variable values (indeterminate if INSTEP <= 0)
37 C --
38 C --Common Variables:
39 C -- Uses NDB of /DBASE/
40 C -- Uses NUMNP, NUMEL, NELBLK, NVARHI, NVARGL, NVARNP, NVAREL,
41 C -- NSTEPS, NSTEPW of /DBNUMS/
42 C --
43 C --Database is rewound upon the first entry of this routine; upon
44 C --exit a flag is set to keep track of the database position; the
45 C --database should not be moved between calls to this routine.
46 C --
47 C --A scratch random file is created and read and written in this routine.
48 C --It is connected to unit 90.
49
50 include 'exodusII.inc'
51 include 'dbase.blk'
52 include 'dbnums.blk'
53
54 REAL VAR(*)
55
56 DIMENSION A(*)
57 INTEGER IA(*)
58 LOGICAL LA(*)
59
60 CHARACTER TYP
61
62 INTEGER KNELB, KIEVOK, KIDELB
63 C --KNELB - the dynamic memory index of NUMELB - the number of elements
64 C -- per element block
65 C --KIEVOK - the dynamic memory index of ISEVOK - the element block
66 C -- variable truth table; variable i of block j exists iff ISEVOK(j,i)
67
68 IF (IVAR .EQ. 0) return
69 if (instep .le. 0) return
70
71 CALL DBVTYP_BL (IVAR, TYP, IDVAR)
72
73 if (typ .eq. 'G') then
74 if (lenvar .lt. nvargl) then
75 call prterr ('PROGRAM', 'Invalid Array length in rndvar')
76 end if
77 call exggv(ndb, instep, nvargl, var, ierr)
78 end if
79
80 if (typ .eq. 'N') then
81 if (lenvar .lt. numnp) then
82 call prterr ('PROGRAM', 'Invalid Array length in rndvar')
83 end if
84 call exgnv(ndb, instep, idvar, numnp, var, ierr)
85 END IF
86
87 if (typ .eq. 'E') then
88 if (lenvar .lt. numel) then
89 call prterr ('PROGRAM', 'Invalid Array length in rndvar')
90 end if
91 call inirea(numel, 0.0, var)
92 if (ielblk .le. 0) then
93 imin = 1
94 imax = nelblk
95 else
96 imin = ielblk
97 imax = ielblk
98 end if
99 CALL MDFIND ('ISEVOK', KIEVOK, IDUM)
100 CALL MDFIND ('IDELB', KIDELB, IDUM)
101 CALL MDFIND ('NUMELB', KNELB, IDUM)
102 CALL MDSTAT (NERR, MEM)
103 IF (NERR .GT. 0) GOTO 130
104
105 call rndelv(ndb, imin, imax, instep, idvar, ia(kidelb),
106 & ia(knelb), var(1), la(kievok), nelblk)
107 END IF
108
109 130 CONTINUE
110 RETURN
111 END
112
113 subroutine rndelv(ndb, imin,imax, instep, idvar,
114 & idelb, numelb, var, isevok, nelblk)
115
116 real var(*)
117 integer idelb(*), numelb(*)
118 logical isevok(nelblk, *)
119
120 ibeg = 1
121 do 10 iel = imin, imax
122 C--- Check truth table.
123 if (isevok(iel, idvar)) then
124 call exgev(ndb, instep, idvar, idelb(iel), numelb(iel),
125 & var(ibeg), ierr)
126 end if
127 ibeg = ibeg + numelb(iel)
128 10 continue
129
130 return
131 end
132 C --Converted