File: matqz.f

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (1079 lines) | stat: -rw-r--r-- 26,331 bytes parent folder | download
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
      subroutine matqz
c     Copyright INRIA
      INCLUDE '../stack.h'
c     
      double precision t,eps
      logical fail,macro
      integer top0,top2,iadr,sadr,tops
      character*(nlgh+1) namef
      common/cschur/namef
      external fschur,bschur
      integer         iero
      common /ierinv/ iero

c     
c     fin    1       2     3        4
c     gschur  gspec  ereduc   fstair
c     
      sadr(l)=(l/2)+1
      iadr(l)=l+l-1
c     
      if (ddt .eq. 4) then
         write(buf(1:4),'(i4)') fin
         call basout(io,wte,' matqz '//buf(1:4))
      endif
c     
      tops=top
      eps=stk(leps)
c     
      if(fin.ge.3) goto 973
      err=0
      if(fin.eq.1.and.rhs.eq.3) goto 30
c     gschur et spectre
c     
      if(rhs.ne.2) then
         call error(39)
         return
      endif
      ile=iadr(lstk(top))
      if(istk(ile).ne.1) then
         if(fin.eq.1) then
            call putfunnam('gschur',top)
         else
            call putfunnam('gspec',top)
         endif
         fun=-1
         return
      endif
      if(istk(ile+3).ne.0) then
         err=2
         call error(52)
         return
      endif
      me=istk(ile+1)
      ne=istk(ile+2)
      if(me.ne.ne) then
         err=2
         call error(20)
         return
      endif
      le=sadr(ile+4)
c     
      top=top-1
      il=iadr(lstk(top))
      if(istk(il).ne.1) then
         if(fin.eq.1) then
            call putfunnam('gschur',top)
         else
            call putfunnam('gspec',top)
         endif
         fun=-1
         top=tops
         return
      endif
      if(istk(il+3).ne.0) then
         err=1
         call error(52)
         return
      endif
      ma=istk(il+1)
      na=istk(il+2)
      if(ma.ne.na) then
         err=1
         call error(20)
         return
      endif
      nn=na*na
      la=sadr(il+4)
c     
      if(na.ne.ne) then
         call error(60)
         return
      endif
c     
      goto(10,20) fin
 10   continue
c     gschur

c     generalized schur form: transformations q,z not required
c-------------------------------------------------------------------
c     Three steps in the reduction of a - s*e:
c     1. qhesz: reduces a to upper hessenberg form and e to upper
c     triangular form
c     2. qitz:  further reduces a to quasi upper triangular form
c     where the 2x2 blocks may correspond to pairs of
c     real eigenvalues
c     3. qvalz: further reduces a so that all 2x2 blocks correspond 
c     to pairs of complex conjugate eigenvalues
      
      if(lhs.ne.2) goto 11
      top=top+1
      lr=le+nn+2
      li=lr+na
      lb=li+na+2
      err=lb+na-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      call qhesz(na,na,stk(la),stk(le),.false.,t,.false.,t)
      call qitz(na,na,stk(la),stk(le),eps,.false.,t,.false.,t,
     x     ierr)

      if (ierr.gt.2)  call msgs(1,ierr)

      call qvalz(na,na,stk(la),stk(le),eps,stk(lr),stk(li),
     x     stk(lb),.false.,t,.false.,t)
      return
c     
c     generalized schur form with transformations q,z
c-------------------------------------------------------------------
 11   if(lhs.ne.4) then
         call error(41)
         return
      endif
      lq=le+nn+sadr(5)-1
      lz=lq+nn+sadr(5)-1
      lr=lz+nn+2
      li=lr+na
      lb=li+na+2
      err=lb+na-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      call qhesz(na,na,stk(la),stk(le),.true.,stk(lq),.true.,stk(lz))
      call qitz(na,na,stk(la),stk(le),eps,.true.,stk(lq),.true.,
     x     stk(lz),ierr)
c     
      if (ierr.gt.2)  call msgs(1,ierr)
c     
      call qvalz(na,na,stk(la),stk(le),eps,stk(lr),stk(li),
     x     stk(lb),.true.,stk(lq),.true.,stk(lz))


c     affectation de q
      top=top+2
      il=iadr(lstk(top))
      istk(il)=1
      istk(il+1)=na
      istk(il+2)=na
      istk(il+3)=0
      lstk(top+1)=sadr(il+4)+nn
c     
c     affectation de z
      top=top+1
      il=iadr(lstk(top))
      istk(il)=1
      istk(il+1)=na
      istk(il+2)=na
      istk(il+3)=0
      lstk(top+1)=sadr(il+4)+nn
      return

c     
c     generalized spectrum
c---------------------------------------------
 20   continue
      if(na.eq.0) then
         top=top+1
         if(lhs.eq.3) then
            top=top+1
            il=iadr(lstk(top))
            istk(il)=1
            istk(il+1)=0
            istk(il+2)=0
            istk(il+3)=0
            lstk(top+1)=sadr(il+4)
         endif
         return
      endif
      if(lhs.eq.3) goto 21
      if(lhs.ne.2) then
         call error(41)
         return
      endif
c     
      lr=le+nn+2
      li=lr+na
      lb=li+na+2
      err=lb+na-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      call qhesz(na,na,stk(la),stk(le),.false.,t,.false.,t)
      call qitz (na,na,stk(la),stk(le),eps,.false.,t,.false.
     x     ,t,ierr)

c     
      if (ierr.gt.2)  call msgs(1,ierr)

      call qvalz(na,na,stk(la),stk(le),eps,stk(lr),stk(li),
     x     stk(lb),.false.,t,.false.,t)
c     affectation des resultats
c     numerateur (complexe)
      it=1
      il=iadr(lstk(top))
      istk(il)=1
      istk(il+1)=na
      istk(il+2)=1
      istk(il+3)=it
      call unsfdcopy(na*(it+1),stk(lr),1,stk(la),1)
      lstk(top+1)=sadr(il+4)+na*(it+1)
c     denominateur (reel)
      it=0
      top=top+1
      il=iadr(lstk(top))
      l=sadr(il+4)
      istk(il)=1
      istk(il+1)=na
      istk(il+2)=1
      istk(il+3)=it
      call unsfdcopy(na,stk(lb),1,stk(l),1)
      lstk(top+1)=sadr(il+4)+na*(it+1)
      return
c     
c     spectre generalise avec vecteurs propres a droite
c-----------------------------------------------------
 21   continue
      lr=le+nn+2
      li=lr+na
      lb=li+na
      lz=lb+na
      err=lz+nn*2-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      call qhesz(na,na,stk(la),stk(le),.false.,t,.true.,stk(lz))
      call qitz (na,na,stk(la),stk(le),eps,.false.,t,.true.
     x     ,stk(lz),err)
      if(err.ne.0) then
         call error(24)
         return
      endif
      call qvalz(na,na,stk(la),stk(le),eps,stk(lr),stk(li),
     x     stk(lb),.false.,t,.true.,stk(lz))
      call qvecz(na,na,stk(la),stk(le),eps,stk(lr),stk(li),
     x     stk(lb),stk(lz))
c     affectation des resultats
c     numerateur (complexe)
      it=1
      il=iadr(lstk(top))
      istk(il)=1
      istk(il+1)=na
      istk(il+2)=1
      istk(il+3)=it
      call unsfdcopy(na*(it+1),stk(lr),1,stk(la),1)
      lstk(top+1)=sadr(il+4)+na*(it+1)
c     denominateur (reel)
      it=0
      top=top+1
      il=iadr(lstk(top))
      istk(il)=1
      l=sadr(il+4)
      istk(il+1)=na
      istk(il+2)=1
      istk(il+3)=it
      call unsfdcopy(na,stk(lb),1,stk(l),1)
      lstk(top+1)=sadr(il+4)+na*(it+1)
c     vecteurs propres generalises (complexes)
      it=1
      top=top+1
      il=iadr(lstk(top))
      l=sadr(il+4)
      istk(il)=1
      istk(il+1)=na
      istk(il+2)=na
      istk(il+3)=it
      kk=1
      do 22 k=1,na
         lzr=lz+(kk-1)*na
         lzr2=lzr+na
         lzi=lzr+nn
         lzi2=lzi+na
         if(abs(stk(li+kk-1)).le.stk(leps)) goto 24
c     paire complexe
         call unsfdcopy(na,stk(lzr2),1,stk(lzi),1)
         do 23 j=1,na
            stk(lzi2+j-1)=-stk(lzi+j-1)
 23      continue
         call unsfdcopy(na,stk(lzr),1,stk(lzr2),1)
         kk=kk+2
         goto 25
 24      continue
c     cas reel
         call dset(na,0.0d+0,stk(lzi),1)
         kk=kk+1
 25      continue
         if(kk.gt.na) goto 26
 22   continue
 26   continue
      call unsfdcopy(nn*(it+1),stk(lz),1,stk(l),1)
      lstk(top+1)=sadr(il+4)+nn*(it+1)
      return

c     
c     stabl :   sous espace de deflation stable a droite
c--------------------------------------------------------
 30   continue
      top0=top+1-rhs
      if(rhs.ne.3) then
         call error(39)
         return
      endif
      if(lhs.ne.2.and.lhs.ne.4) then 
         call error(59)
         return
      endif
      ilcd=iadr(lstk(top))
      if(istk(ilcd).gt.10) then
         macro=.true.
      elseif(istk(ilcd).eq.10) then
         macro=.false.
         if(istk(ilcd+1)*istk(ilcd+2).ne.1) then
            err=3
            call error(89)
            return
         endif
         nc=istk(ilcd+5)-1
         namef=' '
         call cvstr(nc,istk(ilcd+6),namef,1)
         namef(nc+1:nc+1)=char(0)
         call setfschur(namef,irep)
         if ( irep.eq.1) then 
            buf = namef
            call error(50)
            return
         endif
         top=top-1
         icd=abs(istk(ilcd+6))
      else
         err=rhs
         call error(44)
      endif
      top2=top
      lw=lstk(top+1)

c     acquisition de la matrice   e
      ile=iadr(lstk(top0+1))
      if(istk(ile).ne.1.or.istk(ile+3).ne.0) then
         if(fin.eq.1) then
            call putfunnam('gschur',top0+1)
         else
            call putfunnam('gspec',top0+1)
         endif
         fun=-1
         top=tops
         return
      endif
      me=istk(ile+1)
      ne=istk(ile+2)
      if(me.ne.ne) then
         err=2
         call error(20)
         return
      endif
      le=sadr(ile+4)
c     
c     acquisition de la matrice a
      ila=iadr(lstk(top0))
      if(istk(ila).ne.1.or.istk(ila+3).ne.0) then
         if(fin.eq.1) then
            call putfunnam('gschur',top0)
         else
            call putfunnam('gspec',top0)
         endif
         fun=-1
         top=tops
         return
      endif
      ma=istk(ila+1)
      na=istk(ila+2)
      if(ma.ne.na) then
         err=1
         call error(20)
         return
      endif
      nn=na*na
      ita=istk(ila+3)
      la=sadr(ila+4)
c     
c     test de coherence des tailles
      if(ma.ne.me) then
         call error(60)
         return
      endif
c     
c     on implante les tableau resultats et de travail
      ilz=iadr(lw)
      lz=sadr(ilz+4)
      ild=iadr(lz+nn)
      ld=sadr(ild+4)
      lr=ld+1
      li=lr+na
      lb=li+na
      ilw=iadr(lb+na)
      lfree=sadr(ilw+na)
c     
c     verification de l'existence de l'espace necessaire
      err=lfree - lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
c     
c     appel du programme
      call qhesz(na,na,stk(la),stk(le),.false.,t,.true.,stk(lz))
      call qitz (na,na,stk(la),stk(le),eps,.false.,t,.true.
     x     ,stk(lz),ierr)
c     
      if (ierr.gt.2) call msgs(1,ierr)

      call qvalz(na,na,stk(la),stk(le),eps,stk(lr),stk(li),
     x     stk(lb),.false.,t,.true.,stk(lz))

      if(.not.macro) then
         call dsubsp(na,na,stk(la),stk(le),stk(lz),fschur
     x        ,eps,ndim,fail,istk(ilw))
      else
c     on ferme le tableau de travail...
         lstk(top+1)=lfree
c     creation d'une variable bidon de type scalaire pour stockage de la
c     valeur retournee par l'external
         top=top+1
         il9=iadr(lstk(top))
         istk(il9)=1
         istk(il9+1)=3
         istk(il9+2)=1
         istk(il9+3)=0
         lvar=sadr(il9+4)
         kvtop=top
         lstk(top+1)=lvar+3
c     creation d'une structure pour l'external
         top=top+1
         ilwe=iadr(lstk(top))
         istk(ilwe)=1
         istk(ilwe+1)=ilwe+2
         istk(ilwe+2)=top2
         istk(ilwe+3)=kvtop
         lstk(top+1)=lstk(top)+3
         call dsubsp(na,na,stk(la),stk(le),stk(lz),bschur
     x        ,eps,ndim,fail,istk(ilw))
         if(iero.ne.0) then
            err=1
            return
         endif
      endif
      if(fail) then
         call error(24)
         return
      endif
      top=top0+1
      if(lhs.eq.2) then
         call unsfdcopy(nn,stk(lz),1,stk(la),1)
         stk(le)=ndim
         istk(ile+1)=1
         istk(ile+2)=1
         return
      endif
c     creation de la variable z
      top=top+1
      ilz=iadr(lstk(top))
      istk(ilz)=1
      istk(ilz+1)=na
      istk(ilz+2)=na
      istk(ilz+3)=0
      l=sadr(ilz+4)
      if(macro) call unsfdcopy(na*na,stk(lz),1,stk(l),1)
      lstk(top+1)=l+nn
c     creation de la variable d
      top=top+1
      ild=iadr(lstk(top))
      istk(ild)=1
      istk(ild+1)=1
      istk(ild+2)=1
      istk(ild+3)=0
      ld=sadr(ild+4)
      stk(ld)=ndim
      lstk(top+1)=ld+1
      return
 973  continue
      if (fin .eq.3) then
c     
c     SCILAB function : ereduc
c     --------------------------
         lw = lstk(top+1)
         l0 = lstk(top+1-rhs)
         if (rhs .ne. 2) then
            call error(39)
            return
         endif
         if (lhs .gt. 5) then
            call error(41)
            return
         endif
c     checking variable e (number 1)
c     
         il1 = iadr(lstk(top-rhs+1))

         if (istk(il1) .ne. 1) then
            call putfunnam('ereduc',top-rhs+1)
            fun=-1
            return
         endif
         n1 = istk(il1+1)
         m1 = istk(il1+2)
         l1 = sadr(il1+4)
c     checking variable tol (number 2)
c     
         il2 = iadr(lstk(top-rhs+2))
         if (istk(il2) .ne. 1) then
            err = 2
            call error(53)
            return
         endif
         if (istk(il2+1)*istk(il2+2) .ne. 1) then
            err = 2
            call error(89)
            return
         endif
         l2 = sadr(il2+4)
c     
c     cross variable size checking
c     
c     
c     cross formal parameter checking
c     not implemented yet
c     
c     cross equal output variable checking
c     not implemented yet
         lw4=lw
         lw=lw+n1*n1
         lw5=lw
         lw=lw+m1*m1
         lw6=lw
         lw=lw+n1
         lw7=lw
         lw=lw+1
         err=lw-lstk(bot)
         if (err .gt. 0) then
            call error(17)
            return
         endif
c     
         call ereduc(stk(l1),n1,m1,stk(lw4),stk(lw5),stk(lw6),stk(lw7)
     $        ,stk(l2))
         if (err .gt. 0) return
c     
         top=top-rhs
         lw0=lw
         mv=lw0-l0
c     
         if(lhs .ge. 1) then
c     
c     output variable: e
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+n1*m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            call icopy(4,istk(il1),1,istk(ilw),1)
            lw=sadr(ilw+4)
            call unsfdcopy(n1*m1,stk(l1),1,stk(lw),1)
            lw=lw+n1*m1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 2) then
