0

This answer explains how to skip the first 5 lines of a file and read the following 5. But how do I skip a line when reading a file with Fortran if some condition is met, so that I don't know in advance which line I should skip? I wish a code that looks like this

     OPEN(1,FILE='file.txt',STATUS='old')
     DO    
      READ (1,*, END=10) a, b, c
      IF(condition is true) THEN skip this line
       ELSE do something
      END IF
     END DO
  10 CLOSE(1)
mattiav27
  • 655
  • 2
  • 9
  • 27
  • The question is perhaps slightly unclear. Do you intend to "skip" a line based on that line itself (the duplicate question) or skip the _next_ line if the processed line meets a condition (in which case the read of the linked question)? – francescalus Sep 12 '19 at 10:02
  • No I want to skip the line itself – mattiav27 Sep 12 '19 at 10:38
  • ok, that's what I thought you meant when proposing that duplicate. If you can't find your answer there, please edit the question with more detail. – francescalus Sep 12 '19 at 10:53

0 Answers0