Irregular Mesh: OpenMP Program

!$OMP PARALLEL, DEFAULT(SHARED)
!$OMP SINGLE
err = tol * 1e6
!$OMP END SINGLE
DO WHILE (err > tol)
    !$OMP DO, PRIVATE(flux), REDUCTION(+:err)
    DO i = 1, nedge
        flux = (y(iedge(i,1))-y(iedge(i,2)))/2
        !$OMP ATOMIC
        x(iedge(i,1)) = x(iedge(i,1)) - flux
        !$OMP ATOMIC
        x(iedge(i,2)) = x(iedge(i,2)) + flux
        err = err + flux(i)*flux(i)
    END DO
    !$OMP END DO
    !$OMP SINGLE
    err = err / nedge
    !$OMP SINGLE
    !$OMP DO
    DO j = 1, nnode
        y(i) = x(i)
    END DO
    !$OMP END DO
END DO
!$OMP END PARALLEL