c     
c     output variable: q
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+n1*n1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=n1
            istk(ilw+2)=n1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call unsfdcopy(n1*n1,stk(lw4),1,stk(lw),1)
            lw=lw+n1*n1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 3) then
c     
c     output variable: z
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+m1*m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=m1
            istk(ilw+2)=m1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call unsfdcopy(m1*m1,stk(lw5),1,stk(lw),1)
            lw=lw+m1*m1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 4) then
c     
c     output variable: stair
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+n1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=n1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(n1,stk(lw6),1,stk(lw),1)
            lw=lw+n1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 5) then
c     
c     output variable: rk
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+5-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(1,stk(lw7),1,stk(lw),1)
            lw=lw+1
            lstk(top+1)=lw-mv
         endif
c     
c     putting in order the stack
c     
         call unsfdcopy(lw-lw0,stk(lw0),1,stk(l0),1)
         return
      endif
c     
      if (fin .eq. 4) then
c     
c     SCILAB function : fstair
c     --------------------------
         lw = lstk(top+1)
         l0 = lstk(top+1-rhs)
         if (rhs .ne. 7) then
            call error(39)
            return
         endif
         if (lhs .gt. 10) then
            call error(41)
            return
         endif
c     checking variable a (number 1)
c     
         il1 = iadr(lstk(top-rhs+1))
         if (istk(il1) .ne. 1) then
            if (istk(il1) .ne. 1) then
               call putfunnam('fstair',top-rhs+1)
               fun=-1
               return
            endif
         endif
         n1 = istk(il1+1)
         m1 = istk(il1+2)
         l1 = sadr(il1+4)
