suppose you have Fortran code that looks like
integer i
do i = 1, 10^6
program(i)
enddo
and would like to add the ability to pause the program while it's running, without loosing your progress.
integer i
integer pause_variable
open(20,'pause_file.input')
read(20) pause_variable
if (pause_variable > 0) then
% program was previously paused, read interrupt data
open(21,'interrupt_variables.dump')
read(21) interrupted variables
close(20)
write(20) pause_variable*(-1) % switch back to run mode
endif
close(20)
do i = 1, 10^6
program(i)
open(20,'pause_file.input')
read(20) pause_variable
close(20)
if (pause_variable > 0)
% pause now
open(21,'interrupt_variables.dump')
write(21) interrupted variables
close(21)
exit
endif
enddo