/* -----------------------------------------------------!
! The current code has two purposes:                    !
! (1) using Intel and PGI compilers and see how         !
!     OMP_NUM_THREADS was set by default.               !  
! (2) demonstrate how private variables behave outside  !
!     of parallell regions.                             !
!-------------------------------------------------------!
! Xiaoxu Guan at LSU HPC.                               !
! March 07, 2016                                        !
!----------------------------------------------------- */

#include <omp.h>
#include <stdio.h>
#include <stdlib.h>

int main () {

int k,id,nothread;

#pragma omp parallel private (k,id) shared (nothread)
    {
      nothread = omp_get_num_threads();
      id = omp_get_thread_num();
      k = id + id;
    }


printf("Hello from the master, k = %d\n", k);


#pragma omp parallel private(k,id)
  {
      printf("Hello: = %6d %6d %6d\n", id, k, nothread);
  }


}

