Debian Codegraph @

packages/seacas/libraries/suplib/dbiv0.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 DBIV0 (NQAREC, NINFO)
9 C=======================================================================
10
11 C --*** DBIV0 *** (EXOLIB) Initialize for DBIVAR
12 C -- Written by Amy Gilkey - revised 11/04/87
13 C --
14 C --DBIV0 and DBIV1 initialize for the DBIVAR routine.
15 C --
16 C --Parameters:
17 C -- NQAREC - IN - the number of QA records
18 C -- NINFO - IN - the number of information records
19 C --
20 C --Database state is maintained within DBIVIN and DBIVAR, and should
21 C --not be moved between calls to these routines.
22
23 INTEGER NQAREC, NINFO
24
25 INTEGER NELBLK
26 INTEGER NVARHI, NVARGL, NVARNP, NVAREL
27 LOGICAL ISEVOK(*)
28
29 LOGICAL REWDB
30
31 INTEGER NDB
32 INTEGER NUMVAR
33 INTEGER IVAR(*)
34 INTEGER ISTEP
35 INTEGER LENVAR
36 INTEGER NUMELB(*)
37 REAL VAR(*)
38
39 CHARACTER*80 ERRMSG
40 CHARACTER TYP, T
41 LOGICAL WHOTIM
42
43 INTEGER NQASV, NINSV, NELBSV, NVELSV
44 SAVE NQASV, NINSV, NELBSV, NVELSV
45 C --NQASV, NINSV, NELBSV, NVELSV - the saved values for
46 C -- NQAREC, NINFO, NELBLK, NVAREL
47
48 INTEGER NREC0, NRECST
49 SAVE NREC0, NRECST
50 C --NREC0 - the number of database records before the time steps
51 C --NRECST - the number of database records for each whole time step
52
53 INTEGER IHVR0, IGVR0, INVR0, IEVR0
54 SAVE IHVR0, IGVR0, INVR0, IEVR0
55 C --IHVR0, IGVR0, INVR0, IEVR0 - the variable record number offset,
56 C -- including the time record
57
58 INTEGER NCSTEP, NCREC, NCEND
59 SAVE NCSTEP, NCREC, NCEND
60 C --NCSTEP - the current database step number; <0 if database should be
61 C -- rewound
62 C --NCREC - the current database record within time step
63 C --NCEND - the number of database records in current time step
64
65 DATA NQASV, NINSV, NELBSV / -999, -999, -999 /
66 DATA NREC0, NRECST / -999, -999 /
67 DATA IHVR0, IGVR0, INVR0, IEVR0 / -999, -999, -999, -999 /
68 DATA NCSTEP / -999 /
69
70 C --Save the input parameters
71
72 NQASV = NQAREC
73 NINSV = NINFO
74
75 GOTO 120
76
77 C=======================================================================
78 ENTRY DBIV1 (NELBLK, NVARHI, NVARGL, NVARNP, NVAREL, ISEVOK)
79 C=======================================================================
80
81 C --*** DBIV1 *** (EXOLIB) Initialize for DBIVAR
82 C -- Written by Amy Gilkey - revised 11/04/87
83 C --
84 C --DBIV0 and DBIV1 initialize for the DBIVAR routine.
85 C --
86 C --Parameters:
87 C -- NELBLK - IN - the number of element blocks
88 C -- NVARHI - IN - the number of history variables
89 C -- NVARGL - IN - the number of global variables
90 C -- NVARNP - IN - the number of nodal variables
91 C -- NVAREL - IN - the number of element variables
92 C -- ISEVOK - IN - the element block variable truth table;
93 C -- variable i of block j exists iff ISEVOK(j,i)
94 C --
95 C --Database state is maintained within DBIVIN and DBIVAR, and should
96 C --not be moved between calls to these routines.
97
98 C --Save the input parameters
99
100 NELBSV = NELBLK
101 NVELSV = NVAREL
102
103 C --Set NRECST = the number of records in a whole time step
104
105 IF (NRECST .LT. 0) THEN
106 NRECST = 1 + 1 + 1 + NVARNP
107 DO 110 IELB = 1, NELBLK
108 DO 100 I = 1, NVAREL
109 IF (ISEVOK( (I-1)*NELBLK+IELB )) THEN
110 NRECST = NRECST + 1
111 END IF
112 100 CONTINUE
113 110 CONTINUE
114 END IF
115
116 C --Set the variable record number offsets
117
118 IF (IHVR0 .LT. 0) THEN
119 IHVR0 = 1
120 IGVR0 = IHVR0 + 1
121 INVR0 = IGVR0 + 1
122 IEVR0 = INVR0 + NVARNP
123 END IF
124
125 C --DBIV0 and DBIV1 converge at this point
126 120 CONTINUE
127
128 C --Set NREC0 = the number of records before the time steps
129
130 IF (NREC0 .LT. 0) THEN
131 IF ((NELBSV .GE. 0)
132 & .AND. (NQASV .GE. 0) .AND. (NINSV .GE. 0)) THEN
133 NREC0 = 1 + 1 + 1 + 1 + NELBSV * (1 + 1 + 1) + 5 + 8
134 & + 1 + NQASV + 1 + NINSV + 1 + 1 + 1 + 1 + 1
135 END IF
136 END IF
137
138 RETURN
139
140 C=======================================================================
141 ENTRY DBIVIN (REWDB)
142 C=======================================================================
143
144 C --*** DBIVIN *** (EXOLIB) Initialize for DBIVAR
145 C -- Written by Amy Gilkey - revised 11/04/87
146 C --
147 C --DBIVIN initializes for the DBIVAR routine.
148 C --
149 C --Parameters:
150 C -- REWDB - IN - if true, database should be rewound, else database is
151 C -- at start of time steps
152 C --
153 C --Database state is maintained within DBIVIN and DBIVAR, and should
154 C --not be moved between calls to these routines.
155
156 IF (REWDB) THEN
157 NCSTEP = -999
158 ELSE
159 NCSTEP = 1
160 NCREC = 0
161 END IF
162
163 RETURN
164
165 C=======================================================================
166 ENTRY DBIVAR (NDB, NUMVAR, IVAR, ISTEP, LENVAR, IELBLK,
167 & NELBLK, NUMELB, ISEVOK, VAR, *)
168 C=======================================================================
169
170 C --*** DBIVAR *** (EXOLIB) Read variable
171 C -- Written by Amy Gilkey - revised 08/16/88
172 C --
173 C --DBIVAR returns the values for the requested variables for the
174 C --requested time step. Several variables may be read, but all must
175 C --be of the same type. Element variables may be read for a single
176 C --block (because of the way they are stored, this prevents rewinding).
177 C --
178 C --DBIVIN must be called before this routine is called and the database
179 C --cannot be moved between calls to DBIVIN and DBIVAR.
180 C --
181 C --Parameters:
182 C -- NDB - IN - the database number
183 C -- NUMVAR - IN - the number of variables to be read (for nodal and
184 C -- element variables only)
185 C -- IVAR - IN - the variable indices; no repetitions allowed
186 C -- ISTEP - IN - the time step number
187 C -- LENVAR - IN - the length of VAR
188 C -- IELBLK - IN - the element block number to read, 0 for all
189 C -- (for element variables only)
190 C -- NELBLK - IN - the number of element blocks
191 C -- (for element variables only)
192 C -- NUMELB - IN - the number of elements per block
193 C -- (for element variables only)
194 C -- ISEVOK - IN - the element block variable truth table;
195 C -- variable i of block j exists iff ISEVOK(j,i)
196 C -- (for element variables only)
197 C -- NOTE: ISEVOK is indexed as singly-dimensioned array.
198 C -- VAR - OUT - the variable values
199 C -- * - return statement if error encountered, message is printed
200
201 C --Find the variable type and ID
202
203 ieelb = 0
204 iselb = 0
205 ivrec = 0
206
207 CALL DBVTYP (IVAR(1), TYP, MINID)
208 MAXID = MINID
209 DO 130 I = 2, NUMVAR
210 CALL DBVTYP (IVAR(I), T, ID)
211 IF (TYP .NE. T) THEN
212 CALL PRTERR ('PROGRAM',
213 & 'Variables of different types requested')
214 GOTO 320
215 END IF
216 MINID = MIN (MINID, ID)
217 MAXID = MAX (MAXID, ID)
218 130 CONTINUE
219
220 IF (MINID .EQ. 0) TYP = 'T'
221 IF (TYP .EQ. ' ') THEN
222 CALL PRTERR ('PROGRAM', 'Invalid variable requested')
223 GOTO 320
224 END IF
225
226 C --Find the starting variable record number
227
228 IF (TYP .EQ. 'T') THEN
229 IVREC = 1
230 ELSE IF (TYP .EQ. 'H') THEN
231 IVREC = IHVR0 + 1
232 ELSE IF (TYP .EQ. 'G') THEN
233 IVREC = IGVR0 + 1
234 ELSE IF (TYP .EQ. 'N') THEN
235 IVREC = INVR0 + MINID
236 ELSE IF (TYP .EQ. 'E') THEN
237 IF (IELBLK .GE. 1) THEN
238 ISELB = IELBLK
239 IEELB = IELBLK
240 ELSE
241 ISELB = 1
242 IEELB = NELBLK
243 END IF
244
245 C --Check that some record must be read, otherwise return
246 DO 150 IELB = ISELB, IEELB
247 DO 140 I = 1, NUMVAR
248 CALL DBVTYP (IVAR(I), T, ID)
249 IF (ISEVOK( (ID-1)*NELBLK+IELB )) GOTO 160
250 140 CONTINUE
251 150 CONTINUE
252 RETURN
253 160 CONTINUE
254
255 IVREC = IEVR0 + 1
256 DO 180 IELB = 1, ISELB-1
257 DO 170 I = 1, NVELSV
258 IF (ISEVOK( (I-1)*NELBLK+IELB )) THEN
259 IVREC = IVREC + 1
260 END IF
261 170 CONTINUE
262 180 CONTINUE
263 DO 190 ID = 1, MINID-1
264 IF (ISEVOK( (ID-1)*NELBLK+ISELB )) THEN
265 IVREC = IVREC + 1
266 END IF
267 190 CONTINUE
268 END IF
269
270 C --Rewind the database if past record (or state is unknown)
271
272 IF ((NCSTEP .LT. 0) .OR. (ISTEP .LT. NCSTEP)
273 & .OR. ((ISTEP .EQ. NCSTEP) .AND. (IVREC .LE. NCREC))) THEN
274 REWIND (NDB, ERR=310)
275
276 NCSTEP = 0
277 NCREC = 0
278 DO 200 I = NCREC+1, NREC0
279 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
280 NCREC = NCREC + 1
281 200 CONTINUE
282 NCSTEP = 1
283 NCREC = 0
284 END IF
285
286 C --Scan rest of partially-read current time step (if not needed)
287
288 IF ((NCSTEP .LT. ISTEP) .AND. (NCREC .GT. 0)) THEN
289 DO 210 I = NCREC+1, NCEND
290 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
291 NCREC = NCREC + 1
292 210 CONTINUE
293 NCSTEP = NCSTEP + 1
294 NCREC = 0
295 END IF
296
297 C --Scan past preceding time steps
298
299 DO 230 IS = NCSTEP, ISTEP-1
300 NCREC = 0
301 READ (NDB, END=310, ERR=310, IOSTAT=IERR) TIME, HISTFL
302 NCREC = NCREC + 1
303 WHOTIM = (HISTFL .EQ. 0.0)
304
305 IF (WHOTIM) THEN
306 NCEND = NRECST
307 ELSE
308 NCEND = 2
309 END IF
310 DO 220 I = NCREC+1, NCEND
311 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
312 NCREC = NCREC + 1
313 220 CONTINUE
314 NCSTEP = NCSTEP + 1
315 NCREC = 0
316 230 CONTINUE
317
318 C --Scan to needed record in this time step
319
320 IF (NCREC .LE. 0) THEN
321 READ (NDB, END=310, ERR=310, IOSTAT=IERR) TIME, HISTFL
322 NCREC = 1
323 WHOTIM = (HISTFL .EQ. 0.0)
324
325 IF (WHOTIM) THEN
326 NCEND = NRECST
327 ELSE
328 NCEND = 2
329 END IF
330 END IF
331
332 IF (IVREC .GT. NCEND) THEN
333 CALL PRTERR ('PROGRAM',
334 & 'History variables only on this time step')
335 GOTO 320
336 END IF
337 DO 240 I = NCREC+1, IVREC-1
338 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
339 NCREC = NCREC + 1
340 240 CONTINUE
341
342 C --Read variable values
343
344 IF (TYP .EQ. 'T') THEN
345 VAR(1) = TIME
346
347 ELSE IF ((TYP .EQ. 'H') .OR. (TYP .EQ. 'G')) THEN
348 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
349 & (VAR(I), I=1,LENVAR)
350 NCREC = NCREC + 1
351
352 ELSE IF (TYP .EQ. 'N') THEN
353 CALL DBVIX (TYP, 1, IX1)
354 DO 250 ID = MINID, MAXID
355 IX = LOCINT (ID+IX1-1, NUMVAR, IVAR)
356 IF (IX .GT. 0) THEN
357 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
358 & (VAR( (IX-1)*LENVAR+I ), I=1,LENVAR)
359 NCREC = NCREC + 1
360 END IF
361 250 CONTINUE
362
363 ELSE IF (TYP .EQ. 'E') THEN
364 CALL DBVIX (TYP, 1, IX1)
365
366 IEL0 = 0
367 DO 260 IELB = 1, ISELB-1
368 IEL0 = IEL0 + NUMELB(IELB)
369 260 CONTINUE
370
371 DO 300 IELB = ISELB, IEELB
372 IF (IELB .GT. ISELB) THEN
373 DO 270 ID = 1, MINID-1
374 IF (ISEVOK( (ID-1)*NELBLK+IELB )) THEN
375 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
376 NCREC = NCREC + 1
377 END IF
378 270 CONTINUE
379 END IF
380
381 DO 280 ID = MINID, MAXID
382 IX = LOCINT (ID+IX1-1, NUMVAR, IVAR)
383 IF (IX .GT. 0) THEN
384 IF (ISEVOK( (ID-1)*NELBLK+IELB )) THEN
385 READ (NDB, END=310, ERR=310, IOSTAT=IERR)
386 & (VAR( (IX-1)*LENVAR+IEL0+NE), NE=1,NUMELB(IELB))
387 NCREC = NCREC + 1
388 END IF
389 ELSE
390 IF (ISEVOK( (ID-1)*NELBLK+IELB )) then
391 read (ndb, end=310, err=310, iostat=ierr)
392 ncrec = ncrec + 1
393 end if
394 end if
395 280 continue
396
397 if (ielb .lt. ieelb) then
398 do 290 id = maxid+1, nvelsv
399 if (isevok( (id-1)*nelblk+ielb )) then
400 read (ndb, end=310, err=310, iostat=ierr)
401 ncrec = ncrec + 1
402 end if
403 290 continue
404 end if
405 iel0 = iel0 + numelb(ielb)
406 300 continue
407 end if
408
409 if (ncrec .ge. ncend) then
410 ncstep = ncstep + 1
411 ncrec = 0
412 end if
413
414 return
415
416 310 continue
417 errmsg = 'time step variable'
418 call dberr (ierr, errmsg)
419 ncstep = -999
420 320 continue
421 return 1
422 end