Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang Subject: Re: What language do you use for scientific programming? Message-ID: <1350@umcp-cs.UUCP> Date: Fri, 23-Aug-85 01:44:07 EDT Article-I.D.: umcp-cs.1350 Posted: Fri Aug 23 01:44:07 1985 Date-Received: Sun, 25-Aug-85 04:34:27 EDT References: <909@oddjob.UUCP> <163@ho95e.UUCP> <367@ttrdc.UUCP> <169@ho95e.UUCP> <462@myriasb.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 44 >About recursion in f77 under 4.2. We tried some small experiments and >it turned out that the following recursive calls: > integer function foo(....) > integer x, y >* all necessary stopping conditions > x = foo (left ) > y = foo (right) > foo = x + y > end It just might help to declare your variables automatic, so they won't get stomped on by the recursive calls.... For example, the following program prints "2", as it should: program main integer foo integer i i = foo(5) print *, i stop end C I'm not sure what this computes, but the answer is different if C the variables are made static.... integer function foo(param) integer param automatic x, y, left, right left = param / 2 right = param - (left * 2) x = left y = right if (left .gt. 1) x = foo(left) if (right .gt. 1) y = foo(right) foo = x + y return end Change the declarations of x, y, left, and right to "integer" and it prints -1. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland