integer i, n, sum sum = 0 do 10 i = 1, n sum = sum + i write(*,*) 'i =', i write(*,*) 'sum =', sum 10 continue¼ýÀÚ 10 Àº ¹®Àå ¹øÈ£ labelÀÌ´Ù. º¸Åë ÇÑ ÇÁ·Î±×·¥ ¾È¿¡ ¹®Àå ¹øÈ£°¡ ÇÊ¿äÇÑ loop¿Í ´Ù¸¥ ¹®ÀåÀÌ ¸¹ÀÌ ÀÖ´Ù. °¢°¢ÀÇ ÇÁ·Î±×·¥ (¶Ç´Â ºÎÇÁ·Î±×·¥) ¾È¿¡¼ °íÀ¯ÀÇ ¹®Àå ¹øÈ£¸¦ ºÎ¿©Çϵµ·Ï ÁÖÀÇÇÏ¿©¾ß ÇÑ´Ù. Ä (column) 2-5´Â ÀÌ ¹®Àå ¹øÈ£¸¦ Àû´Â °÷ÀÌ´Ù. ¹®Àå ¹øÈ£·Ñ »ç¿ëÇÏ´Â ¼ýÀÚ´Â Àǹ̰¡ ¾øÀ¸¹Ç·Î ¾î¶²ÇÑ Á¤¼ö¸¦ »ç¿ëÇÏ¿©µµ °ü°è¾ø´Ù. º¸Åë ÇÑ ¹ø¿¡ 10¾¿ Áõ°¡Çϵµ·Ï ÇÑ´Ù.
do-¹®Àå¿¡¼ Á¤ÀÇÇÑ º¯¼ö´Â Ưº°ÇÑ ¸í·ÁÀÌ ¾ø´Â ÇÑ 1¾¿ Áõ°¡ÇÑ´Ù. ±×·¯³ª step À» »ç¿ëÇÏ¿© ±× Áõ°¡·®À» ´Ù¸¥ Á¤¼ö·Î ¹Ù²Ü ¼ö ÀÖ´Ù. ´ÙÀ½Àº 1ºÎÅÍ 10»çÀÌÀÇ Â¦¼ö¸¦ Å« ¼öºÎÅÍ ÀμâÇÏ´Â ÇÁ·Î±×·¥ÀÌ´Ù.
integer i do 20 i = 10, 1, -2 write(*,*) 'i =', i 20 continue
do loopÀÇ ÀϹÝÀûÀÎ ÇüÅ´ ´ÙÀ½°ú °°´Ù.
do label var = expr1, expr2, expr3 statements label continuevar ´Â loop º¯¼ö (¶Ç´Â loop index¶ó°íµµ ÇÑ´Ù)´Â Á¤¼öÇüÅÂÀ̾î¾ß ÇÑ´Ù. expr1 ´Â varÀÇ ÃʱⰪ, expr2 ´Â Á¾·á ÇÑ°èÀÌ°í expr3 ´Â Áõ°¡(step)ÀÌ´Ù.
ÁÖÀÇ : do-loop º¯¼ö¸¦ loop ¾È¿¡¼ ´Ù¸¥ ¹æ¹ýÀ¸·Î ¹Ù²Ù¾î¼´Â ¾ÈµÈ´Ù. ÀÌ °æ¿ì ½É°¢ÇÑ È¥¶õÀ» ÃÊ·¡ÇÑ´Ù.
¸¹Àº Fortran 77 compiler¿¡¼ do-loop¸¦ enddo ¹®ÀåÀ¸·Î ³¡³¾ ¼ö ÀÖµµ·Ï ÇÑ´Ù. ÀÌ °æ¿ìÀÇ ÀåÁ¡Àº enddo°¡ ¾Õ¿¡¼ »ç¿ëÇÑ °¡Àå ÃÖ±ÙÀÇ do ¹®ÀåÀÇ ³¡À» ÀǹÌÇϹǷΠ¹®Àå ¹øÈ£¸¦ »ç¿ëÇÏÁö ¾Ê¾Æµµ µÈ´Ù´Â Á¡ÀÌ´Ù. enddo ±¸Á¶´Â »ó´çÈ÷ ¸¹ÀÌ »ç¿ëµÇÁö¸¸ Ç¥ÁØ ANSI Fortran 77Àº ¾Æ´Ï´Ù.
while (logical expr) do statements enddoÀ̰ųª
do while (logical expr) statements enddoÀÌ´Ù. while ¹®ÀÌ Âü(true)ÀÎ ÇÑ ³»ºÎÀÇ ¹®ÀåµéÀ» ¹Ýº¹ÇÑ´Ù. ÀÌ syntax¸¦ ¿©·¯ ÄÄÇ»ÅÍ¿¡¼ »ç¿ëÇÒ ¼ö ÀÖ±â´Â Çϳª ANSI Fortran 77Àº ¾Æ´Ï´Ù. ¿Ã¹Ù¸¥ ¹æ¹ýÀº if¿Í goto¸¦ »ç¿ëÇÏ´Â °ÍÀÌ´Ù.
label if (logical expr) then statements goto label endif
´ÙÀ½Àº 100º¸´Ù À۰ųª °°Àº ¼ö¸¦ 2ÀÇ Áö¼ö·Î ÇÏ¿© ±× °ªÀ» °è»êÇÏ°í ÀμâÇÏ´Â ÇÁ·Î±×·¥ÀÌ´Ù.
integer n n = 1 10 if (n .le. 100) then n = 2*n write (*,*) n goto 10 endif
do statements until (logical expr)Fortran 77¿¡¼´Â ÀÌ ¿ª½Ã if¿Í goto¸¦ »ç¿ëÇÏ¿© ±¸¼ºÇÏ¿©¾ß ÇÑ´Ù.
label continue statements if (logical expr) goto label¸¶Áö¸·ÀÇ ³í¸®½ÄÀÌ À¯»ç ÄÚµåÀÇ ³í¸®½ÄÀÇ ºÎÁ¤À̾î¾ß ÇÑ´Ù´Â Á¡À» ÁÖÀÇÇ϶ó.
do i = 10, 1, -2 write(*,*) 'i =', i end dowhile °ú until loopµµ do-enddo ±¸Á¶·Î ±¸¼ºÇÒ ¼ö ÀÖÀ¸³ª conditional exit ¹®À» ´õÇÏ¿©¾ß ÇÑ´Ù. ÀϹÝÀûÀÎ °æ¿ì¿¡´Â
do statements if (logical expr) exit statements end doexit Á¶°ÇÀÌ ¾Õ¿¡ ÀÖÀ¸¸é while loopÀÌ°í ¸Ç µÚ¿¡ ÀÖÀ¸¸é until loopÀÎ ¼ÀÀÌ´Ù.
i = 1 while (i<100) do sum = sum + i i = i+2 enddo i = 0 x = 1.0 repeat x = f(x) i = i+1 until (x<0) write(*,*) i, x
i = 1 sum = 0 10 do 20 i = 1, 50 if (i .gt. 10) goto 30 sum = sum + i 20 continue 30 if (i. le. 20) then sum = sum - 1 goto 20 else sum = 2*sum endif write(*,*) 'Sum =', sum