AS far as i could find, the condition (IDfim(w).ne. BolID(1)), although the values are exactly the same is not stopping the loop. can't figure out why. I tested with print of values before and after the do while, and the value is always the same and equal on both variables.