sections.f90
program sections
!$ use OMP_LIB
	implicit none
	integer :: rank, tnot
 
!$OMP PARALLEL PRIVATE(rank) DEFAULT(SHARED)
	rank = OMP_GET_THREAD_NUM () ! get the rank of current thread
	tnot =  OMP_GET_NUM_THREADS() ! get the total number of threads currently running this PR
!$OMP SECTIONS
!$OMP SECTION
	print *,"I am rank",rank,"and I am in section 1"
	call system("sleep 1s")
!$OMP SECTION
	print *,"I am rank",rank,"and I am in section 2"
	call system("sleep 1s")
!$OMP SECTION
	print *,"I am rank",rank,"and I am in section 3"
	call system("sleep 1s")
!$OMP END SECTIONS ! NOWAIT can be used here
!$OMP END PARALLEL
 
end program sections
sections.c
#include <stdlib.h>
#include <stdio.h>
#include <omp.h>
 
int main(int argc, char** argv)
{
	int rank, tnot;
 
#pragma omp parallel private(rank) default(shared)
{
	rank = omp_get_thread_num (); // get the rank of current thread
	tnot = omp_get_num_threads(); // get the total number of threads currently running this PR
 
#pragma omp sections
{
#pragma omp section
{
	printf("I am rank %d and I am in section 1\n", rank);
	sleep(1);
}
#pragma omp section
{
	printf("I am rank %d and I am in section 2\n", rank);
	sleep(1);
}
#pragma omp section
{
	printf("I am rank %d and I am in section 3\n", rank);
	sleep(1);
}
}
}
	return 0;
}