gfortran6 with OpenACC - error

Cesar Philippidis cesar@codesourcery.com
Tue Apr 26 15:16:00 GMT 2016


On 04/26/2016 08:08 AM, Anton Shterenlikht wrote:
> gfortran  6.0.0 20160410 on linux.
> Compiling with *no* -fopenacc works fine,
> and the serial program runs as expected.
> Compiling with -fopenacc gives an error.
> Am I using OpenACC directives wrongly?
> 
> newblue4> cat z.f90 
> program z
> implicit none
> integer, parameter :: d1 = 1000, d2 = 1000
> real :: tmp( (d1-2) *(d2-2) )
> real, allocatable :: arr(:,:), old(:,:)
> integer :: i,j,k
> 
> ! allocate and set all to zero
> allocate( arr(d1,d2), source = 0.0 )
> allocate( old(d1,d2) )
> 
> ! set inner cells to random numbers
> call random_number(tmp)
> arr( 2:d1-1 , 2:d2-1 ) = reshape( tmp, (/ d1-2, d1-2 /) ) 
> 
> !$acc data copy(arr)
> write (*,*) "before:", sum(abs(arr))
> 
> do i=1,1000
>   old = arr
> 
> !$acc kernels
>   do j=2,d1-1
>   do k=2,d2-1
>     arr(j,k) = 0.25 * ( old(j-1,k) + old(j+1,k) + old(j,k-1) + old(j,k+1) )
>   end do
>   end do
> !$acc end kernels
> 
> end do
> 
> write (*,*) "after:", sum(abs(arr))
> 
> end program z
> newblue4> 
> 
> newblue4> gfortran -O2 z.f90 -Wall -o gfort-acc.x
> newblue4> time ./gfort-acc.x 
>  before:   497871.688    
>  after:   464004.844    
> 9.102u 0.006s 0:09.13 99.6%     0+0k 0+0io 0pf+0w
> newblue4> 
> 
> newblue4> gfortran -fopenacc -O2 z.f90 -Wall -o gfort-acc.x
> z.f90:34:3:
> 
>  end program z
>    1
> Error: Unexpected END statement at (1)
> f951: Error: Unexpected end of file in ‘z.f90’
> newblue4>

This program missing an "!$acc end data" to mark the end of the data region.

Cesar



More information about the Fortran mailing list