Re: Bloated file size?

From: Gordon Sande (g.sande_at_worldnet.att.net)
Date: 11/09/04


Date: Tue, 09 Nov 2004 21:28:55 GMT


Richard E Maine wrote:
> nessie235@aol.com (Aleph Mobius) writes:
>
>
>>I meant that if we compiled
>>Hello, World programs, this should give us about the base size of each
>>program. In other words, I don't think I will be able to produce any
>>program file less than 26k.
>
>
> Probably... though not quite provably from the data at hand. See below.
>
>
>>I understand that these file sizes are
>>really irrelevant of what will happen as more code is added. I am just
>>curious as to why there is so much more overhead.
>
>
> One thing to realize, as hinted to by one other reply here, is that
> formatted I/O is pretty complicated. Most people don't tend to think
> about it a lot because the compiler does it for them so they don't have
> to worry much about it. Fortran formatting has an awful lot of options.
> One could almost think of "format" as a whole language to itself, and
> it is one that has to be interpreted at run-time in general - or at
> least the capability has to be there for run-time interpretation.

Perhaps 10 years ago there was a magazine for programmers (really C
programmers on PCs) called Computer Languages which had an article
on the amazingly powerful legacy language and some of its features that
the authors had discovered.

What they had discovered was that one could produce nicely formatted
output from (hold your breath) Fortran using its feature of (hold
your breath again) formatted i/o with very little effort. For this
newsgroup it sounds a bit corny but those folks were deadly earnest
as they seemed to have been overworked in trying to get nice output
from C's printf.

Truth is always stranger than fiction as I could not make up such a
story.

All of this is intended to reinforce the point that the run time
formatting support in Fortran is providing a lot of capability that
it is easy to miss.

> It is possible for the user to build formats at run-time in character
> variables, so in general the compiler has to include support for
> all formatting options. Perhaps in some common special cases, the
> compiler could deduce that portions of the formatting support will
> not be needed... but I'd guess that to be a pretty complicated deduction
> with limited payoff in real programs.
>
> Printing out a literal string is perhaps the simplest case, but
> consider what you would have to do to write the code to parse a format
> and use it to convert the I/O list to the appropriate character form
> (considering just output for now). It's not at all a simple task, but
> it doesn't involve any actual system interfacing, so you "ought" to be
> able to do something at least comparable in ordinary old Fortran code
> (without using Fortran I/O). I don't recommend seriously trying
> unless you have a year or so of time to throw away on the experiment,
> though;; that's about what I'd think it would take to do a good job...
> and I coulld be low. And that's just the formatting part - without
> getting into the actual I/O.
>
> Compilers probably vary as to how much they separate out parts of
> the run-time formatting support code. Some compilers probably bring
> in absolutely everything if the code has any I/O at all (and maybe
> even otherwise in order to support system error messages). Others
> might separate out some major parts so that you can avoid loading
> parts that aren't used. This is probably why someone was asking
> about differences between various ways of writing the "hello, world"
> program; for example, if the program had no explicit formats, it
> is posssible that the run-time support for parsing formats might not
> get loaded.
>
> I guess a summary is that, simple though it may look, "Hello, world"
> under the covers can be pretty complicated. That's part of why its
> actually a pretty decent first test that you have a compiler correctly
> installed and working - a lot of things have to be right.
>
> It is rare to have useful programs with no I/O at all... though such
> animals do exist (mostly in embedded systems where leaving an answer
> in the right memory location is sufficient). Programs that have no
> formatted I/O are more common - still pretty rare, but into the range
> of things that I've actually seen (and written) quite a few times. A
> program without formatted I/O *MIGHT* be smaller than your "hello,
> world". But it is mostly just an academic point.
>
> Oh, and all of this doesn't even touch on the question of shared
> libraries. Some implementations of some languages (including Fortran)
> may put much of the run-time support in a shared library (by any of
> several names). There are good reasons for this - sometimes it is
> a big "win" (particularly when there are lots of programs using the
> same shared library). But it can be misleading if you compare just
> the size of the "executable file", because the program actually
> requires both its executable file plus the shared libraries to
> run. Whenever you see an unusually small executable file, that is
> an almost certain sign that most of the run-time support code is in
> a shared library somewhere else - this applies across languages, not
> just to Fortran. There is some language dependence in that a system
> is more likely to come with shared run-time support libraries for
> languages that the system was implemented in.
>



Relevant Pages

  • Re: IVF vs CVF
    ... I would paraphrase part of it as: Microsoft didn't accept ... > Fortran for a lower price than CVF. ... > necessity for a commercial compiler. ... High quality compiler, good support, free email support within ...
    (comp.lang.fortran)
  • Re: new book: Guide to Fortran 2003 Programming (Brainerd)
    ... which looks at compiler support for the Fortran 2003 standard. ... but some people do seem to overlook that feature ...
    (comp.lang.fortran)
  • Re: Integer Coersion
    ... and as this is Fortran not Delphi, ... vaguely standard conforming. ... It would be amazingly stupid of a compiler vendor to not support a byte-sized integer. ...
    (comp.lang.fortran)
  • Re: General advice on C++ F77 multi-language compiling and linking
    ... This last part I am working through separately using help from Mixed language programming using CO++ and FORTRAN 77. ... From what I've been able to learn so far, I'll need a f77 compiler running on Windows-Intel as a minimum. ... MSVS2005 express is the only cheap way with current support; as you may have noticed, MS does not permit Fortran to be used with it, except by command line. ...
    (comp.lang.fortran)
  • Re: file formatting (open, recl, etc.)
    ... I'm trying to read a file that is normally read by a fortran program ... I don't quite understand how the fortran formatting works ... Standard so the particulars for a given compiler may be different. ... Even though it was an unformatted file, ...
    (comp.lang.fortran)