c     checking variable e (number 2)
c     
         il2 = iadr(lstk(top-rhs+2))
         if (istk(il2) .ne. 1) then
            call putfunnam('fstair',top-rhs+2)
            fun=-1
            return
         endif
         n2 = istk(il2+1)
         m2 = istk(il2+2)
         l2 = sadr(il2+4)
c     checking variable q (number 3)
c     
         il3 = iadr(lstk(top-rhs+3))
         if (istk(il3) .ne. 1) then
            call putfunnam('fstair',top-rhs+3)
            fun=-1
            return
         endif
         if (istk(il3+1) .ne. istk(il3+2)) then
            err = 3
            call error(20)
            return
         endif
         n3 = istk(il3+1)
         m3 = istk(il3+2)
         l3 = sadr(il3+4)
c     checking variable z (number 4)
c     
         il4 = iadr(lstk(top-rhs+4))
         if (istk(il4) .ne. 1) then
            call putfunnam('fstair',top-rhs+4)
            fun=-1
            return
         endif
         if (istk(il4+1) .ne. istk(il4+2)) then
            err = 4
            call error(20)
            return
         endif
         n4 = istk(il4+1)
         m4 = istk(il4+2)
         l4 = sadr(il4+4)
c     checking variable stair (number 5)
c     
         il5 = iadr(lstk(top-rhs+5))
         if (istk(il5) .ne. 1) then
            call putfunnam('fstair',top-rhs+5)
            fun=-1
            return
         endif
         if (istk(il5+1) .ne. 1) then
            err = 5
            call error(89)
            return
         endif
         m5 = istk(il5+2)
         l5 = sadr(il5+4)
