Common statement does not work with gfortran, but g95 gives the correct answer

Quote:

> When I give a vector size of 2 for "x", with values x(1)=1 y x(2)=1,

> the result with an executable from gfrotran gives x(1)+x(2)=3.00000000,

> but with g95, it gives x(1)+x(2)=3.00000000. Maybe I am doing something

> wrong, but lahey gives the correct answer as g95. ?g

fortran does not

> parse correctly my function?

> My code (in 1 file) is:

> IMPLICIT NONE

> REAL(8),allocatable:: X(:)

> REAL(8) fun

> INTEGER n

> COMMON n

> READ*,n

> ALLOCATE (x(n))

> READ*,x

> PRINT*,fun(x)

> end

> function fun(x)

> implicit REAL(8) (a-z)

> DIMENSION x(n)

> INTEGER n

> COMMON n

> fun=x( 1 )+x( 2 )

> END function fun

You failed to mention the version of gfortran that you used.

If you have 4.0.x, then upgrade to at least 4.1.1 (which was

released yesterday :-).

troutmask:kargl[205] gfortran -o z a.f90

troutmask:kargl[206] ./z

2

1

1

2.00000000000000

--

Steve

http://www.*-*-*.com/ ~kargl/