Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Illegal FPO - power operation 1

Status
Not open for further replies.

alorenzom

Technical User
Jun 15, 2007
6
FI
Dear All,

I have a very basic question for you.

I got an illegal floating point operation executing an application (Abaqus) using a Fortran subroutine.

I wrote in my subroutine

<cite>

BB = -0.2447862
AA = 0.6734121
write (*,*) "BB,AA = ", BB,AA
write (*,*) "-0.2447862**0.6734121 =
* ",-0.2447862**0.6734121
write (*,*) "BB**AA = ", BB**AA

</cite>

and I got

<cite>
BB, AA = -0.244786270668933 0.673412181089838
-0.2447862**0.6734121 = -0.3876160
</cite>

and then illegal FPO message.

I`m a beginner in using Fortran language, and I know this is a very basic problem, but I would be very thankful to u if u could help me.

Thanks in advance.

Regards,
alorenzom


 
I added some lines to your code
Code:
BB = -0.2447862
AA = 0.6734121
write (*,*) "BB,AA = ", BB, AA
write (*,*) "-0.2447862**0.6734121 =   * ",-0.2447862**0.6734121
write (*,*) "-(0.2447862)**0.6734121 =   * ",-(0.2447862)**0.6734121
write (*,*) "BB**AA = ", BB**AA
write (*,*) "(-0.2447862)**0.6734121 =   * ",(-0.2447862)**0.6734121
end
if I compile it with g77 I get
Code:
$ g77 alorenzom.for -o alorenzom -ffree-form

mikl1071@RMIKLOSXP ~/fortran
$ alorenzom
 BB,AA =  -0.244786203  0.673412085
 -0.2447862**0.6734121 =   *  -0.387616038
 -(0.2447862)**0.6734121 =   *  -0.387616038
 BB**AA =   -1.#IND
 (-0.2447862)**0.6734121 =   *   -1.#IND
You see, in the first case you compute -(0.2447862)**0.6734121 which gives you real result.
In the second case with BB**AA you try to compute
(-0.2447862)**0.6734121
which could not be computed with real numbers - your variables AA and BB are implicitly real.
 
Thank u so much, mikrom.

Sorry... I didn`t realize that operation results in a complex number

Actually

a<0, b in R and b not in N, (a)**b in C

where
R real numbers
N natural numbers
C complex numbers
 
Yes you get a complex number.
Here I computed in Python what result we get:
Code:
>>> bb = -0.2447862 + 0j
>>> aa = 0.6734121 + 0j
>>> bb**aa
(-0.20087760764505513+0.33150319669911388j)
 
I wrote wrong in the previous post...

Actually

a<0, b in R and b not in Z, (a)**b in C

where
R real numbers
Z relative integer numbers
C complex numbers
 
Hi both

Fortran can also real with complex numbers:
Code:
	program compl

	complex*16 aa,bb,cc

	bb = -0.2447862
	aa =  0.6734121

	open(1,file='out.txt',status='unknown')

	write(1,'(a,2f12.7)') ' bb     =', bb
	write(1,'(a,2f12.7)') ' aa     =', aa

	cc = bb**aa

	write(1,'(a,2f19.14)') ' bb**aa =', cc

	end
and the result is:
Code:
 bb     =   -.2447862    .0000000
 aa     =    .6734121    .0000000
 bb**aa =   -.20087759755167    .33150321627667
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top