Fortran compiler strangeness

Steve Kargl sgk@troutmask.apl.washington.edu
Wed May 9 15:31:00 GMT 2007


On Wed, May 09, 2007 at 05:12:07PM +0200, Stefano Simonucci wrote:
> Hi. 
> 
>       program prova
>       parameter(Nx=10000,Ny=10000)
>       real*8 A(Nx,Ny),X(Nx),Y(Ny)
>       do i=1,Nx
>        X(i)=2./(Nx+1)*i-1

2. is a default real kind constant.

>       end do
>       do i=1,Ny
>        Y(i)=2./(Ny+1)*i-1

2. is a default real kind constant.

>       end do
>       do i=1,Nx
>       do j=1,Ny
>       A(i,j)=sin(1.+i+j);

1. is a default real kind constant.

>       end do
>       end do
>       end program
> 
> then I have execute the program
>  
> time ./a.out 
> 
> real    1m58.509s
> user    1m57.035s
> sys     0m0.792s
> 
> An analogous program in C takes 22 sec.

Your C code goes here, because I doubt that it is analogous.

> Then I have changed sin(1.+i+j) with sin(1.d0+i+j) 
> and I get the following execution time
> 
> real    0m23.868s
> user    0m22.737s
> sys     0m0.864s
> 
> This behaviour seems strange.

Why? sin(1.+i+j) and sin(1.d0+i+j) are different expression.
One does not require additional implicit type conversion
during the assignment.

-- 
Steve



More information about the Fortran mailing list