home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!cwi.nl!dik
- From: dik@cwi.nl (Dik T. Winter)
- Newsgroups: comp.lang.fortran
- Subject: Re: Jumping from nested subroutine to main directly?
- Message-ID: <7976@charon.cwi.nl>
- Date: 24 Nov 92 00:00:00 GMT
- References: <DODD.92Nov21071326@mycenae.cchem.berkeley.edu> <By2xxC.JAB@mentor.cc.purdue.edu> <1992Nov21.222705.20726@monu6.cc.monash.edu.au>
- Sender: news@cwi.nl
- Organization: CWI, Amsterdam
- Lines: 34
-
- In article <1992Nov21.222705.20726@monu6.cc.monash.edu.au> map@hal.maths.monash.edu.au (Michael Page) writes:
- > ags@seaman.cc.purdue.edu (Dave Seaman) writes:
- > >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.
- This fails the request: a return to the main subroutine not a complete bail
- out.
- > 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, ..?
- Moreover that will not work at all:
- SUBROUTINE A()
- INTEGER I
- I = 1
- CALL B()
- ENTRY A1()
- PRINT *, I
- RETURN
- END
- ...
- SUBROUTINE Z()
- CALL A1()
- END
- Where Z is called somewhere in the elaboration of B. This is illegal
- (A is called recursively), and hence not portable. Moreover, if the
- system uses a stack, what will be the value printed? And finally,
- the RETURN statement returns back to Z (which in turn returns back to
- B, which in turn returns back to A, which in turn might return back to
- Z, ad infinitum).
- --
- dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland
- home: bovenover 215, 1025 jn amsterdam, nederland; e-mail: dik@cwi.nl
-