[comp.lang.fortran] Omitting width in a format

pmontgom@euphemia.math.ucla.edu (Peter Montgomery) (06/02/91)

In article <1991Jun1.043052.29008@jato.jpl.nasa.gov> 
vsnyder@jato.Jpl.Nasa.Gov (Van Snyder) writes:
>In article <quan.675653087@sol> 
>quan@sol.surv.utas.edu.au (Stephen Quan) writes:
>>I'm having a slight, almost trivial problem, I cannot write
>>integers without them being right justified.
>>
>It was for exactly this reason that I urged X3J3, during all the public
>reviews, to generalize format specifications so that the "w" part was
>optional, as it is in "a" formats.  The committee responded that the
>standard ALLOWS an implementor to do just this with * format.  But it's
>hard to mix * with precise fixed formats, and, in addition, few if any
>vendors left justify numbers in * format.
>
	I too would like to be able to say "I" in a format to
let the vendor decide the width.  Sometimes I desire data left
justified, as with Stephen's problem.  For me, a more serious
need is avoiding ***** when outputting big integers.

	When I originally designed some of my current software,
the CDC 7600 allowed only 50000 words of memory, and
an I5 edit descriptor was enough to use when printing a subscript.
Modern architectures have much more memory, and we
need at least an I8.  I also keep counters about
how often certain routines have executed, and these
are presently overflowing past 2**31 on 32-bit machines
during long runs; when 64-bit integers become common,
I will need to increase my widths to cover this.

	Sometimes ***** is a desirable output, because it
keeps the columns lined up (and will cause an error
if the same data is read back with a formatted read
expecting data in particular columns).
Certainly printing ***** is preferable to terminating the program,
in my experience.  But I would like to be able to use an "I"
edit descriptor (requesting the vendor to use exactly the width needed, 
no leading zeros or blanks except that zero prints as "0") 
and a form "I.5" (requesting at least five columns, more if needed). 

	PROBLEM:  Suppose we use the syntax "I.5"
(width omitted) to mean "supply at least five columns".
If the data item has value 123, how do we distinguish
whether we want to print "  123", " 0123", or "00123"
while also guarding against large values? Presently an I5 
(or I5.3) prints the first, I5.4 the second, and I5.5 the third.
But all of these print ***** if the data item exceeds 99999.

--
        Peter L. Montgomery 
        pmontgom@MATH.UCLA.EDU 
        Department of Mathematics, UCLA, Los Angeles, CA 90024-1555
If I spent as much time on my dissertation as I do reading news, I'd graduate.