Search code examples
loopsif-statementfortranlogic

How does `loop` with `if(test) next` work in Mortran?


I have a Mortran code here.

loop<(do something)   
<k=1,n; if(test) next; 
(do another thing 1); (do another thing 2);
(do another thing 3);
>
>

What happens if the test statement is true? I guess the code execute do another thing 2 jumping over do another thing 1.

The above code snippet is part of the glmnet package in R. There is .Fortran("lognet",~~) in the package.


Solution

  • If test evaluates to .true. then then the program goes to the next iteration of this loop. See this Mortran User's Guide for more details.