fortranfortran95

Fortran loop for discrete values


Is there any way to run a loop for discrete values of a variable? What about in some latest version?

Something like

for i in 1  5 9 11  31 77 

used in Unix shell script?


Solution

  • integer, dimension (5) :: indx = [5, 9, 11, 31, 71]
    
    do i=1, size(indx)
       j=indx(i)
       ....
    end do