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

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uimrl7.mrl.uiuc.edu!ercolessi
  3. From: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
  4. Subject: Re: Jumping from nested subroutine to main directly?
  5. References: <1992Nov21.015026.17820@netcom.com> <DODD.92Nov21071326@mycenae.cchem.berkeley.edu> <By2xxC.JAB@mentor.cc.purdue.edu> <1992Nov21.222705.20726@monu6.cc.monash.edu.au>
  6. Message-ID: <By3ptF.MuL@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Reply-To: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
  9. Organization: MRL - UIUC
  10. Date: Sun, 22 Nov 1992 04:58:25 GMT
  11. Lines: 49
  12.  
  13. In article <1992Nov21.222705.20726@monu6.cc.monash.edu.au>, map@hal.maths.monash.edu.au (Michael
  14. Page) writes:
  15. |>>== John H. Chauvin <jchauvin@netcom.com> writes:
  16. |>>>
  17. |>>>  Is it possible to transfer control from a nested subroutine directly to the 
  18. |>>>  main routine without have to execute multiple returns from all the 
  19. |>>>  subroutines in between?  I would like a way of exiting directly to the main 
  20. |>>>  routine when a error is detected six or seven subroutines down.
  21. |>
  22. |>One way to almost do what he wants is to use an ENTRY statement at the 
  23. |>point he wants to return to in the main program.  However, I suspect he 
  24. |>wants something a bit more `automatic' than that, but I don't think it 
  25. |>exists in FORTRAN.  Does it exist in C, Pascal, ..?
  26.  
  27. Hmmmm ... so do you think it is really possible to do something like
  28.  
  29.     program main
  30. 1    continue
  31.     ...
  32.     call level1(...)
  33.     ...
  34.     stop
  35.     entry backtomain
  36. *       pretend we can 'restart' program
  37.     goto 1
  38.     end
  39.  
  40.     subroutine level1(...)
  41.     ...
  42.     call level2(...)
  43.     ...
  44.     end
  45.  
  46.     subroutine level2(...)
  47.     ...
  48.     if (troubles) call backtomain
  49.     ...
  50.     end
  51.  
  52. and 'fall' in 'backtomain' from level2 as many times as we want? 
  53. my guess is that this can be done but eats stack space because
  54. no one ever returns. well actually it looks like a form of recursion,
  55. where we do not need to retain data from previous calls, so
  56. is this a form of pseudo-recursion allowed by Fortran?
  57. --
  58. Furio Ercolessi
  59. Materials Research Laboratory           |   Intl School for Advanced Studies
  60. Univ. of Illinois at Urbana-Champaign   |   Trieste, Italy
  61. furio@uiuc.edu                          |   furio@sissa.it
  62.