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