| 1 |
C Copyright(C) 1999-2025 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 |
C======================================================================= |
| 7 |
PROGRAM ALGEBRA2 |
| 8 |
C======================================================================= |
| 9 |
|
| 10 |
C --This version of ALGEBRA will read and write EXODUSIIV2 database |
| 11 |
C --format files. Many changes have occurred since the first version |
| 12 |
C --of ALGEBRA. The original database files, genesis and exodusI |
| 13 |
C --were sequential access files. EXODUSIIV2 uses a random access |
| 14 |
C --file format. Previous versions of ALGEBRA would have to read the |
| 15 |
C --input database more than once in order to get the file pointer |
| 16 |
C --to the desired data. With random access files we are able to |
| 17 |
C --select what we want to read or write at anytime. |
| 18 |
|
| 19 |
C *** ALGEBRA 2.02 *** |
| 20 |
C --*** ALGEBRA *** (ALGEBRA) Algebraic Database Manipulation Program |
| 21 |
C -- |
| 22 |
C --The ALGEBRA program allows the user to process data from a finite |
| 23 |
C --element analysis before it is plotted. The finite element output |
| 24 |
C --data is in the form of variable values (stress, strain, and |
| 25 |
C --velocity components, etc.) in an EXODUS database. The ALGEBRA program |
| 26 |
C --evaluates user-supplied functions of the data and writes the results |
| 27 |
C --to an output EXODUS database which can be read by plot programs. |
| 28 |
C -- |
| 29 |
include 'exodusII.inc' |
| 30 |
include 'ag_namlen.blk' |
| 31 |
|
| 32 |
C max_num_equation, max_parsed_entries |
| 33 |
include 'ag_numeqn.blk' |
| 34 |
C QAINFO array with program information |
| 35 |
include 'ag_progqa.blk' |
| 36 |
C input equation info |
| 37 |
include 'ag_ent.blk' |
| 38 |
C input variable info |
| 39 |
include 'ag_var.blk' |
| 40 |
C aliases |
| 41 |
include 'ag_alias.blk' |
| 42 |
C I/O file names |
| 43 |
include 'ag_dbase.blk' |
| 44 |
C I/O database titles |
| 45 |
include 'ag_dbtitl.blk' |
| 46 |
C num_of: nodes,elements,coordinated/node,element_blks |
| 47 |
C num_of: history,global,nodal,element variables, num_of_time_steps |
| 48 |
include 'ag_dbnums.blk' |
| 49 |
C node set/side sets number,length,dist factor |
| 50 |
include 'ag_dbnumg.blk' |
| 51 |
C database type, num_of qa and info records |
| 52 |
include 'ag_dbnumq.blk' |
| 53 |
C num_of: nodes,elements,element blks,node_sets,side_sets in zoom mesh |
| 54 |
C num_of: output history,global,nodal,element variables |
| 55 |
include 'ag_dbout.blk' |
| 56 |
C time_index, I_index/O_index for history,global,nodal and element vars |
| 57 |
include 'ag_dbxvar.blk' |
| 58 |
C time variables |
| 59 |
include 'ag_times.blk' |
| 60 |
C zoom info |
| 61 |
include 'ag_zoom.blk' |
| 62 |
C function variables |
| 63 |
include 'ag_fnctbc.blk' |
| 64 |
C equation line error messages |
| 65 |
include 'ag_eqnlns.blk' |
| 66 |
C floating point byte size |
| 67 |
include 'ag_dbws.blk' |
| 68 |
include 'argparse.inc' |
| 69 |
|
| 70 |
C Input/Output File Arguments |
| 71 |
C CPUWS - The word size in bytes of the floating point variables |
| 72 |
C used in the application program |
| 73 |
C IOWS - The word size in bytes of the floating point data as they |
| 74 |
C are stored in the EXODUS II file |
| 75 |
C IERR - error code |
| 76 |
C VERS - version number of database |
| 77 |
C NERR - error flag for dynamic memory errors |
| 78 |
C MERR - memory error flag |
| 79 |
C IOERR - Input/output error flag |
| 80 |
C INTEGER CPUWS, IOWS, IERR, NERR, CERR, MERR |
| 81 |
INTEGER IERR, NERR, CERR, MERR |
| 82 |
REAL VERS |
| 83 |
LOGICAL MEMBUG |
| 84 |
CHARACTER*2048 FILNAM, SCRATCH |
| 85 |
character*256 option, value |
| 86 |
|
| 87 |
CHARACTER*8 STR8 |
| 88 |
|
| 89 |
C A - the dynamic memory base array |
| 90 |
DIMENSION A(1) |
| 91 |
CHARACTER*1 C(1) |
| 92 |
|
| 93 |
C Logical variables that indicate whether an input/output |
| 94 |
C file is open. These variable are use during exit of the |
| 95 |
C program in hopes to cut down on the multitude of goto labels |
| 96 |
C while exiting the program |
| 97 |
LOGICAL INOPEN, OTOPEN |
| 98 |
|
| 99 |
C Executable code in qainfo.blk |
| 100 |
include 'ag_qainfo.blk' |
| 101 |
|
| 102 |
INOPEN = .FALSE. |
| 103 |
OTOPEN = .FALSE. |
| 104 |
MEMBUG = .FALSE. |
| 105 |
MERR = 0 |
| 106 |
IOERR = 0 |
| 107 |
|
| 108 |
CALL STRTUP (QAINFO) |
| 109 |
CALL BANNR2 (80, QAINFO(1), 0) |
| 110 |
CALL BANNER (0, QAINFO, |
| 111 |
& 'AN ALGEBRAIC MANIPULATION PROGRAM', |
| 112 |
& 'FOR POST-PROCESSING OF FINITE ELEMENT ANALYSES', |
| 113 |
& 'EXODUS II VERSION') |
| 114 |
CALL CPYRGT (0, '2008') |
| 115 |
WRITE(*,*) |
| 116 |
|
| 117 |
C Set compute and file float size to default values |
| 118 |
C values located in dbws.blk |
| 119 |
CPUWS=0 |
| 120 |
IOWS=0 |
| 121 |
|
| 122 |
IF (MEMBUG) THEN |
| 123 |
CALL MLIST() |
| 124 |
END IF |
| 125 |
|
| 126 |
C Input and Output File ID's |
| 127 |
C See Algebra script for more details |
| 128 |
C dbase.blk: COMMON /DBASE/ NDBIN, NDBOUT |
| 129 |
NDBIN = 11 |
| 130 |
NDBOUT = 12 |
| 131 |
|
| 132 |
C Open the log file - temporary file unless the user decides to save it |
| 133 |
NLOG = 99 |
| 134 |
CALL OPNLOG (NLOG) |
| 135 |
|
| 136 |
C .. Get filename from command line. If not specified, emit error message |
| 137 |
NARG = argument_count() |
| 138 |
if (narg .lt. 2) then |
| 139 |
CALL PRTERR ('FATAL', 'Filenames not specified.') |
| 140 |
CALL PRTERR ('CMDSPEC', |
| 141 |
* 'Syntax is: "algebra [-change_set #] file_in file_out"') |
| 142 |
CALL PRTERR ('CMDSPEC', |
| 143 |
* 'Documentation: https://sandialabs.github.io' // |
| 144 |
$ '/seacas-docs/sphinx/html/index.html#algebra') |
| 145 |
GOTO 150 |
| 146 |
end if |
| 147 |
|
| 148 |
C Open the input database; Exit on error |
| 149 |
CALL get_argument(narg - 1,FILNAM, LFIL) |
| 150 |
ndbin = exopen(filnam(:lfil), EXREAD, cpuws, iows, |
| 151 |
& vers, ierr) |
| 152 |
IF (IERR .NE. 0) THEN |
| 153 |
SCRATCH = 'Database "'//FILNAM(:LFIL)//'" does not exist.' |
| 154 |
CALL PRTERR ('FATAL', SCRATCH(:LENSTR(SCRATCH))) |
| 155 |
GOTO 150 |
| 156 |
END IF |
| 157 |
|
| 158 |
if (narg .gt. 2) then |
| 159 |
do i=1, narg-2, 2 |
| 160 |
CALL get_argument(i+0,option, lo) |
| 161 |
CALL get_argument(i+1,value, lv) |
| 162 |
if (option(:lo) .eq. '-change_set' .or. |
| 163 |
* option(:lo) .eq. '--change_set') then |
| 164 |
C ... Convert `value` to an integer. |
| 165 |
read (value(:lv), '(i10)') nchange |
| 166 |
C ... Check that file contains at least that many change sets... |
| 167 |
ndbr = iand(ndbin, EX_FILE_ID_MASK) |
| 168 |
call exinq(ndbr, EX_INQ_NUM_CHILD_GROUPS, |
| 169 |
$ idum, rdum, cdum, ierr) |
| 170 |
if (nchange .gt. idum) then |
| 171 |
write (SCRATCH,*) 'Selected change set', nchange, |
| 172 |
$ 'but there are only ', idum, ' change sets in file.' |
| 173 |
call sqzstr(scratch, lscratch) |
| 174 |
call PRTERR('CMDERR', SCRATCH(:LSCRATCH)) |
| 175 |
goto 150 |
| 176 |
else |
| 177 |
ndbin = ndbr + nchange |
| 178 |
write (scratch,99) nchange |
| 179 |
99 format(1x,'NOTE: Selecting change set ', i3) |
| 180 |
call sqzstr(scratch, lscratch) |
| 181 |
call PRTERR('CMDSPEC', scratch(:lscratch)) |
| 182 |
end if |
| 183 |
end if |
| 184 |
end do |
| 185 |
end if |
| 186 |
|
| 187 |
call exinq(ndbin, EXDBMXUSNM, namlen, rdum, cdum, ierr) |
| 188 |
call exmxnm(ndbin, namlen, ierr) |
| 189 |
|
| 190 |
INOPEN = .TRUE. |
| 191 |
|
| 192 |
C Initialize the Memory Manager |
| 193 |
CALL MDINIT (A) |
| 194 |
c CALL MDFILL(0) |
| 195 |
CALL MCINIT (C) |
| 196 |
CALL MDSTAT (NERR, MEM) |
| 197 |
IF (NERR .GT. 0) THEN |
| 198 |
C Report dynamic memory error |
| 199 |
CALL MEMERR |
| 200 |
C Goto WRAPUP call and exit program |
| 201 |
GOTO 150 |
| 202 |
END IF |
| 203 |
|
| 204 |
C Read the initial parameters from the database |
| 205 |
C ndbin - file ID (input) |
| 206 |
C title - title of input file dbtitl.blk |
| 207 |
C ndim - number of coordinates per node dbnums.blk |
| 208 |
C numnp - number of nodes dbnums.blk |
| 209 |
C numel - number of elements dbnums.blk |
| 210 |
C nelblk - number of element blocks dbnums.blk |
| 211 |
C numnps - number of node sets dbnumg.blk |
| 212 |
C numess - number of side sets dbnumg.blk |
| 213 |
C ioerr - error code |
| 214 |
C dbase.blk, dbtitl.blk, dbnums.blk, dbnumg.blk |
| 215 |
CALL EXGINI(NDBIN, TITLE, NDIM, NUMNP, NUMEL, NELBLK, |
| 216 |
& NUMNPS, NUMESS, IERR) |
| 217 |
|
| 218 |
C if number of node sets > 0, gather node set information dbnumg.blk |
| 219 |
if (numnps .gt. 0) then |
| 220 |
C EXNSNL - request the length of the node set node list. |
| 221 |
CALL EXINQ (NDBIN, EXNSNL, LNPSNL, RDUM, CDUM, IERR) |
| 222 |
C EXNSDF - request the length of the node sets distribution factors list |
| 223 |
CALL EXINQ (NDBIN, EXNSDF, LNPSDF, RDUM, CDUM, IERR) |
| 224 |
else |
| 225 |
lnpsnl = 0 |
| 226 |
lnpsdf = 0 |
| 227 |
end if |
| 228 |
|
| 229 |
C if number of side sets > 0, gather side set information dbnumg.blk |
| 230 |
if (numess .gt. 0) then |
| 231 |
C EXSSNL request length of the side set node list |
| 232 |
CALL EXINQ (NDBIN, EXSSNL, LESSNL, RDUM, CDUM, IERR) |
| 233 |
C EXSSEL request the length of the side sets element list. |
| 234 |
CALL EXINQ (NDBIN, EXSSEL, LESSEL, RDUM, CDUM, IERR) |
| 235 |
C EXSSDF request the length of the side set distribution factors list |
| 236 |
CALL EXINQ (NDBIN, EXSSDF, LESSDF, RDUM, CDUM, IERR) |
| 237 |
else |
| 238 |
lessnl = 0 |
| 239 |
lessel = 0 |
| 240 |
lessdf = 0 |
| 241 |
end if |
| 242 |
|
| 243 |
C Title of output db = title of input db dbtitl.blk |
| 244 |
TITLEO = TITLE |
| 245 |
|
| 246 |
C Print the database filename, title, and db initial variables |
| 247 |
C Cannot print global, element, or nodal info. Data has not |
| 248 |
C been read from the input database yet. |
| 249 |
CALL DBPINI ('TIS', NDBIN, TITLE, NDIM, NUMNP, NUMEL, NELBLK, |
| 250 |
& NUMNPS, LNPSNL, LNPSDF, NUMESS, LESSEL, |
| 251 |
& LESSDF, IDUM, IDUM, IDUM, ' ') |
| 252 |
|
| 253 |
cccc DBLIST uses MDFIND to locate NUMELB, NUMLNK, NUMATR |
| 254 |
cccc Scan the connectivity to get the element block IDs |
| 255 |
cccc Read element block connectivity |
| 256 |
|
| 257 |
C call MxRSRV(array_name, ret_array_index, array_size) |
| 258 |
C IDELB: Element block ID's for each block |
| 259 |
CALL MDRSRV ('IDELB', KIDELB, NELBLK) |
| 260 |
C NUMELB: Number of elements in each block |
| 261 |
CALL MDRSRV ('NUMELB', KNELB, NELBLK) |
| 262 |
C NUMLNK: Number of nodes per element in each block |
| 263 |
CALL MDRSRV ('NUMLNK', KNLNK, NELBLK) |
| 264 |
C NUMATR: Number of attributes in each block |
| 265 |
CALL MDRSRV ('NUMATR', KNATR, NELBLK) |
| 266 |
C VISELB(i) = True iff element block i is to be written |
| 267 |
CALL MDRSRV ('VISELB', KVISEB, NELBLK) |
| 268 |
C BLKTYP: Element type |
| 269 |
CALL MCRSRV ('BLKTYP', KNMLB, NELBLK * MXSTLN) |
| 270 |
C Reserving space for the element block connectivity arrays |
| 271 |
CALL MDRSRV ('LINK', KLINK, 0) |
| 272 |
C Reserving space for the element block attributes |
| 273 |
CALL MDRSRV ('ATRIB', KATRIB, 0) |
| 274 |
C Check for dynamic memory errors |
| 275 |
CALL MDSTAT (NERR, MEM) |
| 276 |
CALL MCSTAT (CERR, MEM) |
| 277 |
IF ((NERR .GT. 0) .OR. (CERR .GT. 0)) THEN |
| 278 |
CALL MEMERR |
| 279 |
GOTO 130 |
| 280 |
END IF |
| 281 |
|
| 282 |
C DBIELB reads and returns the following: |
| 283 |
C 1. Element block ID's |
| 284 |
C 2. Element type in each element block |
| 285 |
C 3. Number of elements in each element block |
| 286 |
C 4. Number of nodes per element in each element block |
| 287 |
C 5. Number of attributes per element in each element block |
| 288 |
C 6. If Option = A or * -> element block attributes |
| 289 |
C 7. If Option = C or * -> element block connectivity |
| 290 |
C 8. If Option = H or * -> read all header information |
| 291 |
C 9. If Option = I or * -> read the element block ID's |
| 292 |
C Note: Element block ID's must be read for all options |
| 293 |
C DBIELB reads the element block information from the database. |
| 294 |
C An error message is displayed if the end of file is read. |
| 295 |
CALL DBIELB (NDBIN, '*', 1, NELBLK, A(KIDELB), A(KNELB), |
| 296 |
& A(KNLNK), A(KNATR), C(KNMLB), A, IELNK, IEATR, MERR) |
| 297 |
C Exit program on memory error |
| 298 |
IF (MERR .EQ. 1) GO TO 130 |
| 299 |
|
| 300 |
C QA and Information record number stored in dbnumq.blk |
| 301 |
C Request the number of QA records. Return the value |
| 302 |
C as an integer in nqarec |
| 303 |
CALL EXINQ (NDBIN, EXQA, NQAREC, RDUM, CDUM, IERR) |
| 304 |
C Request the number of information records. Return the |
| 305 |
C value as an integer in ninfo |
| 306 |
CALL EXINQ (NDBIN, EXINFO, NINFO, RDUM, CDUM, IERR) |
| 307 |
|
| 308 |
C Reserve contiguous block space for arrays QA and information records |
| 309 |
C Reserve nqarec for input file + 1 for the current run |
| 310 |
CALL MCGET(((nqarec+1)*4*MXSTLN) + (ninfo*MXLNLN)) |
| 311 |
C Reserve space to read the QA and information records |
| 312 |
call MCRSRV('QAREC', kqarec, (nqarec+1) * 4 * MXSTLN) |
| 313 |
call MCRSRV('INFREC', kinfo, ninfo * MXLNLN) |
| 314 |
CALL MCSTAT (NERR, MEM) |
| 315 |
IF (NERR .GT. 0) THEN |
| 316 |
CALL MEMERR |
| 317 |
GOTO 130 |
| 318 |
END IF |
| 319 |
|
| 320 |
C Read the QA and Information Records |
| 321 |
CALL DBIQA(NDBIN, '*', NQAREC, C(KQAREC), NINFO, C(KINFO)) |
| 322 |
|
| 323 |
C Read the number of global, node, and element variables |
| 324 |
C Read number of global variables = nvargl |
| 325 |
call exgvp(ndbin, 'G', nvargl, ierr) |
| 326 |
|
| 327 |
C Read number of nodal variables = nvarnp |
| 328 |
call exgvp(ndbin, 'N', nvarnp, ierr) |
| 329 |
|
| 330 |
C Read number of element variables = nvarel |
| 331 |
call exgvp(ndbin, 'E', nvarel, ierr) |
| 332 |
|
| 333 |
C Reserve memory for coordinate array names |
| 334 |
CALL MCRSRV ('NAMECO', KNACOR, namlen*NDIM) |
| 335 |
C Reserve memory for global, node, and element variable |
| 336 |
CALL MCRSRV ('NAMES', KNAMES, namlen*(NVARGL+NVARNP+NVAREL)) |
| 337 |
C Reserve memory for element variable truth table |
| 338 |
CALL MDRSRV ('ISEVOK', KIEVOK, NELBLK * NVAREL) |
| 339 |
C Temporary storage |
| 340 |
CALL MDRSRV ('ITMP', KITMP, NELBLK * NVAREL) |
| 341 |
CALL MCSTAT (CERR, MEM) |
| 342 |
CALL MDSTAT (NERR, MEM) |
| 343 |
IF ((NERR .GT. 0) .OR. (CERR .GT. 0)) THEN |
| 344 |
CALL MEMERR |
| 345 |
MERR = 1 |
| 346 |
GOTO 130 |
| 347 |
END IF |
| 348 |
|
| 349 |
C Read the coordinate names |
| 350 |
CALL DBICON (NDBIN, NDIM, C(KNACOR)) |
| 351 |
IF (IOERR .EQ. 1) GO TO 130 |
| 352 |
|
| 353 |
C Read the names of the global, node, and element variables |
| 354 |
CALL DBINAM (NDBIN, C, C(KNAMES), NVARGL, NVARNP, NVAREL, |
| 355 |
& KNAMGV, KNAMNV, KNAMEV, MAXVAR) |
| 356 |
|
| 357 |
C Print database variable names |
| 358 |
C call dbpnam (option, num_glb_var, num_nod_var, num_elem_var, |
| 359 |
C glb_var_names, nod_var_names, elem_var_names) |
| 360 |
CALL DBPNAM ('*', NVARGL, NVARNP, NVAREL, |
| 361 |
& C(KNAMES+NAMLEN*(KNAMGV-1)), |
| 362 |
& C(KNAMES+NAMLEN*(KNAMNV-1)), |
| 363 |
& C(KNAMES+NAMLEN*(KNAMEV-1))) |
| 364 |
|
| 365 |
C Read the element variable truth table |
| 366 |
CALL DBIVTT (NDBIN, A(KIEVOK), A(KITMP), NELBLK, NVAREL) |
| 367 |
|
| 368 |
C Delete temporary dynamic memory |
| 369 |
CALL MDDEL('ITMP') |
| 370 |
CALL MDSTAT (NERR, MEM) |
| 371 |
if (NERR .GT. 0) then |
| 372 |
CALL MEMERR |
| 373 |
merr = 1 |
| 374 |
GO TO 130 |
| 375 |
end if |
| 376 |
|
| 377 |
C Request the number of time steps from the database |
| 378 |
CALL EXINQ (NDBIN, EXTIMS, NSTEPS, RDUM, CDUM, IERR) |
| 379 |
C Reserve memory to hold the time step values |
| 380 |
C Reserve memory for step times |
| 381 |
CALL MDRSRV ('TIMES', KTIMES, max(1,NSTEPS)) |
| 382 |
CALL MDSTAT (NERR, MEM) |
| 383 |
IF (NERR .GT. 0) THEN |
| 384 |
CALL MEMERR |
| 385 |
MERR = 1 |
| 386 |
GO TO 130 |
| 387 |
END IF |
| 388 |
if (nsteps .gt. 0) then |
| 389 |
CALL EXGATM(NDBIN, A(KTIMES), IERR) |
| 390 |
else |
| 391 |
C Add a dummy step at time 0 in case user is trying to add a new step |
| 392 |
A(KTIMES) = 0.0 |
| 393 |
END IF |
| 394 |
|
| 395 |
C Displays the number of time steps and the minimum and |
| 396 |
C maximum time on the database |
| 397 |
C 'NM' Print the number of time steps and the minimum and |
| 398 |
C maximum time step times |
| 399 |
C NSTEPS The number of time steps |
| 400 |
C A(KTIMES) The database time steps |
| 401 |
CALL DBPTIM ('NM', NSTEPS, A(KTIMES)) |
| 402 |
|
| 403 |
C Selected time steps |
| 404 |
CALL MDRSRV ('IPTIMS', KPTIMS, MAX(1,NSTEPS)) |
| 405 |
C selected element blocks |
| 406 |
CALL MDRSRV ('SELELB', KSELEB, NELBLK) |
| 407 |
CALL MDSTAT (NERR, MEM) |
| 408 |
IF (NERR .GT. 0) THEN |
| 409 |
CALL MEMERR |
| 410 |
MERR = 1 |
| 411 |
GOTO 130 |
| 412 |
END IF |
| 413 |
|
| 414 |
C ... See if the input database has any nodeset or sideset variables. |
| 415 |
C If there are any, then output a warning message telling the user |
| 416 |
C that these are not supported in algebra and will be stripped from |
| 417 |
C output file. |
| 418 |
call exgvp(ndbin, 'M', nvarns, ierr) |
| 419 |
call exgvp(ndbin, 'S', nvarss, ierr) |
| 420 |
if (nvarns .gt. 0) then |
| 421 |
CALL PRTERR('WARNING', |
| 422 |
$ 'The Input Database contains NODESET VARIABLES') |
| 423 |
CALL PRTERR('CMDSPEC', |
| 424 |
$ ' NODESET VARIABLES are not supported by algebra') |
| 425 |
CALL PRTERR('CMDSPEC', |
| 426 |
$ ' These will NOT be saved to the output database') |
| 427 |
end if |
| 428 |
if (nvarss .gt. 0) then |
| 429 |
CALL PRTERR('WARNING', |
| 430 |
$ 'The Input Database contains SIDESET VARIABLES') |
| 431 |
CALL PRTERR('CMDSPEC', |
| 432 |
$ ' SIDESET VARIABLES are not supported by algebra') |
| 433 |
CALL PRTERR('CMDSPEC', |
| 434 |
$ ' These will NOT be saved to the output database') |
| 435 |
end if |
| 436 |
|
| 437 |
C Read in the equations |
| 438 |
C call rdeqns(DMarray, DCarray, coord_names, elem_names, db_var_names, |
| 439 |
C qa_rec, info_rec, db_time_step, select_time_step, |
| 440 |
C elem_blk_ids, TRUE_IFF_elem(i)_written, DMindex_ISEVOK, |
| 441 |
C max_stack_size, return_if_quit) |
| 442 |
|
| 443 |
CALL RDEQNS (A, C, C(KNACOR), C(KNMLB), C(KNAMES), C(KQAREC), |
| 444 |
& C(KINFO), A(KTIMES), A(KPTIMS), A(KSELEB), |
| 445 |
& A(KIDELB), A(KVISEB), KIEVOK, MAXSTK, NLOG, MERR) |
| 446 |
IF (MERR .EQ. 1) GO TO 130 |
| 447 |
|
| 448 |
C RDEQNS processes the input equations as follows: |
| 449 |
C o Reads the line and parses it into fields. |
| 450 |
C o Checks the equation for syntax. |
| 451 |
C o Stores the variable names from the equations. |
| 452 |
C o Puts the equation in postfix form. |
| 453 |
C o Adds the equation variables to a global list. |
| 454 |
C If any errors are found, that equation is ignored. |
| 455 |
C After all the equations have been read in, all the variables are |
| 456 |
C gathered into the /VAR../ arrays. The assigned variables are |
| 457 |
C after the expression variables. |
| 458 |
|
| 459 |
C Sort the input variables (by ID) |
| 460 |
C SORTID gathers the variables of the specified type into |
| 461 |
C one area of an array and orders these variable |
| 462 |
ITIME = 1 |
| 463 |
CALL SORTID ('T', NUMINP, ITIME, I) |
| 464 |
ICOBEG = ITIME + 1 |
| 465 |
CALL SORTID ('C', NUMINP, ICOBEG, ICOEND) |
| 466 |
IGVBEG = ICOEND + 1 |
| 467 |
CALL SORTID ('G', NUMINP, IGVBEG, IGVEND) |
| 468 |
INVBEG = IGVEND + 1 |
| 469 |
CALL SORTID ('N', NUMINP, INVBEG, INVEND) |
| 470 |
IEVBEG = INVEND + 1 |
| 471 |
CALL SORTID ('E', NUMINP, IEVBEG, IEVEND) |
| 472 |
|
| 473 |
C Set the ID to the order in which the LHS variables were defined |
| 474 |
NLHS = 1 |
| 475 |
DO 100 I = MAXVAR, IXLHS, -1 |
| 476 |
IDVAR(I) = NLHS |
| 477 |
NLHS = NLHS + 1 |
| 478 |
100 CONTINUE |
| 479 |
|
| 480 |
C Sort deleted variables to end of entries |
| 481 |
C SORDEL sorts the deleted variables so that they appear at the start |
| 482 |
C of all non-deleted entries. |
| 483 |
CALL SORDEL (MAXVAR, IXLHS, I) |
| 484 |
JTIME = I + 1 |
| 485 |
|
| 486 |
C Sort the LHS variables in the order defined |
| 487 |
CALL SORTID ('T', MAXVAR, JTIME, I) |
| 488 |
JGVBEG = I + 1 |
| 489 |
CALL SORTID ('G', MAXVAR, JGVBEG, JGVEND) |
| 490 |
JNVBEG = JGVEND + 1 |
| 491 |
CALL SORTID ('N', MAXVAR, JNVBEG, JNVEND) |
| 492 |
JEVBEG = JNVEND + 1 |
| 493 |
CALL SORTID ('E', MAXVAR, JEVBEG, JEVEND) |
| 494 |
NVARGO = JGVEND - JGVBEG + 1 |
| 495 |
NVARNO = JNVEND - JNVBEG + 1 |
| 496 |
NVAREO = JEVEND - JEVBEG + 1 |
| 497 |
|
| 498 |
C Link the variables with storage |
| 499 |
C Assign storage for variables |
| 500 |
C LNKSTO sets up the storage locations for all the variables. |
| 501 |
C Input and output variables of the same name share storage (unless |
| 502 |
C one is a history/global and the other is not). Time and history/global |
| 503 |
C variables are all in the first storage location: time is in slot 1, |
| 504 |
C followed by the input history variables (if any), the input global |
| 505 |
C variables (if any), then the output only history/global variables. |
| 506 |
CALL LNKSTO (C(KNAMES+NAMLEN*(KNAMGV-1)), NUMSTO, LTMENT, IOERR) |
| 507 |
IF (IOERR .EQ. 1) GO TO 130 |
| 508 |
|
| 509 |
C LNKFNC sets up the storage locations for the time functions that |
| 510 |
C need storage for results that must be saved over time steps. |
| 511 |
CALL LNKFNC (NUMSTO, *130) |
| 512 |
|
| 513 |
C Relink the equation variables with the sorted name array |
| 514 |
CALL LNKVAR (*130) |
| 515 |
|
| 516 |
C Check displacement variables |
| 517 |
IF ((NVARNP .GT. 0) .OR. (NVARNO .GT. 0)) THEN |
| 518 |
C CHKDIS finds the displacement variables. The first two/three nodal |
| 519 |
C variables are displacement variables if and only if they begin with |
| 520 |
C 'D' and end with the last character of the corresponding coordinate |
| 521 |
C name. |
| 522 |
CALL CHKDIS (NDIM, C(KNACOR), NVARNO, NAMVAR(JNVBEG), |
| 523 |
* namlen, maxnam) |
| 524 |
END IF |
| 525 |
|
| 526 |
C ************************************************************* |
| 527 |
C Open the Output Database |
| 528 |
C ************************************************************* |
| 529 |
CALL get_argument(narg,FILNAM, LFIL) |
| 530 |
ndbout = excre(filnam(:lfil), EXCLOB, CPUWS, IOWS, IERR) |
| 531 |
IF (IERR .NE. 0) THEN |
| 532 |
SCRATCH = 'Problems creating database "'//FILNAM(:LFIL)//'".' |
| 533 |
CALL PRTERR ('FATAL', SCRATCH(:LENSTR(SCRATCH))) |
| 534 |
goto 130 |
| 535 |
END IF |
| 536 |
OTOPEN = .TRUE. |
| 537 |
call exmxnm(ndbout, namlen, ierr) |
| 538 |
|
| 539 |
C RWEVAL reads the unread information from the input database, |
| 540 |
C processes the data for zoom mesh, and write the output database. |
| 541 |
|
| 542 |
CALL RWEVAL (NDBIN, NDBOUT, A, A, C, NPTIMS, |
| 543 |
& NUMSTO, LTMENT, MAXSTK, NWRIT, IOERR, MERR) |
| 544 |
IF ((IOERR .EQ. 1) .OR. (MERR .EQ. 1)) GO TO 130 |
| 545 |
|
| 546 |
if (numsto .gt. 1 .and. nsteps .eq. 0) then |
| 547 |
nsteps = 1 |
| 548 |
nwrit = 1 |
| 549 |
end if |
| 550 |
|
| 551 |
CALL MDSTAT (NERR, MEM) |
| 552 |
IF (NERR .GT. 0) THEN |
| 553 |
CALL MEMERR |
| 554 |
END IF |
| 555 |
|
| 556 |
C Converts a set of integer numbers into a consistent |
| 557 |
C set of strings of the same length (right justified) |
| 558 |
CALL INTSTR (1, 0, NWRIT, STR8, LSTR) |
| 559 |
WRITE (*, 10000) STR8(:LSTR) |
| 560 |
10000 FORMAT (/, 4X, A, |
| 561 |
& ' time steps have been written to the database') |
| 562 |
|
| 563 |
130 CONTINUE |
| 564 |
|
| 565 |
call mddel ('IDELB') |
| 566 |
CALL MDDEL ('NUMELB') |
| 567 |
CALL MDDEL ('VISELB') |
| 568 |
CALL MCDEL ('BLKTYP') |
| 569 |
CALL MDDEL ('SELELB') |
| 570 |
CALL MDDEL ('TIMES') |
| 571 |
CALL MDDEL ('IPTIMS') |
| 572 |
CALL MCDEL ('NAMECO') |
| 573 |
CALL MCDEL ('NAMES') |
| 574 |
CALL MDDEL ('ISEVOK') |
| 575 |
|
| 576 |
CALL MDSTAT (NERR, MEM) |
| 577 |
IF (NERR .GT. 0) THEN |
| 578 |
CALL MEMERR |
| 579 |
END IF |
| 580 |
|
| 581 |
150 continue |
| 582 |
C Exiting programs - close input/output files if they are open |
| 583 |
C or even if they opened and may have an error |
| 584 |
IF (INOPEN) CALL exclos(NDBIN, IERR) |
| 585 |
|
| 586 |
IF (OTOPEN) CALL exclos(NDBOUT, IERR) |
| 587 |
|
| 588 |
C Performs finishing details common to all programs. |
| 589 |
C Specifically, it gets and displays the CPU time used. |
| 590 |
|
| 591 |
call addlog (QAINFO(1)(:lenstr(QAINFO(1)))) |
| 592 |
CALL WRAPUP (QAINFO(1)) |
| 593 |
|
| 594 |
END |