home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!munnari.oz.au!titan!trlluna!bruce.cs.monash.edu.au!monu6!hal!map
- From: map@hal.maths.monash.edu.au (Michael Page)
- Subject: Re: Jumping from nested subroutine to main directly?
- Message-ID: <1992Nov21.222705.20726@monu6.cc.monash.edu.au>
- Sender: news@monu6.cc.monash.edu.au (Usenet system)
- Organization: Mathematics Department, Monash University, Australia
- References: <1992Nov21.015026.17820@netcom.com> <DODD.92Nov21071326@mycenae.cchem.berkeley.edu> <By2xxC.JAB@mentor.cc.purdue.edu>
- Date: Sat, 21 Nov 1992 22:27:05 GMT
- Lines: 34
-
- ags@seaman.cc.purdue.edu (Dave Seaman) 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.
- >
- >Write a subroutine to do whatever final cleanup is needed. Have
- >the main program end with a call to the cleanup routine. Have the
- >cleanup routine finish with a STOP statement, so that it never
- >returns to the main program.
- >
- >Now, when an error is detected and you want to bail out, you can
- >just call the cleanup routine, knowing it will never return. You
- >can even have the routine take an error argument to indicate the
- >reason for termination, and have the cleanup take appropriate
- >action.
-
- 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, ..?
-
- (Which also prompts me to ask why the ENTRY statement is so frowned upon
- that it is now deprecated? Is it superceded by something else?)
-
-
- --
- +------------------------------------------------------------------------------+
- Michael Page, Maths Dept, Monash University, Clayton, Victoria, AUSTRALIA 3168
- email: map@hal.maths.monash.edu.au phone: +61 3 565 4486 FAX: +61 3 565 4403
- +------------------------------------------------------------------------------+
-