home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uimrl7.mrl.uiuc.edu!ercolessi
- From: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
- Subject: Re: Jumping from nested subroutine to main directly?
- References: <1992Nov21.015026.17820@netcom.com> <DODD.92Nov21071326@mycenae.cchem.berkeley.edu> <By2xxC.JAB@mentor.cc.purdue.edu> <1992Nov21.222705.20726@monu6.cc.monash.edu.au>
- Message-ID: <By3ptF.MuL@news.cso.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Reply-To: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
- Organization: MRL - UIUC
- Date: Sun, 22 Nov 1992 04:58:25 GMT
- Lines: 49
-
- In article <1992Nov21.222705.20726@monu6.cc.monash.edu.au>, map@hal.maths.monash.edu.au (Michael
- Page) writes:
- |>>== John H. Chauvin <jchauvin@netcom.com> writes:
- |>>>
- |>>> Is it possible to transfer control from a nested subroutine directly to the
- |>>> main routine without have to execute multiple returns from all the
- |>>> subroutines in between? I would like a way of exiting directly to the main
- |>>> routine when a error is detected six or seven subroutines down.
- |>
- |>One way to almost do what he wants is to use an ENTRY statement at the
- |>point he wants to return to in the main program. However, I suspect he
- |>wants something a bit more `automatic' than that, but I don't think it
- |>exists in FORTRAN. Does it exist in C, Pascal, ..?
-
- Hmmmm ... so do you think it is really possible to do something like
-
- program main
- 1 continue
- ...
- call level1(...)
- ...
- stop
- entry backtomain
- * pretend we can 'restart' program
- goto 1
- end
-
- subroutine level1(...)
- ...
- call level2(...)
- ...
- end
-
- subroutine level2(...)
- ...
- if (troubles) call backtomain
- ...
- end
-
- and 'fall' in 'backtomain' from level2 as many times as we want?
- my guess is that this can be done but eats stack space because
- no one ever returns. well actually it looks like a form of recursion,
- where we do not need to retain data from previous calls, so
- is this a form of pseudo-recursion allowed by Fortran?
- --
- Furio Ercolessi
- Materials Research Laboratory | Intl School for Advanced Studies
- Univ. of Illinois at Urbana-Champaign | Trieste, Italy
- furio@uiuc.edu | furio@sissa.it
-