Parallel FORTRAN output varies with addition of arbitrary WRITE statement

Click For Summary
SUMMARY

The forum discussion centers on the impact of an arbitrary WRITE statement in a parallel FORTRAN code block, specifically within an OpenMP parallel loop. The inclusion of the WRITE(*,*) statement leads to correct results, while its absence produces inconsistent and erroneous outputs. This behavior is attributed to the WRITE statement affecting the timing of operations, which in turn influences the execution of parallel tasks. The issue highlights the importance of understanding how I/O operations can impact parallel computation in FORTRAN.

PREREQUISITES
  • Familiarity with FORTRAN programming language
  • Understanding of OpenMP parallel processing
  • Knowledge of parallel computing concepts
  • Experience with debugging parallel code
NEXT STEPS
  • Investigate the effects of I/O operations on parallel execution in FORTRAN
  • Learn about OpenMP synchronization mechanisms
  • Explore techniques for debugging parallel FORTRAN applications
  • Study performance optimization strategies for parallel computing
USEFUL FOR

This discussion is beneficial for FORTRAN developers, parallel computing researchers, and anyone involved in optimizing performance in parallelized applications.

Hemmer
Messages
15
Reaction score
0
Hi there,

I've been puzzling over the following code (which works in serial). It produces radically different answers if the (blank) WRITE(*,*) is included or not. Any help greatly appreciated!

Code:
eps = 0.0

  !$omp parallel do default(none) private(i, j, current_angle, current_energy) &
  !$omp shared(a, N, J_0, eps)
    do j = 1, N
       do i = 1, N

          ! find energy
          current_angle = a(i,j)
          call get_neighbouring_contrib(a, current_angle, i, j, current_energy, J_0, N)

          [B]!if i have this (or any) WRITE statement, program gets answer correct
          !otherwise get garbage results which vary each time[/B]
          write(*,*)

          ! and sum
          !$omp atomic
          eps = eps + current_energy
       end do
    end do
    !$omp end parallel do
 
Technology news on Phys.org
Just a guess. The WRITE statement drastically alters the timing, which affects parallel operations. It might even trigger a timeout.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
11
Views
16K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K