PROGRAM  Main

implicit none

include 'mpif.h'

integer :: ierr, numprocs
integer  :: numthreads, myid,tid,i,j
integer, external :: OMP_GET_THREAD_NUM, OMP_GET_NUM_THREADS
!double precision :: busy

! MPI Initialization 
      call MPI_INIT (ierr)
      call MPI_COMM_SIZE (MPI_COMM_WORLD, numprocs,ierr)
      call MPI_COMM_RANK (MPI_COMM_WORLD, myid, ierr)

      !Make myid start at 1, make output more intuitive 
       myid = myid+1


!$OMP PARALLEL private(numthreads, tid)

   tid = OMP_GET_THREAD_NUM()
   tid = tid+1

   write(6,*) "Thread=",tid," proc=",myid
   call system("hostname")

!For doing timing/scaling tests, 
!Do something that takes a long time
!   do i=1,100000
!      do j=1,100000
!      busy = sin(1.*i)
!      enddo
!   enddo

!$OMP END PARALLEL

    call MPI_FINALIZE(ierr)

END
