mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
40 lines
734 B
Fortran
40 lines
734 B
Fortran
! @@name: requires.1f90
|
|
! @@type: F-free
|
|
! @@compilable: yes, omp_5.0
|
|
! @@linkable: yes
|
|
! @@expect: success
|
|
|
|
module data
|
|
!$omp requires unified_shared_memory
|
|
type,public :: mypoints
|
|
double precision :: res
|
|
double precision :: data(500)
|
|
end type
|
|
end module
|
|
|
|
program main
|
|
use data
|
|
type(mypoints) :: p
|
|
integer :: q=0
|
|
|
|
!$omp target !! no map clauses needed
|
|
q = q + 1 !! q is firstprivate
|
|
call do_something_with_p(p,q)
|
|
!$omp end target
|
|
|
|
write(*,'(f5.0,i5)') p%res, q !! output 1. 0
|
|
|
|
end program
|
|
|
|
subroutine do_something_with_p(p,q)
|
|
use data
|
|
type(mypoints) :: p
|
|
integer :: q
|
|
|
|
p%res = q;
|
|
do i=1,size(p%data)
|
|
p%data(i)=q*i
|
|
enddo
|
|
|
|
end subroutine
|