From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,1ef3b84ca62fad7b X-Google-Attributes: gidfee84,public X-Google-Thread: 1094ba,1ef3b84ca62fad7b X-Google-Attributes: gid1094ba,public From: Craig Burley Subject: Re: fortran error? Date: 1998/03/24 Message-ID: #1/1 X-Deja-AN: 337224912 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> <351296BC.167E@still3.chem.columbia.edu> <3512FE4B.2781@still3.chem.columbia.edu> <3516CD59.167E@still3.chem.columbia.edu> Organization: Cygnus Support Newsgroups: comp.lang.fortran,comp.unix.osf.osf1 Peter Shenkin writes: > Craig Burley wrote: > ... > > F77 code can be trivially compiled to an executable that makes > > no use whatsover of the stack *or* heap, and thus does not > > grow during run time. (Of course, the underlying system might > > mandate certain uses of stack/heap for things like starting up > > the program, calling the OS, etc.,... > > Or calling procedures. But I don't disagree with this statement, > generally. I'm not sure I'm aware of any system that mandates that calling a procedure requires using a stack. Calling pre-compiled *library* procedures might, of course, but that is subsumed by my "calling the OS, etc." comment. That is, I'm pretty sure that most systems, perhaps all popular ones during the F77 "era", offered "short call" instructions that didn't use the stack. The machines on which I did a decent amount of Fortran work usually had options you could give to the compilers to specify that you wanted to use these "short call" instructions instead of the longer form. (E.g. on a SPARC, you can avoid using the stack and more than one register window for most of your application except, of course, for library and OS calls; dunno whether Sun/Solaris f77/f90 products provide options to take advantage of this fact, though. Prime machines would use, IIRC, JSX in place of the PCL instruction. The most primitive form of non-stack-using instructions I can recall offhand was exemplified by the PDP-8 in its JMS instruction -- instead of storing the return address in a register, which the callee can decide to store in "data memory", this form stores it directly in the *callee* and starts execution at the next memory location, making shared libraries kinda hard. And, debugging programs compiled or hand-written to use these less-than-comprehensive procedure- call instructions was, typically, annoying when using the fancier debuggers, e.g. stack traces might not work.) Regardless, in the F77 days, if you wanted to be absolutely sure a running Fortran program never ran out of memory (once started up by the OS), it was quite easy to do so on almost every system out there, certainly every system I've used, modulo obscure behaviors in the run-time library I didn't know about (and which have basically nothing to do with Fortran). That's no longer true, for three reasons: 1. Fortran has features by which the programmer explicitly (in the sense of "usually knows it's happening") asks for dynamic allocation. (ALLOCATE, automatic arrays, etc.) 2. Fortran has features by which the programmer implicitly (in the sense of "might not know or care it's happening") asks for dynamic allocation. (FOO//FOO, when FOO is CHARACTER*(*), etc.) 3. Due to 1 and 2, Fortran implementations might now be exploiting dynamic allocation, to implement otherwise innocuous features, such that memory exhaustion (stack overflow or no room in the heap) can happen even when performing one of these innocuous features (e.g. a wholly "traditional" operation like WRITE). For more traditional implementations and code, actual overflows are, maybe, 99% likely to happen when implementing features in Item 1 above, so enabling the programmer to explicitly avoid (or at least trap on) these covers a lot of worthwhile cases. For the newer implementations and newer, F90-based program, though, the percentage of actual overflows that happen for Item-1 situations is almost certainly going to be lower, which means the usefulness of trapping only those overflows goes down *unless* trapping on *all* overflows (meaning those that happen in cases listed in Items 2 and 3) also works (and, preferably, works seamlessly vis-a-vis traps of Item-1 cases). -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.org