Re: How to halt a running program without losing data?
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Dec 2005 11:14:01 -0600
In article <1121086174.215125.289690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Random Programmer" <nonexistent2032@xxxxxxxxxxx> wrote:
> So, let's say you want to give the programmer precise control over when
> it stops - so you want the program to be able to be stopped from the
> shell/command prompt.
>
> Is there a Fortran command to get the program to pause if say Ctrl-C is
> hit and ask the user for a halt confirmation? I thought the best way
> might be to somehow change a variable that is stored in memory (e.g.
> iteration count), effectively "tricking" the program into thinking it
> has reached the end of it's calculations.
I think your question is not clear. The "programmer" already has
the control to stop a program in various ways. He could check the
iteration count, he could check for numerical convergence, he could
periodically prompt the user to determine whether to continue, he
could periodically read data from an external file, and so on.
However, you seem to also want the "user" of the program to be able
to stop the program at places or times in which the programmer did
not anticipate. This is more a property of the OS and shell than it
is of the fortran program. For example, in VAX/VMS I think the user
can type cntl-C to stop a program (followed by continue if he
changes his mind). In unix (in most interactive shells, at least),
cntl-Z followed by bg will suspend the program and then resume it in
the background (and fg will bring it back to the foreground if
desired). These things work for any process, using code written in
any language, with nothing particularly special required of the
programmer.
As far as changing variables in some external way, that is usually
something only done when the code is run under control of a
debugger. Also, the codes must usually be compiled in a special way
for this to happen (no optimization, with local symbol tables
saved). Normally, variables just get translated into memory
locations by the compiler, and the internal variable names and
symbols are no longer available at runtime. Or the variables you
used to define the operations are optimized away entirely and are
not available even in memory or register locations.
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: How to halt a running program without losing data?
- From: *** Russell
- Re: How to halt a running program without losing data?
- From: Richard E Maine
- Re: How to halt a running program without losing data?
- Prev by Date: Re: How to halt a running program without losing data?
- Next by Date: Re: How to halt a running program without losing data?
- Previous by thread: Re: How to halt a running program without losing data?
- Next by thread: Re: How to halt a running program without losing data?
- Index(es):