/
savey.f
35 lines (29 loc) · 956 Bytes
/
savey.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C @file savey.f
C @Author Mitch Richling<https://www.mitchr.me>
C @Copyright Copyright 1993 by Mitch Richling. All rights reserved.
C @brief Illustrates save statement in Fortran 77.@EOL
C @Keywords save statement FORTRAN f77
C @Std F77
C
program savey
integer i
integer memfun
do 10 i=1,10
write (*,*) 'memfun()... =', memfun()
10 continue
write (*,*) "DONE"
end
C This function illustrates the use of the save statement
integer function memfun()
C Declare our "saved" variable
integer lastv
C Tell the compiler to save this value upon exit
save lastv
C Set lastv to '0' the FIRST TIME the function runs.
data lastv/0/
C The result of the function as normal..
lastv = lastv + 1
memfun=lastv
return
end