home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4398 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.2 KB  |  46 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!munnari.oz.au!titan!trlluna!bruce.cs.monash.edu.au!monu6!hal!map
  3. From: map@hal.maths.monash.edu.au (Michael Page)
  4. Subject: Re: Jumping from nested subroutine to main directly?
  5. Message-ID: <1992Nov21.222705.20726@monu6.cc.monash.edu.au>
  6. Sender: news@monu6.cc.monash.edu.au (Usenet system)
  7. Organization: Mathematics Department, Monash University, Australia
  8. References: <1992Nov21.015026.17820@netcom.com> <DODD.92Nov21071326@mycenae.cchem.berkeley.edu> <By2xxC.JAB@mentor.cc.purdue.edu>
  9. Date: Sat, 21 Nov 1992 22:27:05 GMT
  10. Lines: 34
  11.  
  12. ags@seaman.cc.purdue.edu (Dave Seaman) writes:
  13. >>
  14. >== John H. Chauvin <jchauvin@netcom.com> writes:
  15. >>
  16. >>  Is it possible to transfer control from a nested subroutine directly to the 
  17. >>  main routine without have to execute multiple returns from all the 
  18. >>  subroutines in between?  I would like a way of exiting directly to the main 
  19. >>  routine when a error is detected six or seven subroutines down.
  20. >
  21. >Write a subroutine to do whatever final cleanup is needed. Have
  22. >the main program end with a call to the cleanup routine. Have the
  23. >cleanup routine finish with a STOP statement, so that it never
  24. >returns to the main program.
  25. >
  26. >Now, when an error is detected and you want to bail out, you can
  27. >just call the cleanup routine, knowing it will never return. You
  28. >can even have the routine take an error argument to indicate the
  29. >reason for termination, and have the cleanup take appropriate
  30. >action.
  31.  
  32. One way to almost do what he wants is to use an ENTRY statement at the 
  33. point he wants to return to in the main program.  However, I suspect he 
  34. wants something a bit more `automatic' than that, but I don't think it 
  35. exists in FORTRAN.  Does it exist in C, Pascal, ..?
  36.  
  37. (Which also prompts me to ask why the ENTRY statement is so frowned upon 
  38. that it is now deprecated?  Is it superceded by something else?)
  39.  
  40.  
  41. --
  42. +------------------------------------------------------------------------------+
  43.  Michael Page, Maths Dept, Monash University, Clayton, Victoria, AUSTRALIA 3168
  44.   email: map@hal.maths.monash.edu.au phone: +61 3 565 4486 FAX: +61 3 565 4403
  45. +------------------------------------------------------------------------------+
  46.