program subroutines
!$ use OMP_LIB
implicit none
integer :: a=22,b=67,c=53,i
!$OMP PARALLEL SHARED(a) PRIVATE(b) DEFAULT(SHARED)
call addrank(a,b)
print *,"I have the value :",b," and my rank is",OMP_GET_THREAD_NUM ()
!$OMP DO
do i=1,4
call mul2(b)
end do
!$OMP END DO
print *,"I have the value :",b," and my rank is",OMP_GET_THREAD_NUM ()
!$OMP END PARALLEL
end program subroutines
subroutine addrank(o,p) ! add rank to o and return in p
!$ use OMP_LIB
integer, intent(in) :: o
integer, intent(out) :: p
p = o + OMP_GET_THREAD_NUM ()
end subroutine addrank
subroutine mul2(p) ! mul p by 2
integer, intent(inout) :: p
p = p * 2
end subroutine mul2