# Introduction to structured programming with Fortran
https://dev.to/nikolab/complete-list-of-github-markdown-emoji-markup-5aia
Author: P.Y. Barriat

Notes for presenter.

```fortran module subs contains subroutine asub (i, control) implicit none integer, intent (in) :: i logical, intent (in) :: control integer, save :: j = 0 integer :: k j = j + i if ( control ) k = 0 k = k + i write (*, *) 'i, j, k=', i, j, k end subroutine asub end module subs program test_saves use subs implicit none call asub ( 3, .TRUE. ) call asub ( 4, .FALSE. ) end program test_saves ``` Local variable k of the subroutine is intentionally misused -- in this program it is initialized in the first call since control is TRUE, but on the second call control is FALSE, so k is not redefined. But without the save attribute k is undefined, so the using its value is illegal. ```fortran i, j, k= 3 3 3 i, j, k= 4 7 7 ``` Compiling the program with ifort and aggressive optimization options, k lost its value: ```fortran i, j, k= 3 3 3 i, j, k= 4 7 4 ```