sub.f90
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
sub.c
#include<stdio.h>
#include <omp.h>
 
int main(int argc, char** argv)
{
	int a = 22;
	int b = 67;
	int c = 53;
	int i;
 
#pragma omp parallel shared(a) firstprivate(b) default(shared)
{
	b = addrank(a);
	printf(" I have the value : %d and my rank is %d\n",b,omp_get_thread_num());
#pragma omp for
	for (i = 0; i < 4; i++ )
		b = mul2(b);
 
	printf(" I have the value : %d and my rank is %d\n",b,omp_get_thread_num());   
}
 
	return 0;
}
 
int addrank(int o)
{
	return o + omp_get_thread_num();
}
 
int mul2(int p)
{
	return p*2;
}