c     checking variable rk (number 6)
c     
         il6 = iadr(lstk(top-rhs+6))
         if (istk(il6) .ne. 1) then
            err = 6
            call error(53)
            return
         endif
         if (istk(il6+1)*istk(il6+2) .ne. 1) then
            err = 6
            call error(89)
            return
         endif
         l6 = sadr(il6+4)
c     checking variable tol (number 7)
c     
         il7 = iadr(lstk(top-rhs+7))
         if (istk(il7) .ne. 1) then
            err = 7
            call error(53)
            return
         endif
         if (istk(il7+1)*istk(il7+2) .ne. 1) then
            err = 7
            call error(89)
            return
         endif
         l7 = sadr(il7+4)
c     
c     cross variable size checking
c     
         if (n1 .ne. n2) then
            call error(42)
            return
         endif
         if (n1 .ne. n3) then
            call error(42)
            return
         endif
         if (n1 .ne. m3) then
            call error(42)
            return
         endif
         if (n1 .ne. m5) then
            call error(42)
            return
         endif
         if (m1 .ne. m2) then
            call error(42)
            return
         endif
         if (m1 .ne. n4) then
            call error(42)
            return
         endif
         if (m1 .ne. m4) then
            call error(42)
            return
         endif
c     
c     cross formal parameter checking
c     not implemented yet
c     
c     cross equal output variable checking
c     not implemented yet
         call entier(m5,stk(l5),istk(iadr(l5)))
         call entier(1,stk(l6),istk(iadr(l6)))
         lw10=lw
         lw=lw+1
         lw11=lw
         lw=lw+m1
         nn12=n1+1
         lw12=lw
         lw=lw+nn12
         lw13=lw
         lw=lw+m1
         lw14=lw
         lw=lw+nn12
         nn15=4
         lw15=lw
         lw=lw+nn15
         lw16=lw
         lw=lw+m1
         lw17=lw
         lw=lw+m1

         err=lw-lstk(bot)
         if (err .gt. 0) then
            call error(17)
            return
         endif
