! This is a basic starting shell for your programs MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const ! PROGRAM prog USE const IMPLICIT NONE ! ! Program to demonstrate counting loops INTEGER :: i,j,total WRITE(*,*) 'Simple Count to 10 loop' DO i = 1,10,1 WRITE(*,*) 'i = ',i ENDDO WRITE(*,*) 'Simple Count Odds from 1 to 10' DO i = 1,10,2 WRITE(*,*) 'i = ',i ENDDO WRITE(*,*) 'More advanced stepping loop' DO i = -4,9,8 WRITE(*,*) 'i = ',i ENDDO WRITE(*,*) 'Empty loop. This loop never executes' DO i = 10,1 WRITE(*,*) 'i = ',i ENDDO WRITE(*,*) 'Counting Backwards' DO i = 10,1,-1 WRITE(*,*) 'i = ',i ENDDO WRITE(*,*) 'Nesting loops' DO i = 1,5 DO j = -3,-1 WRITE(*,*) 'i, j = ',i,j ENDDO WRITE(*,*) ENDDO WRITE(*,*) 'Nesting loops, j limit depends on i' DO i = 1,5 DO j = 1,i WRITE(*,*) 'i, j = ',i,j ENDDO WRITE(*,*) ENDDO WRITE(*,*) 'Simple summation problem' total = 0 DO i = 1,100 total = total + i**2 + i ENDDO WRITE(*,*) 'total = ',total END PROGRAM prog