Silverfrost Forums

Welcome to our forums

Floating point co-processor fault at address <number>

30 Nov 2010 4:44 #7182

The following declarations are provoking the error as shown in the post subject.

        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!

2 Dec 2010 10:28 #7195

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

2 Dec 2010 1:39 #7196

Thank you Carl. The error came from divided by zero from 'sum2=0'. Your last suggestion was really helpful.

Cheers!

Please login to reply.