1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
|
subroutine lstelmi
c ================================== ( Inria ) =============
c
c evaluate utility list's functions with possible indirect args
c
c =============================================================
c
c Copyright INRIA
c
include '../stack.h'
c
if (ddt .eq. 4) then
write(buf(1:4),'(i4)') fin
call basout(io,wte,' lstelmi '//buf(1:4))
endif
c
c functions/fin
c 1 2
c getfield setfield
c
c
rhs=max(0,rhs)
if(top-rhs+lhs+1.ge.bot) then
call error(18)
return
endif
c
goto(10,20) fin
10 continue
c getfield
call intgetfield()
if(err.gt.0) return
goto 99
20 continue
c setfield
call intsetfield()
if(err.gt.0) return
goto 99
99 return
end
subroutine intgetfield()
include '../stack.h'
integer top0,tops,vol,vol2,vol1
integer strpos
external strpos
integer iadr,sadr
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
if (rhs .lt. 1) then
call error(39)
return
endif
lw=lstk(top+1)
c
c extraction
10 continue
if(rhs.ne.2) then
call error(39)
return
endif
c arg2(arg1)
c get arg2
il2=iadr(lstk(top))
if(istk(il2).lt.0) il2=iadr(istk(il2+1))
m2=istk(il2+1)
id2=il2+3
l2=sadr(il2+m2+3)
c get arg1
top=top-1
il1=iadr(lstk(top))
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
ilist=0
nlist=0
if(istk(il1).eq.15) then
ill=il1
nlist=m1
ll=sadr(ill+3+nlist)
ilist=1
il1=iadr(ll+istk(ill+1+ilist)-1)
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
endif
c
15 continue
c
if(istk(il1).ne.10) goto 20
c . arg2(arg1) with arg1 vector of strings
ilt=iadr(sadr(il2+istk(il2+1)+3))
nt=istk(ilt+1)*istk(ilt+2)
if(nt.ne.1) goto 17
c . Soft coded extraction
buf='Soft coded field names not yet implemented'
call error(999)
return
17 continue
c arg2(arg1) arg1:string, hard coded case
if(istk(il1+1).gt.1.and.istk(il1+2).gt.1) then
call error(21)
return
endif
n1=istk(il1+1)*istk(il1+2)
ili=iadr(lw)
lw=sadr(ili+n1)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
c . look for corresponding index
l=il1+5+n1
mx=0
do 18 i=1,n1
nl=istk(il1+4+i)-istk(il1+3+i)
n=strpos(istk(ilt+5),nt-1,istk(ilt+5+nt),istk(l),nl)
l=l+nl
if(n.le.0) then
call error(21)
return
endif
n=n+1
mx=max(mx,n)
istk(ili-1+i)=n
18 continue
n=n1
c end of arg1=string case
goto 22
c begining of standard case
20 if(m1.eq.-1) then
c . arg2(:)
l=lstk(top)
if(ilist.ne.nlist) then
if(m2.ne.1) then
call error(21)
return
endif
endif
if(m2.ne.lhs) then
call error(41)
return
endif
if(top+1+m2.ge.bot) then
call error(18)
return
endif
do 21 i=1,m2
vol1=istk(il2+2+i)-istk(il2+1+i)
if(vol1.eq.0) then
err=i
call error(117)
return
endif
lstk(top+1)=lstk(top)+vol1
top=top+1
21 continue
top=top-1
call dcopy(istk(il2+m2+2)-1,stk(l2),1,stk(l),1)
goto 99
else
c . arg2(arg1) standard case
call indxg(il1,m2,ili,n,mx,lw,1)
if(err.gt.0) return
endif
c
22 if(mx.gt.m2) then
call error(21)
return
endif
c
if(ilist.ge.nlist) goto 31
if(n.gt.1) then
call error(21)
return
endif
lt2=sadr(il2+3+m2)+istk(il2+1+istk(ili))-1
ll2=istk(il2+2+istk(ili))-istk(il2+1+istk(ili))
il2=iadr(lt2)
23 ilist=ilist+1
il1=iadr(ll+istk(ill+1+ilist)-1)
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
if(istk(il2).eq.15.or.istk(il2).eq.16) goto 26
call error(21)
return
26 continue
m2=istk(il2+1)
l2=sadr(il2+m2+3)
goto 15
c
31 if(n.ne.lhs) then
call error(41)
return
endif
c
if(top+n+1.ge.bot) then
call error(18)
return
endif
do 32 i=1,n
k=istk(ili-1+i)
vol2=istk(il2+2+k)-istk(il2+1+k)
if(vol2.eq.0) then
err=k
call error(117)
return
endif
lstk(top+1)=lstk(top)+vol2
top=top+1
32 continue
top=top-1
c
ill=iadr(max(lw,lstk(top+1)))
lw=sadr(ill+n)
err=sadr(ill+n)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
do 34 i=1,n
k=istk(ili-1+i)
istk(ill-1+i)=istk(il2+1+k)+l2-1
34 continue
c
do 35 i=1,n
k=top-n+i
call dcopy(lstk(k+1)-lstk(k),stk(istk(ill-1+i)),1,stk(lstk(k))
$ ,1)
35 continue
goto 99
99 return
end
subroutine intsetfield()
include '../stack.h'
integer top0,tops,vol,vol2,vol1,vol3s,vol3,dvol,typ2,rhs1,id(nsiz)
integer strpos,subptr
external strpos,subptr
c
integer iadr,sadr
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
if (rhs .ne. 3) then
call error(39)
return
endif
top0=top
lw=lstk(top+1)
c
ltop0=lstk(top0)
c integer vector for recursion saving
ilrec=iadr(lw)
lw=sadr(ilrec+13)
c arg3(arg1)=arg2
c get arg3
call putid(id,idstk(1,top))
il3=iadr(lstk(top))
if(istk(il3).lt.0) then
il3=iadr(istk(il3+1))
else
err=3
call error(118)
return
endif
il3s=il3
typ3=istk(il3)
if(typ3.lt.14.or.typ3.gt.17) then
call error(44)
return
endif
m3=istk(il3+1)
m3s=m3
id3=il3+3
l3=sadr(il3+m3+3)
l3s=l3
vol3=istk(il3+2+m3)-1
vol3s=vol3
c get arg2
top=top-1
l2t=lstk(top)
il2=iadr(lstk(top))
typ2=istk(il2)
vol2=lstk(top+1)-lstk(top)
c get arg1
top=top-1
il1=iadr(lstk(top))
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
ilist=0
nlist=0
if(istk(il1).eq.15.or.istk(il1).eq.16) then
ill=il1
nlist=m1
ll=sadr(ill+3+nlist)
ilist=1
il1=iadr(ll+istk(ill+1+ilist)-1)
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
ilind=iadr(lw)
lw=sadr(ilind+m1)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
else
ilind=iadr(lw)
lw=sadr(ilind+1)
endif
c
51 continue
c
if(istk(il1).eq.10) then
ilt=iadr(sadr(il3+istk(il3+1)+3))
nt=istk(ilt+1)*istk(ilt+2)
if(nt.eq.1) then
if(nlist.le.1) then
fin=-fin
top=top0
rhs1=rhs
return
endif
buf='tlist soft coded insertion not allowed here'
call error(9999)
return
endif
c . element is designated by its name
if(istk(il1+1)*istk(il1+2).ne.1) then
call error(21)
return
endif
c . look for corresponding index
n=strpos(istk(ilt+5),nt-1,istk(ilt+5+nt),istk(il1+6),
$ istk(il1+5)-istk(il1+4))
if(n.le.0) then
call error(21)
return
endif
n=n+1
ili=iadr(lw)
lw=sadr(ili+2)
istk(ili)=n
else
c . arg3(arg1)=arg2 standard case
call indxg(il1,m3,ili,nl,mx,lw,0)
if(err.gt.0) return
if(nl.ne.1) then
call error(21)
return
endif
n=istk(ili)
if(n.lt.0) then
call error(21)
return
endif
endif
c
if(ilist.ge.nlist) goto 57
c store current index
istk(ilind-1+ilist)=istk(ili)
c move pointer to indexed sub-list of arg3
il3p=il3
lt3=sadr(il3+3+m3)+istk(il3+1+istk(ili))-1
ll3=istk(il3+2+istk(ili))-istk(il3+1+istk(ili))
il3=iadr(lt3)
c move pointer to next index list entry
ilist=ilist+1
il1=iadr(ll+istk(ill+1+ilist)-1)
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
c
if(abs(istk(il3)).eq.15.or.abs(istk(il3)).eq.16.or.
$ abs(istk(il3)).eq.17) goto 56
call error(44)
return
c a leaf found
56 continue
typ3=istk(il3)
m3=istk(il3+1)
l3p=l3
l3=sadr(il3+m3+3)
vol3=istk(il3+2+m3)-1
goto 51
57 istk(ilind+nlist-1)=istk(ili)
c
58 if(n.eq.0) then
c add a new element "on the left"
if(typ2.eq.0) then
c null element : nothing added
c il1=iadr(lstk(top))
c istk(il1)=-1
c istk(il1+1)=-1
c istk(il1+2)=istk(iadr(ltop0)+2)
c lstk(top+1)=lstk(top)+3
goto 99
endif
l3d=sadr(il3s)
lrn=lw
err=sadr(iadr(lrn)+3+m3s+1)+vol3s+vol2-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
if(nlist.gt.0) then
iln=iadr(lrn)
c . copy the beginning of arg3 up to the modified sub-list
if(lt3-l3d.gt.0) then
call dcopy(lt3-l3d,stk(l3d),1,stk(lrn),1)
c . lrn points to the beginning of the new entry
lrn=lrn+lt3-l3d
endif
endif
ilr=iadr(lrn)
istk(ilr)=typ3
istk(ilr+1)=m3+1
istk(ilr+2)=1
istk(ilr+3)=1+vol2
do 59 i=1,m3
istk(ilr+3+i)=istk(ilr+2+i)+istk(il3+2+i)-istk(il3+1+i)
59 continue
lr=sadr(ilr+4+m3)
call dcopy(vol2,stk(l2t),1,stk(lr),1)
lr=lr+vol2
call dcopy(vol3,stk(l3),1,stk(lr),1)
lr=lr+vol3
dvol=(lr-lrn)-(l3+vol3-sadr(il3))
if(nlist.eq.0) then
call dcopy(lr-lrn,stk(lrn),1,stk(lstk(top)),1)
lstk(top+1)=lstk(top)+lr-lrn
else
c . update new data structure pointers recursively
call updptr(iln,istk(ilind),nlist-1,dvol)
c . copy the rest of data structure
istk(ilind+nlist-2)=istk(ilind+nlist-2)+1
lt3=sadr(subptr(il3s,istk(ilind),nlist-1))
call dcopy(l3s+vol3s-lt3,stk(lt3),1,stk(lr),1)
lr=lr+l3s+vol3s-lt3
c . put the result in place
lrn=sadr(iln)
call dcopy(lr-lrn,stk(lrn),1,stk(lstk(top)),1)
lstk(top+1)=lstk(top)+lr-lrn
endif
elseif(n.gt.m3) then
c add a new element "on the right"
if(typ2.eq.0) then
c null element : nothing added
c il1=iadr(lstk(top))
c istk(il1)=-1
c istk(il1+1)=-1
c istk(il1+2)=istk(iadr(ltop0)+2)
c lstk(top+1)=lstk(top)+3
goto 99
endif
l3d=sadr(il3s)
lrn=lw
iln=iadr(lrn)
err=sadr(iln+3+m3s+n-m3)+vol3s+vol2-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
if(nlist.gt.0) then
c . copy the beginning of arg3 up to the modified sub-list
if(lt3-l3d.gt.0) then
call dcopy(lt3-l3d,stk(l3d),1,stk(lrn),1)
c . lrn points to the beginning of the new entry
lrn=lrn+lt3-l3d
endif
endif
ilr=iadr(lrn)
call icopy(m3+3,istk(il3),1,istk(ilr),1)
istk(ilr+1)=n
call iset(n-m3,istk(ilr+m3+2),istk(ilr+m3+3),1)
istk(ilr+n+2)=istk(ilr+n+1)+vol2
lr=sadr(ilr+3+n)
call dcopy(vol3,stk(l3),1,stk(lr),1)
lr=lr+vol3
call dcopy(vol2,stk(l2t),1,stk(lr),1)
lr=lr+vol2
c
dvol=(lr-lrn)-(l3+vol3-sadr(il3))
if(nlist.ne.0) then
c . update new data structure pointers recursively
call updptr(iln,istk(ilind),nlist-1,dvol)
c . copy the rest of data structure
istk(ilind+nlist-2)=istk(ilind+nlist-2)+n-m3
lt3=sadr(subptr(il3s,istk(ilind),nlist-1))
if(l3s+vol3s-lt3.gt.0) then
call dcopy(l3s+vol3s-lt3,stk(lt3),1,stk(lr),1)
lr=lr+l3s+vol3s-lt3
endif
endif
c . store result
lrn=sadr(iln)
lt=lstk(top)
lstk(top)=lrn
lstk(top+1)=lstk(top)+lr-lrn
lhs=1
call stackp(id,0)
c . notify that result has already been stored
top=top+1
c lstk(top)=lt
c il1=iadr(lstk(top))
c istk(il1)=-1
c istk(il1+1)=-1
c istk(il1+2)=fin
c lstk(top+1)=lstk(top)+3
elseif(typ2.ne.0) then
c%%2
c change the specified element
if (istk(il3+2+n)-istk(il3+1+n).eq.vol2) then
c element is directly replaced
lr=l3+istk(il3+1+n)-1
call dcopy(vol2,stk(l2t),1,stk(lr),1)
c . list has been modified in place
c il1=iadr(lstk(top))
c istk(il1)=-1
c istk(il1+1)=-1
c istk(il1+2)=istk(iadr(ltop0)+2)
c lstk(top+1)=lstk(top)+3
goto 99
else
iln=iadr(lw)
lrn=lw
c . dvol the size variation of modified sub-element (-old+new)
dvol=-(istk(il3+2+n)-istk(il3+1+n))+vol2
err=sadr(iln+3+m3s)+vol3s+dvol-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
c . lr,ilr points to the entry to be replaced
lr=l3+istk(il3+1+n)-1
ilr=iadr(lr)
c . change list type if necessary
if(n.eq.1.and.typ2.ne.10) istk(il3)=15
c . copy the beginning of arg3 up to entry to be replaced
l3d=sadr(il3s)
call dcopy(lr-l3d,stk(l3d),1,stk(lrn),1)
c . lrn points to the beginning of the new entry
lrn=lrn+lr-l3d
c . set new value of the entry
call dcopy(vol2,stk(l2t),1,stk(lrn),1)
lrn=lrn+vol2
c . copy last entries of arg3
c . il3l points to the end of arg3 data structure
l3l=l3s+vol3s
l3=l3+istk(il3+2+n)-1
call dcopy(l3l-l3,stk(l3),1,stk(lrn),1)
lrn=lrn+l3l-l3
c . update new data structure pointers recursively
if(nlist.eq.0) then
nlist=1
c?? istk(ilind)=istk(ilind)+1
istk(ilind)=n
endif
call updptr(iln,istk(ilind),nlist,dvol)
c . store result
lt=lstk(top)
lstk(top)=lw
lstk(top+1)=lstk(top)+lrn-lw
lhs=1
call stackp(id,0)
c . notify that result has already been stored
top=top+1
lstk(top)=lt
c il1=iadr(lstk(top))
c istk(il1)=-1
c istk(il1+1)=-1
c istk(il1+2)=fin
c lstk(top+1)=lstk(top)+3
endif
else
c suppress the specified entry
l3d=sadr(il3s)
lrn=lw
iln=iadr(lrn)
err=sadr(iln+3+m3s)+vol3s-(istk(il3+2+n)-istk(il3+1+n))
$ -lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
if(nlist.gt.0) then
c . copy the beginning of arg3 up to the modified sub-list
if(lt3-l3d.gt.0) then
call dcopy(lt3-l3d,stk(l3d),1,stk(lrn),1)
c . lrn points to the beginning of the new entry
lrn=lrn+lt3-l3d
endif
endif
c . update sub_list
c . ---------------
il=iadr(lrn)
l2=l3-1+istk(il3+2+n)
c . copy variable header and n-1 first pointers
call icopy(2+n,istk(il3),1,istk(il),1)
if(n.eq.1) istk(il)=15
c . reduce list size
istk(il+1)=istk(il+1)-1
c . modify last pointers
do 65 i=n,m3
istk(il+i+2)=istk(il+i+1)+istk(il3+i+3)-istk(il3+i+2)
65 continue
c . copy first n-1 elements
l=sadr(il+2+m3)
call dcopy(istk(il+n+1)-1,stk(l3),1,stk(l),1)
l=l+istk(il+n+1)-1
c . dvol the size variation of modified sub-element (-old+new)
dvol=(l-sadr(il))-(l2-sadr(il3))
c . copy last elements
call dcopy(istk(il+1+m3)-istk(il+1+n),stk(l2),1,stk(l),1)
l=l+istk(il+1+m3)-istk(il+1+n)
if(nlist.gt.0) then
c . update new data structure pointers recursively
call updptr(iln,istk(ilind),nlist-1,dvol)
c . copy the rest of data structure
istk(ilind+nlist-1)=istk(ilind+nlist-1)+1
lt3=sadr(subptr(il3s,istk(ilind),nlist))
call dcopy(l3s+vol3s-lt3,stk(lt3),1,stk(l),1)
l=l+l3s+vol3s-lt3
endif
c . store result
lrn=sadr(iln)
lt=lstk(top)
lstk(top)=lrn
lstk(top+1)=lstk(top)+l-lrn
lhs=1
call stackp(id,0)
c . notify that result has already been stored
top=top+1
lstk(top)=lt
c il1=iadr(lstk(top))
c istk(il1)=-1
c istk(il1+1)=-1
c istk(il1+2)=fin
c lstk(top+1)=lstk(top)+3
endif
goto 99
99 il1=iadr(lstk(top))
istk(il1)=0
lstk(top+1)=lstk(top)+1
return
end
|