| 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 LNKSTO (NAMEGV, NUMSTO, LTMENT, MERR) |
| 9 |
C======================================================================= |
| 10 |
|
| 11 |
C --*** LNKSTO *** (ALGEBRA) Assign storage for variables |
| 12 |
C -- Written by Amy Gilkey - revised 11/30/87 |
| 13 |
C -- |
| 14 |
C --LNKSTO sets up the storage locations for all the variables. |
| 15 |
C --Input and output variables of the same name share storage (unless |
| 16 |
C --one is a history/global and the other is not). Time and history/global |
| 17 |
C --variables are all in the first storage location: time is in slot 1, |
| 18 |
C --followed by the input history variables (if any), the input global |
| 19 |
C --variables (if any), then the output only history/global variables. |
| 20 |
C --IDVAR contains the slot index of the time or history/global variables. |
| 21 |
C -- |
| 22 |
C --Parameters: |
| 23 |
C -- NAMEGV - IN - the global variable names |
| 24 |
C -- NUMSTO - OUT - the number of variable storage locations needed |
| 25 |
C -- LTMENT - OUT - the number of slots in the time /globals entry |
| 26 |
C -- * - return statement if an error is found; message is printed |
| 27 |
C -- |
| 28 |
C --Common Variables: |
| 29 |
C -- Sets ISTVAR, IDVAR of /VAR../ |
| 30 |
C -- Uses NUMINP, IXLHS, NAMVAR, TYPVAR of /VAR../ |
| 31 |
C -- Uses NVARGL of /DBNUMS/ |
| 32 |
C -- Uses IHVBEG, IHVEND, IGVBEG, IGVEND of /DBXVAR/ |
| 33 |
|
| 34 |
PARAMETER (ICURTM = 1, ILSTTM = 2, IONETM = 3) |
| 35 |
include 'ag_namlen.blk' |
| 36 |
include 'ag_var.blk' |
| 37 |
include 'ag_dbnums.blk' |
| 38 |
include 'ag_dbxvar.blk' |
| 39 |
|
| 40 |
INTEGER MERR |
| 41 |
CHARACTER*(namlen) NAMEGV(*) |
| 42 |
|
| 43 |
INTEGER ISTTHG(3) |
| 44 |
|
| 45 |
MERR = 0 |
| 46 |
|
| 47 |
ccSave entry 1 for time and history/global variables |
| 48 |
C Save entry 1 for time and global variables |
| 49 |
NUMSTO = 1 |
| 50 |
|
| 51 |
C --Assign current, last and first location for all time global |
| 52 |
C --variables |
| 53 |
|
| 54 |
ISTTHG(ICURTM) = NUMSTO |
| 55 |
ISTTHG(ILSTTM) = 0 |
| 56 |
ISTTHG(IONETM) = 0 |
| 57 |
|
| 58 |
DO 110 IVAR = 1, NUMINP |
| 59 |
IF ((TYPVAR(IVAR) .EQ. 'T') |
| 60 |
& .OR. (TYPVAR(IVAR) .EQ. 'G')) THEN |
| 61 |
DO 100 ITM = 1, 3 |
| 62 |
IF (ISTVAR(ITM,IVAR) .NE. 0) THEN |
| 63 |
IF (ISTTHG(ITM) .EQ. 0) THEN |
| 64 |
NUMSTO = NUMSTO + 1 |
| 65 |
ISTTHG(ITM) = NUMSTO |
| 66 |
END IF |
| 67 |
END IF |
| 68 |
100 CONTINUE |
| 69 |
END IF |
| 70 |
110 CONTINUE |
| 71 |
|
| 72 |
DO 130 IVAR = IXLHS, MAXVAR |
| 73 |
IF ((TYPVAR(IVAR) .EQ. 'T') |
| 74 |
& .OR. (TYPVAR(IVAR) .EQ. 'G')) THEN |
| 75 |
DO 120 ITM = 1, 3 |
| 76 |
IF (ISTVAR(ITM,IVAR) .NE. 0) THEN |
| 77 |
IF (ISTTHG(ITM) .EQ. 0) THEN |
| 78 |
NUMSTO = NUMSTO + 1 |
| 79 |
ISTTHG(ITM) = NUMSTO |
| 80 |
END IF |
| 81 |
END IF |
| 82 |
120 CONTINUE |
| 83 |
END IF |
| 84 |
130 CONTINUE |
| 85 |
|
| 86 |
C --Check if any history or global variables must be input, and assign |
| 87 |
C --index in time entry |
| 88 |
|
| 89 |
c IXHV = 0 |
| 90 |
IXGV = 0 |
| 91 |
DO 140 IVAR = 1, NUMINP |
| 92 |
IF (TYPVAR(IVAR) .EQ. 'G') THEN |
| 93 |
IXGV = 1 |
| 94 |
END IF |
| 95 |
140 CONTINUE |
| 96 |
|
| 97 |
LTMENT = 1 |
| 98 |
IF (IXGV .GT. 0) THEN |
| 99 |
IXGV = LTMENT + 1 |
| 100 |
LTMENT = LTMENT + NVARGL |
| 101 |
END IF |
| 102 |
|
| 103 |
C --Reserve storage for all input variables |
| 104 |
|
| 105 |
DO 160 IVAR = 1, NUMINP |
| 106 |
C --If previous time is needed, current time must be read |
| 107 |
IF (ISTVAR(ILSTTM,IVAR) .NE. 0) ISTVAR(ICURTM,IVAR) = 1 |
| 108 |
|
| 109 |
IF ((TYPVAR(IVAR) .EQ. 'T') |
| 110 |
& .OR. (TYPVAR(IVAR) .EQ. 'G')) THEN |
| 111 |
|
| 112 |
C --Assign current and last for all time /global variables so |
| 113 |
C --current to last move is done properly |
| 114 |
|
| 115 |
IF (ISTVAR(ICURTM,IVAR) .NE. 0) THEN |
| 116 |
ISTVAR(ICURTM,IVAR) = ISTTHG(ICURTM) |
| 117 |
IF (ISTTHG(ILSTTM) .GT. 0) |
| 118 |
& ISTVAR(ILSTTM,IVAR) = ISTTHG(ILSTTM) |
| 119 |
END IF |
| 120 |
IF (ISTVAR(IONETM,IVAR) .NE. 0) |
| 121 |
& ISTVAR(IONETM,IVAR) = ISTTHG(IONETM) |
| 122 |
|
| 123 |
IF (TYPVAR(IVAR) .EQ. 'T') THEN |
| 124 |
C --TIME is in slot 1 (output time shares storage) |
| 125 |
IDVAR(IVAR) = 1 |
| 126 |
|
| 127 |
ELSE IF (TYPVAR(IVAR) .EQ. 'G') THEN |
| 128 |
|
| 129 |
C --Input globals start at assigned slot |
| 130 |
IDVAR(IVAR) = IXGV |
| 131 |
END IF |
| 132 |
|
| 133 |
ELSE |
| 134 |
|
| 135 |
C --Reserve entry for array variable for current, last, and |
| 136 |
C --first time (as needed) |
| 137 |
|
| 138 |
DO 150 ITM = 1, 3 |
| 139 |
IF (ISTVAR(ITM,IVAR) .NE. 0) THEN |
| 140 |
NUMSTO = NUMSTO + 1 |
| 141 |
ISTVAR(ITM,IVAR) = NUMSTO |
| 142 |
END IF |
| 143 |
150 CONTINUE |
| 144 |
END IF |
| 145 |
160 CONTINUE |
| 146 |
|
| 147 |
C --Reserve storage for output variables or link to input variable |
| 148 |
|
| 149 |
DO 190 IVAR = IXLHS, MAXVAR |
| 150 |
|
| 151 |
IF ((TYPVAR(IVAR) .EQ. 'T') |
| 152 |
& .OR. (TYPVAR(IVAR) .EQ. 'G')) THEN |
| 153 |
|
| 154 |
C --Assign current and last for all time / history/global variables |
| 155 |
C --so current to last move is done properly; output history/globals |
| 156 |
C --are in same entry as input history/globals |
| 157 |
|
| 158 |
IF (ISTVAR(ICURTM,IVAR) .NE. 0) THEN |
| 159 |
ISTVAR(ICURTM,IVAR) = ISTTHG(ICURTM) |
| 160 |
IF (ISTTHG(ILSTTM) .GT. 0) |
| 161 |
& ISTVAR(ILSTTM,IVAR) = ISTTHG(ILSTTM) |
| 162 |
END IF |
| 163 |
IF (ISTVAR(IONETM,IVAR) .NE. 0) |
| 164 |
& ISTVAR(IONETM,IVAR) = ISTTHG(IONETM) |
| 165 |
|
| 166 |
IF (TYPVAR(IVAR) .EQ. 'T') THEN |
| 167 |
|
| 168 |
C --Output time shares storage with input time |
| 169 |
IDVAR(IVAR) = 1 |
| 170 |
|
| 171 |
ELSE IF (TYPVAR(IVAR) .EQ. 'G') THEN |
| 172 |
|
| 173 |
C --Share slot with input global variable of the same name (if any) |
| 174 |
C --or reserve new slot |
| 175 |
|
| 176 |
IF (IXGV .GT. 0) THEN |
| 177 |
IINP = LOCSTR (NAMVAR(IVAR), NVARGL, NAMEGV) |
| 178 |
ELSE |
| 179 |
IINP = 0 |
| 180 |
END IF |
| 181 |
IF (IINP .GT. 0) THEN |
| 182 |
IDVAR(IVAR) = IINP + IXGV - 1 |
| 183 |
ELSE |
| 184 |
LTMENT = LTMENT + 1 |
| 185 |
IDVAR(IVAR) = LTMENT |
| 186 |
END IF |
| 187 |
END IF |
| 188 |
|
| 189 |
ELSE |
| 190 |
|
| 191 |
C --Share array storage with input variable of the same name (if any) |
| 192 |
C --or reserve entry for array variable |
| 193 |
|
| 194 |
IINP = LOCSTR (NAMVAR(IVAR), NUMINP, NAMVAR) |
| 195 |
IF (IINP .GT. 0) THEN |
| 196 |
IF ((TYPVAR(IINP) .EQ. 'H') |
| 197 |
& .OR. (TYPVAR(IINP) .EQ. 'G')) IINP = 0 |
| 198 |
END IF |
| 199 |
|
| 200 |
IF (IINP .LE. 0) THEN |
| 201 |
|
| 202 |
C --Reserve entry for array variable for current, last, and |
| 203 |
C --first time (as needed) |
| 204 |
|
| 205 |
DO 170 ITM = 1, 3 |
| 206 |
IF (ISTVAR(ITM,IVAR) .NE. 0) THEN |
| 207 |
NUMSTO = NUMSTO + 1 |
| 208 |
ISTVAR(ITM,IVAR) = NUMSTO |
| 209 |
END IF |
| 210 |
170 CONTINUE |
| 211 |
|
| 212 |
ELSE |
| 213 |
|
| 214 |
C --Share array storage with input variable; if either has |
| 215 |
C --current/last pair, both must have current and last so |
| 216 |
C --current to last move is done properly |
| 217 |
|
| 218 |
DO 180 ITM = 1, 3 |
| 219 |
IF ((ISTVAR(ITM,IVAR) .NE. 0) |
| 220 |
& .OR. (ISTVAR(ITM,IINP) .NE. 0)) THEN |
| 221 |
IF (ISTVAR(ITM,IINP) .EQ. 0) THEN |
| 222 |
NUMSTO = NUMSTO + 1 |
| 223 |
ISTVAR(ITM,IVAR) = NUMSTO |
| 224 |
IF (ITM .NE. IONETM) ISTVAR(ITM,IINP) = NUMSTO |
| 225 |
ELSE |
| 226 |
ISTVAR(ITM,IVAR) = ISTVAR(ITM,IINP) |
| 227 |
END IF |
| 228 |
END IF |
| 229 |
180 CONTINUE |
| 230 |
END IF |
| 231 |
END IF |
| 232 |
190 CONTINUE |
| 233 |
|
| 234 |
C --Fix up variables which request the first time but not the current time |
| 235 |
C --by changing the current storage location to the first storage location |
| 236 |
C --negated |
| 237 |
|
| 238 |
DO 200 IVAR = 1, NUMINP |
| 239 |
IF ((ISTVAR(ICURTM,IVAR) .EQ. 0) |
| 240 |
& .AND. (ISTVAR(IONETM,IVAR) .NE. 0)) THEN |
| 241 |
ISTVAR(ICURTM,IVAR) = - ISTVAR(IONETM,IVAR) |
| 242 |
END IF |
| 243 |
200 CONTINUE |
| 244 |
|
| 245 |
RETURN |
| 246 |
END |