| 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 |
C======================================================================= |
| 7 |
SUBROUTINE WELB (NDBOUT, NELBLK, VISELB, ALLELE, BLKTYP, |
| 8 |
& NUMLNK, NUMATR, LINK, ATRIB, NUMELB, IXELB, IXELBO, |
| 9 |
& IXELEM, NEWNOD, NODIX, IDELB, A, IA, C, MERR) |
| 10 |
C======================================================================= |
| 11 |
|
| 12 |
C --The original version of this code was written by |
| 13 |
C --Amy Gilkey - revised 04/19/88 |
| 14 |
C --*** RWELB *** (ALGEBRA) Read and write database element blocks |
| 15 |
C --RWELB was modified and renamed to WELB 8/25/95 |
| 16 |
C -- |
| 17 |
C --WELB writes the element block information to the database. |
| 18 |
C --Deleted elements are removed and nodes are renumbered. |
| 19 |
C -- |
| 20 |
C --Parameters: |
| 21 |
C -- NDBOUT - IN - the output database file |
| 22 |
C -- NELBLK - IN - the number of element blocks |
| 23 |
C -- VISELB - IN - true iff element block i is to be written |
| 24 |
C -- ALLELE - IN - true iff all elements are selected |
| 25 |
C -- BLKTYP - IN - element type for each element block |
| 26 |
C -- NUMLNK - IN - Number of nodes per element for each element block |
| 27 |
C -- NUMATR - IN - Number of attributes for each element block |
| 28 |
C -- LINK - IN - Connectivity array for element blocks |
| 29 |
C -- ATRIB - IN - Attribute array for element blocks |
| 30 |
C -- NUMELB - I/O - the number of elements in each block; set if ALLELE |
| 31 |
C -- IXELB - I/O - the cumulative element counts for each |
| 32 |
C -- element block; set if ALLELE |
| 33 |
C -- IXELBO - I/O - the cumulative element counts for each output block; |
| 34 |
C -- set if ALLELE |
| 35 |
C -- IXELEM - IN - the indices of the output elements |
| 36 |
C -- (iff IXELBO <> IXELB) |
| 37 |
C -- NEWNOD - IN - true iff nodes are renumbered |
| 38 |
C -- NODIX(i) - IN - the zoom mesh index for each node (iff NEWNOD) |
| 39 |
C -- A - IN - the dynamic memory array |
| 40 |
C -- MERR - OUT - memory error flag |
| 41 |
|
| 42 |
include 'exodusII.inc' |
| 43 |
|
| 44 |
INTEGER NDBOUT |
| 45 |
INTEGER NELBLK |
| 46 |
LOGICAL VISELB(NELBLK) |
| 47 |
LOGICAL ALLELE |
| 48 |
CHARACTER*(MXSTLN) BLKTYP(*) |
| 49 |
INTEGER NUMLNK(*) |
| 50 |
INTEGER NUMATR(*) |
| 51 |
INTEGER LINK(*) |
| 52 |
REAL ATRIB(*) |
| 53 |
INTEGER NUMELB(*) |
| 54 |
INTEGER IXELB(0:NELBLK) |
| 55 |
INTEGER IXELBO(0:NELBLK) |
| 56 |
INTEGER IXELEM(*) |
| 57 |
LOGICAL NEWNOD |
| 58 |
INTEGER NODIX(*) |
| 59 |
INTEGER IDELB(*) |
| 60 |
DIMENSION A(1) |
| 61 |
INTEGER IA(1) |
| 62 |
CHARACTER*1 C(1) |
| 63 |
INTEGER MERR |
| 64 |
|
| 65 |
CHARACTER*(MXSTLN) NAEB |
| 66 |
INTEGER NELB, EBID, NLNK, NATR |
| 67 |
INTEGER NERR |
| 68 |
|
| 69 |
MERR = 0 |
| 70 |
ILNK = 0 |
| 71 |
IATR = 0 |
| 72 |
ISLNK = 0 |
| 73 |
ISATR = 0 |
| 74 |
|
| 75 |
IF (ALLELE) THEN |
| 76 |
IXELB(0) = 0 |
| 77 |
IXELBO(0) = 0 |
| 78 |
END IF |
| 79 |
|
| 80 |
MAXCON = NUMLNK(1)*NUMELB(1) |
| 81 |
MAXATR = NUMATR(1)*NUMELB(1) |
| 82 |
DO 90 I = 1, NELBLK |
| 83 |
NELB = NUMELB(I) |
| 84 |
NLNK = NUMLNK(I) |
| 85 |
NATR = NUMATR(I) |
| 86 |
IF (NELB*NLNK .GT. MAXCON) MAXCON = NELB*NLNK |
| 87 |
IF (NELB*NATR .GT. MAXATR) MAXATR = NELB*NATR |
| 88 |
90 CONTINUE |
| 89 |
|
| 90 |
if (allele) then |
| 91 |
call expclb(ndbout, IDELB, BLKTYP, NUMELB, NUMLNK, NUMATR, |
| 92 |
* .TRUE., IERR) |
| 93 |
else |
| 94 |
call mdrsrv('IDSCR', kidscr, nelblk) |
| 95 |
call mdrsrv('NUMSCR', knumscr, nelblk) |
| 96 |
call mdrsrv('LNKSCR', klnkscr, nelblk) |
| 97 |
call mdrsrv('NATSCR', knatscr, nelblk) |
| 98 |
call mcrsrv('NAMSCR', knamscr, nelblk*mxstln) |
| 99 |
CALL MDSTAT (NERR, MEM) |
| 100 |
IF (NERR .GT. 0) then |
| 101 |
call memerr |
| 102 |
MERR = 1 |
| 103 |
return |
| 104 |
end if |
| 105 |
C Loop from 1 to number of element blocks |
| 106 |
ielbo = 0 |
| 107 |
DO IELB = 1, NELBLK |
| 108 |
if (viselb(ielb)) then |
| 109 |
ielbo = ielbo + 1 |
| 110 |
itmp = isetarr(ia(kidscr), ielbo, idelb(ielb)) |
| 111 |
itmp = isetarr(ia(knatscr), ielbo, numatr(ielb)) |
| 112 |
itmp = isetarr(ia(klnkscr), ielbo, numlnk(ielb)) |
| 113 |
call cpynam(blktyp(ielb), c(knamscr), ielbo) |
| 114 |
NELBO = IXELBO(IELB) - IXELBO(IELB-1) |
| 115 |
itmp = isetarr(ia(knumscr), ielbo, nelbo) |
| 116 |
end if |
| 117 |
end do |
| 118 |
C ... Wrap this call to handle character*(1) vs character*(mxstln) weirdness |
| 119 |
call blkout(ndbout, ia(kidscr), c(knamscr), ia(knumscr), |
| 120 |
* ia(klnkscr), ia(knatscr)) |
| 121 |
call mddel('IDSCR') |
| 122 |
call mddel('NUMSCR') |
| 123 |
call mddel('LNKSCR') |
| 124 |
call mddel('NATSCR') |
| 125 |
call mcdel('NAMSCR') |
| 126 |
CALL MDSTAT (NERR, MEM) |
| 127 |
IF (NERR .GT. 0) then |
| 128 |
call memerr |
| 129 |
MERR = 1 |
| 130 |
return |
| 131 |
end if |
| 132 |
end if |
| 133 |
|
| 134 |
C Loop from 1 to number of element blocks |
| 135 |
DO 100 IELB = 1, NELBLK |
| 136 |
|
| 137 |
C These variable must be set here in order to calculate |
| 138 |
C the correct indices for the LINK and ATRIB arrays |
| 139 |
C The problem arises when the VISIBLE command is used |
| 140 |
C and not all element blocks are visible |
| 141 |
NELB = NUMELB(IELB) |
| 142 |
NLNK = NUMLNK(IELB) |
| 143 |
NATR = NUMATR(IELB) |
| 144 |
ISLNK = ILNK + 1 |
| 145 |
ILNK = ILNK + (NLNK * NELB) |
| 146 |
ISATR = IATR + 1 |
| 147 |
IATR = IATR + (NATR * NELB) |
| 148 |
|
| 149 |
C If write all elements or write this element block |
| 150 |
IF (ALLELE .OR. VISELB(IELB)) THEN |
| 151 |
|
| 152 |
EBID = IDELB(IELB) |
| 153 |
NAEB = BLKTYP(IELB) |
| 154 |
|
| 155 |
IF (ALLELE) THEN |
| 156 |
IXELB(IELB) = IXELB(IELB-1) + NELB |
| 157 |
IXELBO(IELB) = IXELBO(IELB-1) + NELB |
| 158 |
END IF |
| 159 |
|
| 160 |
NELBO = IXELBO(IELB) - IXELBO(IELB-1) |
| 161 |
|
| 162 |
if ((NELBO .NE. NELB) .or. NEWNOD) then |
| 163 |
CALL MDRSRV('LNSCR', KLNSCR, MAX(NELB,NELBO)*NLNK) |
| 164 |
CALL MDRSRV('ATRSCR', KATSCR, MAX(NELB,NELBO)*NATR) |
| 165 |
CALL MDSTAT (NERR, MEM) |
| 166 |
IF (NERR .GT. 0) then |
| 167 |
call memerr |
| 168 |
MERR = 1 |
| 169 |
return |
| 170 |
end if |
| 171 |
else |
| 172 |
klnscr = 1 |
| 173 |
katscr = 1 |
| 174 |
end if |
| 175 |
|
| 176 |
IEL = IXELB(IELB-1)+1 |
| 177 |
IELO = IXELBO(IELB-1)+1 |
| 178 |
|
| 179 |
C Write element block connectivity array |
| 180 |
C Write element block attributes |
| 181 |
CALL WCONAT (NDBOUT, NELB, NELBO, IEL, IXELEM(IELO), |
| 182 |
& NLNK, NATR, MAX(1,NLNK), MAX(1,NATR), |
| 183 |
& LINK(ISLNK), ATRIB(ISATR), NAEB, |
| 184 |
& EBID, NEWNOD, NODIX, |
| 185 |
& A(KLNSCR), A(KATSCR)) |
| 186 |
|
| 187 |
IF (nelbo .ne. nelb .or. newnod) THEN |
| 188 |
CALL MDDEL ('LNSCR') |
| 189 |
CALL MDDEL ('ATRSCR') |
| 190 |
CALL MDSTAT (NERR, MEM) |
| 191 |
IF (NERR .GT. 0) then |
| 192 |
call memerr |
| 193 |
MERR = 1 |
| 194 |
return |
| 195 |
end if |
| 196 |
END IF |
| 197 |
|
| 198 |
END IF |
| 199 |
100 CONTINUE |
| 200 |
|
| 201 |
RETURN |
| 202 |
END |
| 203 |
|
| 204 |
integer function isetarr(intarr, ipos, ival) |
| 205 |
|
| 206 |
integer intarr(*) |
| 207 |
integer ipos |
| 208 |
|
| 209 |
intarr(ipos) = ival |
| 210 |
isetarr = ival |
| 211 |
return |
| 212 |
end |
| 213 |
|
| 214 |
subroutine cpynam(namei, nameo, idx) |
| 215 |
include 'exodusII.inc' |
| 216 |
|
| 217 |
character*(mxstln) namei |
| 218 |
character*(mxstln) nameo(*) |
| 219 |
nameo(idx) = namei |
| 220 |
return |
| 221 |
end |
| 222 |
|
| 223 |
subroutine blkout(ndbout, idelb, names, numelb, numlnk, numatr) |
| 224 |
include 'exodusII.inc' |
| 225 |
integer idelb(*) |
| 226 |
character*(mxstln) names(*) |
| 227 |
integer numelb(*) |
| 228 |
integer numlnk(*) |
| 229 |
integer numatr(*) |
| 230 |
call expclb(ndbout, idelb, names, numelb, numlnk, numatr, |
| 231 |
* .true., ierr) |
| 232 |
return |
| 233 |
end |