変数のsave属性
SAVE属性の解説
http://www7b.biglobe.ne.jp/~fortran/education/fortran90/sec8.html
http://jjoo.sakura.ne.jp/tips/f90/initial_save.html
サンプル
2019-01-29_13-22
/work2/am/TOOLS/CODING_SAMPLE/FORTRAN_SAVE
am@localhost
$ cat fortran_save.f90
program fortran_save
a=100
call sub(a,b)
call sub_save(a,b)
a=0
call sub_save(a,b)
end program fortran_save
subroutine sub(a)
real,intent(in)::a
print *,'IN SUB: a=',a
end subroutine sub
subroutine sub_save(a)
real,intent(in)::a
real,save::b
print *,'IN SUB_SAVE: a=',a
if(a==100)then
b=a
end if
print *,'IN SUB_SAVE: b=',b
end subroutine sub_save
2019-01-29_13-22
/work2/am/TOOLS/CODING_SAMPLE/FORTRAN_SAVE
am@localhost
$ ifort -o fortran_save.exe fortran_save.f90
2019-01-29_13-22
/work2/am/TOOLS/CODING_SAMPLE/FORTRAN_SAVE
am@localhost
$ fortran_save.exe
IN SUB: a= 100.0000
IN SUB_SAVE: a= 100.0000
IN SUB_SAVE: b= 100.0000
IN SUB_SAVE: a= 0.0000000E+00
IN SUB_SAVE: b= 100.0000