From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1094ba,1ef3b84ca62fad7b X-Google-Attributes: gid1094ba,public X-Google-Thread: fee84,1ef3b84ca62fad7b X-Google-Attributes: gidfee84,public From: Peter Shenkin Subject: Re: fortran error? Date: 1998/03/20 Message-ID: <351296BC.167E@still3.chem.columbia.edu>#1/1 X-Deja-AN: 335982536 Content-Transfer-Encoding: 7bit References: <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at> <6ejfii$kbd@usenet.pa.dec.com> <350E95A7.41C6@still3.chem.columbia.edu> <350EDA13.2781@still3.chem.columbia.edu> <351181DB.2781@still3.chem.columbia.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: MacroModel Development Group, Columbia University Newsgroups: comp.lang.fortran,comp.unix.osf.osf1 Craig Burley wrote: ... > Essentially, using FORTRAN 77, it is fairly straightforward to > analyze a complete program and determine whether it will run > to completion in a given amount of memory, because there's > no ability to explicitly *or* implicitly demand dynamic > allocation of memory resources (stack or heap). I think this isn't completely true, but it certainly became a lot less true, as you point out, with the advent of the new features of F90. Even in F77, it would have been difficult to determine the maximum depth of subroutine calls that would be possible for a given program. It would have been possible to compute an upper bound, since, in the absence of recursion, an analyzer could assume that every procedure was chained together in one single call chain, and compute the stack requirements of this chain. But this would almost always be a severe overestimate of what the real program does. But the even simpler analysis of determining the stack resources required for each subroutine, and refusing to start if the stack was too small, was never, as far as I know, done. For instance, if some subroutine declared a local as "REAL A(100000000)", and if locals are allocated on the stack, and if there is not enough stack space for 10^8 reals, it should be possible, in principle for the run-time system to refuse to start up the program, rather than to incur a SEGV when the subroutine is entered. One more thing that you referred to, but that deserves to be emphasized, is something that Sergio Gelato also mentioned to me in email. I started this thread by saying that I wished that the Fortran standard would mandate a program STOP when an automatic cannot be allocated. Sergio -- and you, but less explicitly, I think -- pointed out that this also pertains to temporary arrays that the run-time system allocates. As we go from ALLOCATABLE arrays to automatic arrays, we are going from an explicit to an implicit dynamic memory request. When we go from these to a compiler-requested temporary array, we are going to a completely hidden memory request. Clearly, these can cause the same problems as automatics when allocation fails, and the standard should mandate more graceful error handling for these arrays as well -- even if the program is merely stopped on failure to allocate. -P. ************** In memoriam, Grandpa Jones, 1913-1998, R.I.P. ************** * Peter S. Shenkin; Chemistry, Columbia U.; 3000 Broadway, Mail Code 3153 * ** NY, NY 10027; shenkin@columbia.edu; (212)854-5143; FAX: 678-9039 *** *MacroModel WWW page: http://www.columbia.edu/cu/chemistry/mmod/mmod.html *