Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hou3c.UUCP Path: utzoo!watmath!clyde!burl!hou3c!ka From: ka@hou3c.UUCP (Kenneth Almquist) Newsgroups: net.lang.f77 Subject: Re: Recursion bug in f77 (4.1bsd) Message-ID: <335@hou3c.UUCP> Date: Tue, 28-Feb-84 12:51:30 EST Article-I.D.: hou3c.335 Posted: Tue Feb 28 12:51:30 1984 Date-Received: Wed, 29-Feb-84 09:12:53 EST References: <264@charm.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 15 Two things which you have to watch out for when converting between C and FORTRAN are: 1) In C, parameters are passed by value, while in FORTRAN they are passed by reference. 2) In C, local variables are by default allocated dynamicly each time a routine is entered. In FORTRAN, it is customary to allocate all local variables before the execution of the program begins. I expect that the problem in the example is a result of (2). The solution is to declare all the local variables to be automatic. (The automatic declaration is a UN*X extension to FORTRAN.) That way, you will get a new set of local variables each time the routine invokes itself recursively, instead of sharing one copy between all the invocations of the routine. Kenneth Almquist