c     
         call fstair(stk(l1),stk(l2),stk(l3),stk(l4),n1,m1
     $        ,istk(iadr(l5)),istk(iadr(l6)),stk(l7),stk(lw10)
     $        ,stk(lw11),stk(lw12),stk(lw13),stk(lw14),stk(lw15)
     $        ,stk(lw16),stk(lw17),ierr)
         if (ierr.ne.0) then
            buf='fstair failed !'
            call error(9999)
            return
         endif
c     
         top=top-rhs
         lw0=lw
         mv=lw0-l0
c     
         if(lhs .ge. 1) then
c     
c     output variable: a
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+n1*m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            call icopy(4,istk(il1),1,istk(ilw),1)
            lw=sadr(ilw+4)
            call unsfdcopy(n1*m1,stk(l1),1,stk(lw),1)
            lw=lw+n1*m1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 2) then
c     
c     output variable: e
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+n1*m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            call icopy(4,istk(il2),1,istk(ilw),1)
            lw=sadr(ilw+4)
            call unsfdcopy(n2*m2,stk(l2),1,stk(lw),1)
            lw=lw+n2*m2
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 3) then
c     
c     output variable: q
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+n1*n1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            call icopy(4,istk(il3),1,istk(ilw),1)
            lw=sadr(ilw+4)
            call unsfdcopy(n3*m3,stk(l3),1,stk(lw),1)
            lw=lw+n3*m3
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 4) then
c     
c     output variable: z
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+m1*m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            call icopy(4,istk(il4),1,istk(ilw),1)
            lw=sadr(ilw+4)
            call unsfdcopy(n4*m4,stk(l4),1,stk(lw),1)
            lw=lw+n4*m4
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 5) then
c     
c     output variable: nblcks
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+5-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(1,stk(lw10),1,stk(lw),1)
            lw=lw+1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 6) then
