mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
30 lines
569 B
Fortran
30 lines
569 B
Fortran
! @@name: cancellation.1f
|
|
! @@type: F-free
|
|
! @@compilable: yes
|
|
! @@linkable: no
|
|
! @@expect: success
|
|
subroutine example(n, dim)
|
|
integer, intent(in) :: n, dim(n)
|
|
integer :: i, s, err
|
|
real, allocatable :: B(:)
|
|
err = 0
|
|
!$omp parallel shared(err)
|
|
! ...
|
|
!$omp do private(s, B)
|
|
do i=1, n
|
|
!$omp cancellation point do
|
|
allocate(B(dim(i)), stat=s)
|
|
if (s .gt. 0) then
|
|
!$omp atomic write
|
|
err = s
|
|
!$omp cancel do
|
|
endif
|
|
! ...
|
|
! deallocate private array B
|
|
if (allocated(B)) then
|
|
deallocate(B)
|
|
endif
|
|
enddo
|
|
!$omp end parallel
|
|
end subroutine
|