0 Replies - 3779 Views - Last Post: 13 June 2012 - 01:16 PM Rate Topic: -----

#1 trav9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-June 12

OpenMP threading problem in Fortran

Posted 13 June 2012 - 01:16 PM

I am trying to create a fortran code that will use openMP amongst different cores in order to solve a simple do loop calculation. I want to be able to dynamically allocate the number of threads and monitor which threads are doing what. I am having trouble in using the PARALLEL DO along with both SCHEDULE and PRIVATE. The code runs as is, but won't once I uncomment the p,d, and id lines in order to monitor the code. Any help would be appreciated.
PROGRAM TEST
use omp_lib          ! Fortran 90; omp_get_thread_num, omp_get_num_threads
implicit none

    ! Serial Region  (master thread)
    ! Parameters of the Application
    

    ! OpenMP Parameters
    REAL*8 id, sum, t, s, r, z, w
    integer i, j, nthreads, chunk
    logical p, d
    w = 3
    
    ! Master thread obtains information about itself and its environment.
    !nthreads = omp_get_num_threads()       ! get number of threads
    !id = omp_get_thread_num()              ! get thread
    !WRITE (*,*) 'Serial NTHREADS: ',nthreads



    !$OMP PARALLEL DO SCHEDULE(DYNAMIC) PRIVATE(id, nthreads,p,d)
       !nthreads = omp_get_num_threads()    ! get number of threads
       !p = OMP_IN_PARALLEL()  
       !d = OMP_GET_DYNAMIC()
       !id = omp_get_thread_num()          ! get thread  
       	
       do j = 0,100,2
         do i = 0,100,2
            t = t + i
            s = s+i/2
            r = 4/3*3.141592*i**1.5
            z = w/(i+1)
            write(*,*) 'i,j =', i,j
            write(*,*) 't =', t
            write(*,*) 's =', s
            write(*,*) 'r =', r
            write(*,*) 'z =', z
            write (*,*) 'thread =', id
         enddo
       enddo  
            
       !WRITE (*,*) 'Parallel NTHREADS: ',nthreads
       !WRITE (*,*) 'This loop is in parallel: ',p   
       !WRITE (*,*) 'This loop is dynamically threaded: ',d
    !$OMP END PARALLEL DO
   

   
END PROGRAM TEST


This post has been edited by GunnerInc: 13 June 2012 - 06:23 PM
Reason for edit:: Fixed code tags


Is This A Good Question/Topic? 0
  • +

Page 1 of 1