lundi 22 janvier 2018

Exit Fortran do loop if criteria aren't met in an if statment [duplicate]

This question already has an answer here:

probably this is a trivial matter to most of you but it got me completely stuck. I have an IF block nested inside a DO loop; I need the loop to be interrupted in case the criteria stated in the IF block are not met. Here is my code:

 IF ( con(i) .GT. 1 ) THEN

    search_n1: DO j = 1, 10
      IF  ( CM(i,j) .EQ. 1 ) THEN
          n2 = i
          n1 = j
       ELSE
          CYCLE search_n1
       END IF
    END DO search_n1

 ELSE
    CYCLE
 END IF

(where CM and con are arrays defined in a previous part of the code).

Aucun commentaire:

Enregistrer un commentaire