Re: how to rerun subroutine only? [message #42721] |
Mon, 21 February 2005 14:52 |
u2s5thmember
Messages: 11 Registered: January 2004
|
Junior Member |
|
|
Your idea helped me figure out exactly what I was looking for! This
allows me to reduce the time for this subroutine to recalculate some
equations by 99.8%! I would have the subroutine as its own file, but
the main program and all its prior subroutines generate the arrays used
by the subroutine in question. I knew there had to be a way to do this
more efficiently - THANKS!
Vinay L. Kashyap wrote:
> Depends..
>
> There is no way to move flow control to the beginning of the
> program (that I know of), but if simple debugging is all you
> want to do, then yes.
>
> First get out of the subroutine with a ".out" or a "return" or
> a "return,-1", then recompile that subroutine (if it is in a
> separate file; this won't work if subroutine is in the same file
> as the main program), and simply call it with the same calling
> sequence as you did in the main program. Make sure you feed it
> the right variables in the parameters, because they may have
> changed in value or property in the interim.
>
> Vinay
> --
>
____________________________________________________________ __________________
> kashyap@head.cfa.harvard.edu 617 495 7173 [CfA/P-145] 617 496
7173 [F]
|
|
|
Re: how to rerun subroutine only? [message #42722 is a reply to message #42721] |
Mon, 21 February 2005 13:32  |
kashyap
Messages: 26 Registered: April 1993
|
Junior Member |
|
|
In article <1109014029.766542.64110@g14g2000cwa.googlegroups.com>,
<u2s5thmember@yahoo.com> wrote:
> this is probably a beginner question, so I appreciate your patience:
>
> Suppose I compile & run a top level program, then it enters a
> subroutine. Then suppose I want the code to stop somewhere in the
> subroutine so I can plot variables or check on/plot the results of a
> calculation... or say the subroutine encounters an error. then I might
> change something in the subroutine and need to rerun the subroutine.
>
> right now I recompile the subroutine then rerun the entire code
> starting from the beginning of the toplevel program, when all I really
> need to do is have idl redo the calculations from the beginning of the
> subroutine.
>
> is there a way to do this?
>
> thanks in advance for your time!
Depends..
There is no way to move flow control to the beginning of the
program (that I know of), but if simple debugging is all you
want to do, then yes.
First get out of the subroutine with a ".out" or a "return" or
a "return,-1", then recompile that subroutine (if it is in a
separate file; this won't work if subroutine is in the same file
as the main program), and simply call it with the same calling
sequence as you did in the main program. Make sure you feed it
the right variables in the parameters, because they may have
changed in value or property in the interim.
Vinay
--
____________________________________________________________ __________________
kashyap@head.cfa.harvard.edu 617 495 7173 [CfA/P-145] 617 496 7173 [F]
|
|
|
Re: how to rerun subroutine only? [message #42726 is a reply to message #42722] |
Mon, 21 February 2005 12:57  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
>> this is probably a beginner question, so I appreciate your patience:
>>
>> Suppose I compile & run a top level program, then it enters a
>> subroutine. Then suppose I want the code to stop somewhere in the
>> subroutine so I can plot variables or check on/plot the results of a
>> calculation... or say the subroutine encounters an error. then I might
>> change something in the subroutine and need to rerun the subroutine.
>>
>> right now I recompile the subroutine then rerun the entire code
>> starting from the beginning of the toplevel program, when all I really
>> need to do is have idl redo the calculations from the beginning of the
>> subroutine.
>>
>> is there a way to do this?
>
>
> No. :-)
>
Short and sweet response there, David. While correct, I believe it can
be expanded just a tad. :-)
If you want your code to stop running, use the 'stop' procedure. When
your code encounters a stop, it will immediately stop executing and
you'll be left in interactive mode. You can put the stop within a catch
block of the subroutine you're working on and whenever an error is
encountered the program will stop and you'll be able to look at
variables, run other commands, etc. Just make sure to remove the stop
before distributing your program.
If you want to redo calculations of the subroutine only, you'll need to
break the subroutine out into it's own file. I don't know if anyone
else does this, but I will usually first write subroutines in their own
files just so I can easily test. Once tested somewhat, I'll move the
subroutine o the proper location within the file where the subroutine
actually belongs.
-Mike
|
|
|
Re: how to rerun subroutine only? [message #42728 is a reply to message #42726] |
Mon, 21 February 2005 12:22  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
u2s5thmember@yahoo.com writes:
> this is probably a beginner question, so I appreciate your patience:
>
> Suppose I compile & run a top level program, then it enters a
> subroutine. Then suppose I want the code to stop somewhere in the
> subroutine so I can plot variables or check on/plot the results of a
> calculation... or say the subroutine encounters an error. then I might
> change something in the subroutine and need to rerun the subroutine.
>
> right now I recompile the subroutine then rerun the entire code
> starting from the beginning of the toplevel program, when all I really
> need to do is have idl redo the calculations from the beginning of the
> subroutine.
>
> is there a way to do this?
No. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|