!-------------------------------------------------------!
! 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                                        !
!-------------------------------------------------------!

      program privatevar
      implicit none
      integer   :: k,id,nothread,omp_get_num_threads,omp_get_thread_num


!$omp parallel private (k,id)
       nothread = omp_get_num_threads() 
       id = omp_get_thread_num()
       k = id + id
!$omp end parallel


       write(*,*) 'Hello from the master. k = ', k


!$omp parallel private (k,id)
       write(*,*) 'Hello: ', id, k, nothread
!$omp end parallel


      end program privatevar


