| 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 DBITIM (NDB, OPTION, EXODUS, |
| 9 |
& NVARNP, NELBLK, NVAREL, ISEVOK, |
| 10 |
& NSTEPS, NSTEPW, A, KTIMES, KWHOLE, *) |
| 11 |
C======================================================================= |
| 12 |
|
| 13 |
C --*** DBITIM *** (EXOLIB) Read database time step times |
| 14 |
C -- Written by Amy Gilkey - revised 11/11/87 |
| 15 |
C -- |
| 16 |
C --DBITIM reads all time steps of the database, storing the time for |
| 17 |
C --each step in dynamic memory. It also sets the number of time steps. |
| 18 |
C --If there is a dynamic memory problem, the routine returns immediately |
| 19 |
C --without issuing an error message. If there is a read error, a |
| 20 |
C --warning is printed and the step with the error is ignored. |
| 21 |
C -- |
| 22 |
C --Parameters: |
| 23 |
C -- NDB - IN - the database number |
| 24 |
C -- OPTION - IN - ' ' to not store, '*' to store all, else store options: |
| 25 |
C -- 'W' to store whole times only |
| 26 |
C -- 'H' to store history times only |
| 27 |
C -- EXODUS - IN - true iff this is an EXODUS file |
| 28 |
C -- NVARNP - IN - the number of nodal variables |
| 29 |
C -- NELBLK - IN - the number of element blocks |
| 30 |
C -- NVAREL - IN - the number of element variables |
| 31 |
C -- ISEVOK - IN - the element block variable truth table; |
| 32 |
C -- variable i of block j exists iff ISEVOK(j,i) |
| 33 |
C -- NSTEPS - OUT - the number of database time steps |
| 34 |
C -- NSTEPW - OUT - the number of whole (versus history) database time steps |
| 35 |
C -- A - IN/OUT - the dynamic memory base array |
| 36 |
C -- KTIMES - OUT - the dynamic memory index of TIMES (if OPTION) |
| 37 |
C -- KWHOLE - OUT - the dynamic memory index of WHOTIM (if OPTION); |
| 38 |
C -- WHOTIM(i) is true iff TIMES(i) is a whole (versus history) time step |
| 39 |
C -- * - return statement if error encountered, message is printed |
| 40 |
C -- |
| 41 |
C --Database must be positioned in front of first time step upon entry; |
| 42 |
C --upon exit positioned at end of file. |
| 43 |
|
| 44 |
PARAMETER (MEMAMT=128) |
| 45 |
|
| 46 |
INTEGER NDB |
| 47 |
CHARACTER*(*) OPTION |
| 48 |
LOGICAL EXODUS |
| 49 |
INTEGER NVARNP, NELBLK, NVAREL |
| 50 |
C --NOTE: ISEVOK is doubly-dimensioned array (NELBLK,NVAREL) |
| 51 |
LOGICAL ISEVOK(*) |
| 52 |
INTEGER NSTEPS, NSTEPW |
| 53 |
REAL A(*) |
| 54 |
INTEGER KTIMES |
| 55 |
INTEGER KWHOLE |
| 56 |
|
| 57 |
LOGICAL STOWHO, STOHIS |
| 58 |
|
| 59 |
LOGICAL WHOTIM |
| 60 |
|
| 61 |
NSTEPS = 0 |
| 62 |
NSTEPW = 0 |
| 63 |
|
| 64 |
STOWHO = ((OPTION .EQ. '*') .OR. (INDEX (OPTION, 'W') .GT. 0)) |
| 65 |
STOHIS = ((OPTION .EQ. '*') .OR. (INDEX (OPTION, 'H') .GT. 0)) |
| 66 |
|
| 67 |
IF (STOWHO .OR. STOHIS) THEN |
| 68 |
NSTOR = 0 |
| 69 |
|
| 70 |
C --Reserve memory for step times |
| 71 |
|
| 72 |
MAXMEM = MEMAMT |
| 73 |
CALL MDRSRV ('TIMES', KTIMES, MAXMEM) |
| 74 |
IF (STOWHO .AND. STOHIS) THEN |
| 75 |
CALL MDRSRV ('WHOTIM', KWHOLE, MAXMEM) |
| 76 |
END IF |
| 77 |
CALL MDSTAT (NERR, MEM) |
| 78 |
IF (NERR .GT. 0) GOTO 150 |
| 79 |
END IF |
| 80 |
|
| 81 |
IF (.NOT. EXODUS) GOTO 140 |
| 82 |
|
| 83 |
WRITE (*, 10000) 'Please wait while the step times are read in' |
| 84 |
|
| 85 |
C --Set NRECST = the number of database records in a whole time step |
| 86 |
|
| 87 |
NRECST = 1 + 1 + 1 + NVARNP |
| 88 |
DO 110 IELB = 1, NELBLK |
| 89 |
DO 100 I = 1, NVAREL |
| 90 |
IF (ISEVOK( (I-1)*NELBLK+IELB) ) THEN |
| 91 |
NRECST = NRECST + 1 |
| 92 |
END IF |
| 93 |
100 CONTINUE |
| 94 |
110 CONTINUE |
| 95 |
|
| 96 |
120 CONTINUE |
| 97 |
IF (.TRUE.) THEN |
| 98 |
|
| 99 |
C --Read step time |
| 100 |
|
| 101 |
READ (NDB, END=140, ERR=140, IOSTAT=IERR) TIME, HISTFL |
| 102 |
WHOTIM = (HISTFL .EQ. 0.0) |
| 103 |
|
| 104 |
C --Scan by variables |
| 105 |
|
| 106 |
IF (WHOTIM) THEN |
| 107 |
N = NRECST |
| 108 |
ELSE |
| 109 |
N = 2 |
| 110 |
END IF |
| 111 |
DO 130 I = 2, N |
| 112 |
READ (NDB, END=160, ERR=160, IOSTAT=IERR) |
| 113 |
130 CONTINUE |
| 114 |
|
| 115 |
IF ((STOWHO .AND. WHOTIM) .OR. |
| 116 |
& (STOHIS .AND. (.NOT. WHOTIM))) THEN |
| 117 |
|
| 118 |
C --Reserve more space for times if needed |
| 119 |
|
| 120 |
IF (NSTOR .GE. MAXMEM) THEN |
| 121 |
MAXMEM = MAXMEM + MEMAMT |
| 122 |
CALL MDLONG ('TIMES', KTIMES, MAXMEM) |
| 123 |
IF (STOWHO .AND. STOHIS) THEN |
| 124 |
CALL MDLONG ('WHOTIM', KWHOLE, MAXMEM) |
| 125 |
END IF |
| 126 |
CALL MDSTAT (NERR, MEM) |
| 127 |
IF (NERR .GT. 0) GOTO 150 |
| 128 |
END IF |
| 129 |
|
| 130 |
C --Store step time after time step read correctly |
| 131 |
|
| 132 |
A(KTIMES+NSTOR) = TIME |
| 133 |
IF (STOWHO .AND. STOHIS) THEN |
| 134 |
CALL CPYLOG (1, WHOTIM, A(KWHOLE+NSTOR)) |
| 135 |
END IF |
| 136 |
|
| 137 |
NSTOR = NSTOR + 1 |
| 138 |
END IF |
| 139 |
|
| 140 |
NSTEPS = NSTEPS + 1 |
| 141 |
IF (WHOTIM) NSTEPW = NSTEPW + 1 |
| 142 |
|
| 143 |
GOTO 120 |
| 144 |
END IF |
| 145 |
|
| 146 |
140 CONTINUE |
| 147 |
|
| 148 |
C --Shorten space reserved for step times |
| 149 |
|
| 150 |
IF (STOWHO .OR. STOHIS) THEN |
| 151 |
CALL MDLONG ('TIMES', KTIMES, NSTOR) |
| 152 |
IF (STOWHO .AND. STOHIS) THEN |
| 153 |
CALL MDLONG ('WHOTIM', KWHOLE, NSTOR) |
| 154 |
END IF |
| 155 |
CALL MDSTAT (NERR, MEM) |
| 156 |
IF (NERR .GT. 0) GOTO 150 |
| 157 |
END IF |
| 158 |
|
| 159 |
150 CONTINUE |
| 160 |
RETURN |
| 161 |
|
| 162 |
160 CONTINUE |
| 163 |
CALL PRTERR ('WARNING', 'End-of-file during time steps') |
| 164 |
RETURN |
| 165 |
10000 FORMAT (/, 1X, A) |
| 166 |
END |