3 c This demonstrates a problem with g77 and pic on x86 where
4 c egcs 1.0.1 and earlier will generate bogus assembler output.
5 c unfortunately, gas accepts the bogus acssembler output and
6 c generates code that almost works.
10 C Date: Wed, 17 Dec 1997 23:20:29 +0000
11 C From: Joao Cardoso <jcardoso@inescn.pt>
12 C To: egcs-bugs@cygnus.com
13 C Subject: egcs-1.0 f77 bug on OSR5
14 C When trying to compile the Fortran file that I enclose bellow,
15 C I got an assembler error:
17 C ./g77 -B./ -fpic -O -c scaleg.f
18 C /usr/tmp/cca002D8.s:123:syntax error at (
20 C ./g77 -B./ -fpic -O0 -c scaleg.f
21 C /usr/tmp/cca002EW.s:246:invalid operand combination: leal
23 C Compiling without the -fpic flag runs OK.
25 subroutine scaleg (n,ma,a,mb,b,low,igh,cscale,cperm,wk)
28 integer igh,low,ma,mb,n
29 double precision a(ma,n),b(mb,n),cperm(n),cscale(n),wk(n,6)
31 c *****local variables:
32 integer i,ir,it,j,jc,kount,nr,nrp2
33 double precision alpha,basl,beta,cmax,coef,coef2,coef5,cor,
34 * ew,ewc,fi,fj,gamma,pgamma,sum,t,ta,tb,tc
36 c *****fortran functions:
37 double precision dabs, dlog10, dsign
40 c *****subroutines called:
43 c ---------------------------------------------------------------
46 c scales the matrices a and b in the generalized eigenvalue
47 c problem a*x = (lambda)*b*x such that the magnitudes of the
48 c elements of the submatrices of a and b (as specified by low
49 c and igh) are close to unity in the least squares sense.
50 c ref.: ward, r. c., balancing the generalized eigenvalue
51 c problem, siam j. sci. stat. comput., vol. 2, no. 2, june 1981,
54 c *****parameter description:
59 c row dimensions of the arrays containing matrices
60 c a and b respectively, as declared in the main calling
61 c program dimension statement;
64 c order of the matrices a and b;
67 c contains the a matrix of the generalized eigenproblem
71 c contains the b matrix of the generalized eigenproblem
75 c specifies the beginning -1 for the rows and
76 c columns of a and b to be scaled;
79 c specifies the ending -1 for the rows and columns
80 c of a and b to be scaled;
83 c work array. only locations low through igh are
84 c referenced and altered by this subroutine;
87 c work array that must contain at least 6*n locations.
88 c only locations low through igh, n+low through n+igh,
89 c ..., 5*n+low through 5*n+igh are referenced and
90 c altered by this subroutine.
94 c a,b contain the scaled a and b matrices;
97 c contains in its low through igh locations the integer
98 c exponents of 2 used for the column scaling factors.
99 c the other locations are not referenced;
101 c wk contains in its low through igh locations the integer
102 c exponents of 2 used for the row scaling factors.
104 c *****algorithm notes:
108 c written by r. c. ward.......
109 c modified 8/86 by bobby bodenheimer so that if
110 c sum = 0 (corresponding to the case where the matrix
111 c doesn't need to be scaled) the routine returns.
113 c ---------------------------------------------------------------
115 if (low .eq. igh) go to 410
127 c compute right side vector in resulting linear equations
131 do 240 j = low,igh ! { dg-warning "Obsolescent feature: Shared DO termination" }
134 if (ta .eq. 0.0d0) go to 220
135 ta = dlog10(dabs(ta)) / basl
137 if (tb .eq. 0.0d0) go to 230
138 tb = dlog10(dabs(tb)) / basl
140 wk(i,5) = wk(i,5) - ta - tb
141 wk(j,6) = wk(j,6) - ta - tb
144 coef = 1.0d0/float(2*nr)
151 c start generalized conjugate gradient iteration
158 gamma = gamma + wk(i,5)*wk(i,5) + wk(i,6)*wk(i,6)
162 gamma = coef*gamma - coef2*(ew**2 + ewc**2)
163 + - coef5*(ew - ewc)**2
164 if (it .ne. 1) beta = gamma / pgamma
165 t = coef5*(ewc - 3.0d0*ew)
166 tc = coef5*(ew - 3.0d0*ewc)
168 wk(i,2) = beta*wk(i,2) + coef*wk(i,5) + t
169 cperm(i) = beta*cperm(i) + coef*wk(i,6) + tc
172 c apply matrix to vector
178 if (a(i,j) .eq. 0.0d0) go to 280
182 if (b(i,j) .eq. 0.0d0) go to 290
186 wk(i,3) = float(kount)*wk(i,2) + sum
192 if (a(i,j) .eq. 0.0d0) go to 310
196 if (b(i,j) .eq. 0.0d0) go to 320
200 wk(j,4) = float(kount)*cperm(j) + sum
204 sum = sum + wk(i,2)*wk(i,3) + cperm(i)*wk(i,4)
206 if(sum.eq.0.0d0) return
209 c determine correction to current iterate
213 cor = alpha * wk(i,2)
214 if (dabs(cor) .gt. cmax) cmax = dabs(cor)
215 wk(i,1) = wk(i,1) + cor
216 cor = alpha * cperm(i)
217 if (dabs(cor) .gt. cmax) cmax = dabs(cor)
218 cscale(i) = cscale(i) + cor
220 if (cmax .lt. 0.5d0) go to 370
222 wk(i,5) = wk(i,5) - alpha*wk(i,3)
223 wk(i,6) = wk(i,6) - alpha*wk(i,4)
227 if (it .le. nrp2) go to 250
229 c end generalized conjugate gradient iteration
233 ir = wk(i,1) + dsign(0.5d0,wk(i,1))
235 jc = cscale(i) + dsign(0.5d0,cscale(i))
244 if (i .lt. low) fi = 1.0d0
245 do 400 j =low,n ! { dg-warning "Obsolescent feature: Shared DO termination" }
248 if (j .le. igh) go to 390
249 if (i .lt. low) go to 400
252 a(i,j) = a(i,j)*fi*fj
253 b(i,j) = b(i,j)*fi*fj
258 c last line of scaleg