Common statement does not work with gfortran, but g95 gives the correct answer 
Author Message
 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. ?gfortran 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/



Wed, 12 Nov 2008 05:53:54 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Gfortran 2 years behind G95 and still not ready for prime time

2. Torn-off menus not given correct title

3. Write statement does not print correct value?

4. http://www.g95.org site not working

5. clock scan does not work correct (JAN 29 30 31)

6. automatic arrays with negative size in g95 and gfortran

7. gfortran or g95

8. gfortran vs. g95

9. difference between g95 and gfortran

10. g95 AND gfortran problem ONLY on PPC OSX Tiger

11. Compiler flags for compiling FEM2DLiB with g95 and/or gfortran

12. problem with very small numbers - g95 versus gfortran

 

 
Powered by phpBB® Forum Software