Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

File Access with OpenMP

$
0
0

Dear All,

I am having some difficulty with OpenMP and  Error severe (152): Unresolved contention for DEC Fortran RTL global resource.

Let me give you some background to my FORTRAN program. The program is threaded with OpenMP and the general layout is as follows:

  
  !$OMP PARALLEL 
  
  !$OMP SECTIONS
  !$OMP MASTER
  
  <Execution code to:
      read the individual direct access log files created by worker threads,
      concatenate the outputs and write them to a global log file><The master thread goes to sleep periodically if it has a problem accessing any individual log files>

  
  
  !$OMP END MASTER
  !$OMP END SECTIONS NOWAIT
 
  !$OMP DO SCHEDULE(DYNAMIC) ORDERED PRIVATE(        &
  !$OMP& <thread safe variables, including io-unit-numbers )<All io-unit numbers used in this section are unique to each thread.>  
  
  DO LOOP 1 TO N
     A thread is assigned to do work for each iteration of this loop.
     As the work progresses, a log file is being generated.
     Sometimes critical sections are being used to protect the access to the log files
         This may be an inefficiency as there is no concurrency between the worker threads.
         However, the master thread is accessing the individual files.
         Example of a critical section is shown below.
 
    
    !$OMP CRITICAL(LOG1PARA)
    log_rec_no = write_rec_no(thread_id)
    
    if(log_rec_no < 2) then
        log_rec_no = 2               
    end if
    
    write(temp_line1, fmt='(i0)') log_rec_no
    write(unit=log_file, rec=1), temp_line1
    !$OMP END CRITICAL(LOG1PARA)

    < more work and log output >
    
    !$OMP CRITICAL(LOG3PARA)
    temp_line1 = "Finished"
    write(log_file, rec=log_rec_no) temp_line1
    log_rec_no = log_rec_no + 1
    write_rec_no(id) = log_rec_no
    !$OMP END CRITICAL(LOG3PARA)
        
   
  end do
  !$OMP END DO
  
  !$OMP END PARALLEL

 

When I am running my program I am getting Run-Time Error 152, typically on a write statement for the log file as shown above. This error is not reproducible at will.

My program uses a Master Thread to read log files that are created by Worker Threads on the fly. The output needs to be seen as the program runs. How can I address this Error 152? Is there a better way, for example using locks?

I am relatively inexperienced when it comes to OpenMP. I appreciate any remarks or code snippets you can post.

Thank you.

 

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>