View previous topic :: View next topic |
Author |
Message |
dltanner
Joined: 04 Apr 2005 Posts: 3
|
Posted: Mon Dec 25, 2006 9:57 pm Post subject: invalid floating point operation |
|
|
I get 'invalid floating point operation' with the following code:
Code: | DO 45 I=1,NC
if(x(i) .lt. 1.d-10)goto 45
XIBL= X(I)*HBARL(I)
HL = HL + X(I)*HBARL(I)
45 CONTINUE
|
error on 2nd line (got error on 3rd line before 2nd line added.
I=1
x(1) either 0 or 1e-5
I am using:
IMPLICIT REAL*8(A-H.O-Z) and
ZEROISE
Any suggestions?
Thanks. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Tue Dec 26, 2006 12:06 pm Post subject: |
|
|
What are X and HBARL?
If either of these are external functions the compiler will assume that they are functions returning REAL*8, because of your IMPLICIT REAL*8.
At a guess HBARL might be a function returning a REAL*4 in which case you could get this error at runtime. |
|
Back to top |
|
|
dltanner
Joined: 04 Apr 2005 Posts: 3
|
Posted: Tue Dec 26, 2006 3:39 pm Post subject: invalid floating point operation |
|
|
Hbarl(i) is dimension 50, a calling parameter to Subroutine HLBAR of IMPLICIT REAL*8.
Code: |
40 CALL HLBAR(T,X,HBARL)
DO 45 I=1,NC
if(x(i) .lt. 1.d-10)goto 45
XIBL= X(I)*HBARL(I)
HL = HL + X(I)*HBARL(I)
|
There are many subroutines with IMPLICIT REAL*8. Should I take the time to declare every variable in every subprogram? Previously, I was using FTN77 and got 'floating point stack overflow' in a different subroutine with REAL*8 variables that should not have caused a problem.
This is legacy FTN77 code from a VAX with all the extensions. I never had a problem with this code when I compiled it on Microsoft Powerstation under WFWG3.11, but, of course, I couldn't use Clearwin+.
Thanks for your suggestions. |
|
Back to top |
|
|
silverfrost Site Admin
Joined: 29 Nov 2006 Posts: 191 Location: Manchester
|
Posted: Tue Dec 26, 2006 4:44 pm Post subject: |
|
|
'floating point stack overflow' is almost certainly a bug in FTN77.
Have you run your code with any checking options? 'invalid floating point operation' quite often means unset variable. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Tue Dec 26, 2006 6:20 pm Post subject: |
|
|
I still suspect that something is not declared correctly.
If you cannot find the mismatch then try using IMPLICIT NONE and declare everything explicitly. This is the recommended modern way to write FORTRAN code. |
|
Back to top |
|
|
|