/*  --------------------------------------------------- !
! The current OpenMP code has three purposes:           !
! (1) how loop iterations are mapped to threads.        !
! (2) demonstrates the work-sharing in parallel region. !
! (3) work-sharing does not spawn multiple threads.     !
!-------------------------------------------------------!
! Xiaoxu Guan at LSU HPC.                               !
! March 07, 2016                                        !
!----------------------------------------------------- */

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

int main () {

   int i,id,nothread;
   const int nsize = 40;


#pragma omp parallel private (id,i) shared(nothread)
   {
      id = omp_get_thread_num();
      nothread = omp_get_num_threads();
   /*   printf("Hello World! from ID %d out of %d\n", id, nothread);   */
#pragma omp for
      for(i = 1; i < nsize+1; ++i) {
          printf(" id = %d  i = %d\n", id, i); }

  }

}
