View previous topic :: View next topic |
Author |
Message |
pban92
Joined: 23 Nov 2009 Posts: 38
|
Posted: Tue Nov 30, 2010 5:44 pm Post subject: Floating point co-processor fault at address <number> |
|
|
The following declarations are provoking the error as shown in the post subject.
Code: |
REAL :: sum2,sum3,skewn
INTEGER :: n
DOUBLE PRECISION, DIMENSION(n) :: nvdata
DOUBLE PRECISION :: avg
DO i = 1, n
sum3 = sum3+(nvdata(i)-avg)**3
skewn = (sum3/REAL(n))/((sum2/REAL(n))**(3/2))
END DO
|
My assumption is if data type of "n" could be converted to "DOUBLE PRECISION(n)" instead of "REAL(n)", it could be solved.
Any comment/suggestion would be highly appreciated.
Thanks! |
|
Back to top |
|
|
DrTip
Joined: 01 Aug 2006 Posts: 74 Location: Manchester
|
Posted: Thu Dec 02, 2010 11:28 am Post subject: |
|
|
pban92
The code snippet you have posted is incomplete so difficult to say but
I think your problem is that sum2 and avg have not been initialised. (unless they are parameters passed to the subroutine)
I personally would not use REAL(n) since it is not required and obscures the reading of the code ( unless I am missing something) compiler will convert double precision / integer into a double precision but ...
as an aside
3/2 in power will yield 1 not 1.5 you need to use either 1.5 or use 3.0/2.0.
Carl |
|
Back to top |
|
|
pban92
Joined: 23 Nov 2009 Posts: 38
|
Posted: Thu Dec 02, 2010 2:39 pm Post subject: |
|
|
Thank you Carl. The error came from divided by zero from "sum2=0".
Your last suggestion was really helpful.
Cheers! |
|
Back to top |
|
|
|