- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I have a section of OpenMP parallel loop as follow.
#ifdef OPENMP
!$omp parallel &
!$omp num_threads(numofthreads_global) &
!$omp default(shared) &
!$omp private(ivol) &
!$omp lastprivate(param2, param3)
!$omp do schedule(static)
#endif
do ivol=1,nn
call subroutineX(param(ivol), param2, param3)
end do
#ifdef OPENMP
!$omp end do
!$omp end parallel
#endif
error #5082: Syntax error, found 'LASTPRIVATE' when expecting one of: PRIVATE REDUCTION FIRSTPRIVATE NUM_THREADS COPYIN SHARED DEFAULT
So I modified the codes as follows,
#ifdef OPENMP
!$omp parallel &
!$omp num_threads(numofthreads_global) &
!$omp default(shared) &
!$omp private(ivol) &
!$omp firstprivate(param2, param3) &
!$omp lastprivate(param2, param3)
!$omp do schedule(static)
#endif
do ivol=1,nn
call subroutineX(param(ivol), param2, param3)
end do
#ifdef OPENMP
!$omp end do
!$omp end parallel
#endif
But this time I will get one more error
error #6761: An entity cannot appear explicitly in more than one clause per directive except that an entity can be specified in both a FIRSTPRIVATE and LASTPRIVATE clause
I was confused on the error tips. The syntax is simple and seems correct.
Any suggestion?
Thanks and regards,
Daniel
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The compiler diagnostic is correct -- the 'plain' PARALLEL directive does not accept the LASTPRIVATE clause. This is not a legal OMP program:
subroutine foo
implicit none
integer param2,param3
!$omp parallel lastprivate(param2, param3)
!$omp end parallel
end subroutine foo
You have to apply LASTPRIVATE to a worksharing construct such as DO/PARALLEL DO, or SECTIONS/PARALLEL SECTIONS.
Just append your lastprivate clause to the !$omp do, and all will be fine:
subroutine foo
implicit none
integer ivol, numofthreads_global,param2,param3,nn
integer, dimension(:), allocatable :: param
nn = 10
numofthreads_global = 4
allocate (param(nn))
!$omp parallel &
!$omp num_threads(numofthreads_global) &
!$omp default(shared) &
!$omp private(ivol) &
!$omp firstprivate(param2, param3)
!$omp do schedule(static) lastprivate(param2, param3)
do ivol=1,nn
call subroutineX(param(ivol), param2, param3)
end do
!$omp end do
!$omp end parallel
end subroutine foo
C:\ISN_Forums\U489451>ifort -Qopenmp -c openmp_sub_fix.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.176 Build 20140130
Patrick

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page