Is it possible to assign a variable once and only once at the start of a loop iteration via some kind of pattern in Fortran? Similar to the pseudocode below. What I have now is an If statement that checks if a flag is set and if it is we execute the if statement. Then we unset it, since my program is parallel I would like to avoid conditional branching in my innermost loop. From what I have seen it is possible to do in C++, but I wonder if I can achieve the same thing in Fortran somehow.
What I am looking for:
!$OMP DO PRIVATE(variable)
DO i = 0, N = 100000
<Set Variable to a fixed value once and only once at the start of the iteration>
<CODE>
END DO
!$END OMP DO
What I have
!$OMP DO PRIVATE(variable)
DO i = 1, N = 100000
IF (FLAG_IS_SET) THEN
<Set variable>
<UNSET_THE_FLAG>
END IF
<CODE>
END DO
!$END OMP DO