To: J3 J3/18-238r1 From: Dan Nagle Subject: Minimum-width Character Format Date: 2018-October-15 I Introduction When one combines static-length character variables with the convenience of A format, one finds trim() around the output list item. II Use-cases For a scalar, this is not much more than a nuisance. For example, character( 1000) :: buffer ... write( ..., '( a)') trim( buffer) But trim() is transformational (since it may change a length). So it cannot be applied to an array appearing in an output list. Thus, an implied-do becomes the easiest way forward, as here, character( 100), dimension( nflags) :: flags integer :: i ... write( ..., '( a)') ( trim( flags( i)), i = 1, nflags) If the character array to be written is supplied by a function reference, then a new character variable must be used to subscript the elements for trim(). Thus, a block becomes the easiest way forward, as here, just_a_trim: block character( right_len), dimension( right_size) :: usage_msg integer :: i usage_msg = options% get_usage_message() write( ..., '( a)') ( trim( usage_msg( i)), i = 1, right_size) end block just_a_trim While judicious use of allocatable character variables might alleviate some of the symptoms, a better and broader cure is desirable. If a minimal-width character format descriptor were available, say A0, these gyrations would not be necessary. The effect of this format descriptor is to trim blanks from the list item prior to printing. Note that, with A0, the three write statements above may be written, write( ..., '( a0)') buffer write( ..., '( a0)') flags write( ..., '( a0)') options% get_usage_message() I take this as an improvement. III What I have in mind I propose that an A0 edit descriptor be added. The effect on output is to trim before writing. Like I0, A0 is not allowed on input. At meeting 215, a straw vote went to trim trailing blanks only. If this paper passes, J3 will produce edits. IV (Rough) Requirements 1. A format descriptor be provided that formats character output without trailing blanks.