- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your sketch code shows that you are protecting the log_file by two differently named critical sections.
These two sections can run concurrently, though each only by one thread at a time
Experiment with using
!$OMP CRITICAL(CRITICAL_log_file)
...
to protect _all_ writes, and possibly reads, to/from the log files
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If each worker thread has its own log file, and if (when) you need exclusive access between the worker thread and the master thread, then consider using OpenMP lock variables to protect the region.
Or if you have a small number of threads you could use SELECT/CASE and individual !$OMP CRITICAL(CRITICAL_log_file_1), ...2),... sections.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Jim!
I'll try and implement your suggestions.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page