PGF90-S-0034-Syntax error for example of OpenACC user guide

Hi all,

I am a very beginner of PGI and OpenACC usage. I was trying to validate the installation of PGI and OpenACC on my environment with the simple example on page 24 (2.10.1) of this tutorial (http://www.pgroup.com/doc/openacc17_gs.pdf).

What I did is

  1. put code below into a file called “f1.f90”
module vecaddmod
 implicit none
contains
 subroutine vecaddgpu( r, a, b, n )
  real, dimension(:) :: r, a, b
  integer :: n
  integer :: i
!$acc kernels loop copyin(a(1:n),b(1:n)) copyout(r(1:n))
  do i = 1, n
   r(i) = a(i) + b(i)
  enddo
 end subroutine
end module
program main
 use vecaddmod
 implicit none
 integer :: n, i, errs, argcount
 real, dimension(:), allocatable :: a, b, r, e
 character*10 :: arg1
 argcount = command_argument_count()
 n = 1000000  ! default value
 if( argcount = 1 )then
  call get_command_argument( 1, arg1 )
  read( arg1, '(i)' ) n
  if( n <= 0 ) n = 100000
 endif
allocate( a(n), b(n), r(n), e(n) )
 do i = 1, n
  a(i) = i
  b(i) = 1000*i
 enddo
 ! compute on the GPU
 call vecaddgpu( r, a, b, n )
 ! compute on the host to compare
 do i = 1, n
  e(i) = a(i) + b(i)
  enddo
! compare results
 errs = 0
 do i = 1, n
  if( r(i) /= e(i) )then
    errs = errs + 1
  endif
 enddo
 print *, errs, ' errors found'
 if( errs ) call exit(errs)
end program
  1. try to compile it with pgfortran -acc f1.f90.

What I got is

“PGF90-S-0034-Syntax error at or near = (f1.f90: 22)
0 inform, 0 warnings, 1 severes, 0 fatal for main”

My PGI complier is of 17.4-0 64-bit target on x86-64 Linux -tp haswell version.

I am not sure where is going wrong. Could anyone help me with this?

Hi shizejin,

Looks like a typo in the code where line 22 should be:

 if( argcount == 1 ) then

i.e. equality operator versus the assignment operator.

Once I make this change, the code compiles and runs correctly.

I’ll see about getting our documentation fixed as well.

Thanks!
Mat

% pgf90 -ta=tesla:cc60 -Minfo=accel f1.f90
vecaddgpu:
      8, Generating copyin(a(:n))
         Generating copyout(r(:n))
         Generating copyin(b(:n))
      9, Loop is parallelizable
         Accelerator kernel generated
         Generating Tesla code
          9, !$acc loop gang, vector(128) ! blockidx%x threadidx%x
% a.out
            0  errors found

Hi Mat,

Thanks! After the modification it worked out!

Best,
Zejin