OMP Barrier Fortran Solution

 PROGRAM USING_BARRIERS
      INTEGER omp_get_thread_num
      INTEGER A(20),B(20),C(20),I,J
      INTEGER D(20), E(20)
      DO I=1,20
         A(I)=0
         B(I)=I
         C(I)=2*I
         D(I)=21-I
      END DO
!$OMP PARALLEL PRIVATE(I,J)
      J = omp_get_thread_num()
!$OMP DO
      DO I=1,20
         A(I) = B(I)+C(I)+100*J
      END DO
!$OMP END DO NOWAIT
!$OMP BARRIER
!$OMP DO
      DO I=1,20
         E(I) = A(D(I))
      END DO
!$OMP END DO
!$OMP MASTER
      DO I=1,20
        WRITE(*,*)i, e(i), a(d(i))
      END DO
!$OMP END MASTER
!$OMP END PARALLEL
      END