! -------------------------------
! Intro to Open MP programming
! -------------------------------
        PROGRAM Hello 

        INTEGER :: nthreads, myid, i
	INTEGER, EXTERNAL :: OMP_GET_THREAD_NUM, OMP_GET_NUM_THREADS 

	i = 1000

! Make the values of nthreads and myid PRIVATE to each thread 

!$OMP PARALLEL PRIVATE(nthreads, myid)

        !! Every thread does this
        myid = OMP_GET_THREAD_NUM() 
	i = i + 1
        print *, ' Hello I am thread ', myid, " --- i = ", i

! If I am the master node print number of threads 

	!! Only thread 0 does this
        IF (myid == 0) THEN 
          nthreads = OMP_GET_NUM_THREADS() 
          print *, ' Number of threads = ', nthreads 
        end if 

!$OMP END PARALLEL 
        END 
