home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4438 < prev    next >
Encoding:
Internet Message Format  |  1992-11-24  |  1.8 KB

  1. Path: sparky!uunet!mcsun!sun4nl!cwi.nl!dik
  2. From: dik@cwi.nl (Dik T. Winter)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Jumping from nested subroutine to main directly?
  5. Message-ID: <7976@charon.cwi.nl>
  6. Date: 24 Nov 92 00:00:00 GMT
  7. References: <DODD.92Nov21071326@mycenae.cchem.berkeley.edu> <By2xxC.JAB@mentor.cc.purdue.edu> <1992Nov21.222705.20726@monu6.cc.monash.edu.au>
  8. Sender: news@cwi.nl
  9. Organization: CWI, Amsterdam
  10. Lines: 34
  11.  
  12. In article <1992Nov21.222705.20726@monu6.cc.monash.edu.au> map@hal.maths.monash.edu.au (Michael Page) writes:
  13.  > ags@seaman.cc.purdue.edu (Dave Seaman) writes:
  14.  > >Write a subroutine to do whatever final cleanup is needed. Have
  15.  > >the main program end with a call to the cleanup routine. Have the
  16.  > >cleanup routine finish with a STOP statement, so that it never
  17.  > >returns to the main program.
  18. This fails the request: a return to the main subroutine not a complete bail
  19. out.
  20.  > One way to almost do what he wants is to use an ENTRY statement at the 
  21.  > point he wants to return to in the main program.  However, I suspect he 
  22.  > wants something a bit more `automatic' than that, but I don't think it 
  23.  > exists in FORTRAN.  Does it exist in C, Pascal, ..?
  24. Moreover that will not work at all:
  25.     SUBROUTINE A()
  26.     INTEGER I
  27.     I = 1
  28.     CALL B()
  29.     ENTRY A1()
  30.     PRINT *, I
  31.     RETURN
  32.     END
  33. ...
  34.     SUBROUTINE Z()
  35.     CALL A1()
  36.     END
  37. Where Z is called somewhere in the elaboration of B.  This is illegal
  38. (A is called recursively), and hence not portable.  Moreover, if the
  39. system uses a stack, what will be the value printed?  And finally,
  40. the RETURN statement returns back to Z (which in turn returns back to
  41. B, which in turn returns back to A, which in turn might return back to
  42. Z, ad infinitum).
  43. -- 
  44. dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
  45. home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
  46.