c     
c     output variable: muk
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=m1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(m1,stk(lw11),1,stk(lw),1)
            lw=lw+m1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 7) then
c     
c     output variable: nuk
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+nn12-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=nn12
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(nn12,stk(lw12),1,stk(lw),1)
            lw=lw+nn12
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 8) then
c     
c     output variable: muk0
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+m1-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=m1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(m1,stk(lw13),1,stk(lw),1)
            lw=lw+m1
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 9) then
c     
c     output variable: nuk0
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+nn12-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=1
            istk(ilw+2)=nn12
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(nn12,stk(lw14),1,stk(lw),1)
            lw=lw+nn12
            lstk(top+1)=lw-mv
         endif
c     
         if(lhs .ge. 10) then
c     
c     output variable: mnei
c     
            top=top+1
            ilw=iadr(lw)
            err=lw+4+nn15-lstk(bot)
            if (err .gt. 0) then
               call error(17)
               return
            endif
            istk(ilw)=1
            istk(ilw+1)=nn15
            istk(ilw+2)=1
            istk(ilw+3)=0
            lw=sadr(ilw+4)
            call int2db(nn15,stk(lw15),1,stk(lw),1)
            lw=lw+nn15
            lstk(top+1)=lw-mv
         endif
c     
c     putting in order the stack
c     
         call unsfdcopy(lw-lw0,stk(lw0),1,stk(l0),1)
         return
      endif
c     
      end