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

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!purdue!mentor.cc.purdue.edu!seaman.cc.purdue.edu!ags
  3. From: ags@seaman.cc.purdue.edu (Dave Seaman)
  4. Subject: Re: Jumping from nested subroutine to main directly?
  5. Message-ID: <By2xxC.JAB@mentor.cc.purdue.edu>
  6. Sender: news@mentor.cc.purdue.edu (USENET News)
  7. Organization: Purdue University
  8. References: <1992Nov21.015026.17820@netcom.com> <DODD.92Nov21071326@mycenae.cchem.berkeley.edu>
  9. Date: Sat, 21 Nov 1992 18:56:00 GMT
  10. Lines: 22
  11.  
  12. >
  13. >>>>>> "John" == John H. Chauvin <jchauvin@netcom.com> writes:
  14. >
  15. >  John> Is it possible to transfer control from a nested subroutine directly to the 
  16. >  John> main routine without have to execute multiple returns from all the 
  17. >  John> subroutines in between?  I would like a way of exiting directly to the main 
  18. >  John> routine when a error is detected six or seven subroutines down.
  19.  
  20. Write a subroutine to do whatever final cleanup is needed. Have
  21. the main program end with a call to the cleanup routine. Have the
  22. cleanup routine finish with a STOP statement, so that it never
  23. returns to the main program.
  24.  
  25. Now, when an error is detected and you want to bail out, you can
  26. just call the cleanup routine, knowing it will never return. You
  27. can even have the routine take an error argument to indicate the
  28. reason for termination, and have the cleanup take appropriate
  29. action.
  30.  
  31. --
  32. Dave Seaman
  33. ags@seaman.cc.purdue.edu
  34.