On 11/02/2009 10:59 AM, Hans Horn wrote:
> Steve Kargl wrote:
>> On Mon, Nov 02, 2009 at 09:47:03AM -0800, Hans Horn wrote:
>>> Steve Kargl wrote:
>>>> On Mon, Nov 02, 2009 at 09:03:10AM -0800, Hans Horn wrote:
>>>>> Folks,
>>>>>
>>>>> I get warnings about line truncation on fixed-form (f77) code when
>>>>> I have inline comments starting at column 73 and beyond.
>>>>>
>>>> Fixed-form code is restricted to 72 columns. From the Fortran
>>>> 2003 Standard.
>>>>
>>>> 3.3.2 Fixed source form
>>>>
>>>> In fixed source form, there are restrictions on where a statement mayr
>>>> appear within a line. If a source line contains only default kind
>>>> characters, it shall contain exactly 72 characters; otherwise, its
>>>> maximum number of characters is processor dependent.
>>>>
>>>> See the gfortran manual for options that allows you to violate this
>>>> restricton.
>>>>
>>> Steve,
>>>
>>> line 5 in the mock code I posted emits a warning, while line 4 doesn't.
>>> Both lines are more than 72 chars in length.
>>>
>>> subroutine foo
>>> IMPLICIT NONE
>>> Integer stupid_dummy_variable1 ! stupid_dummy_variable1
>>> Integer stupid_dummy_variable2 ! stupid_dummy_variable2
>>> Integer stupid_dummy_variable3 ! stupid_dummy_variable3
>>
>> Actually, after I unwrap the two comments (email programs have a funny
>> habit of wrapping long lines). Neither gives a warning. Of course,
>> I simply unwrapped the lines. You've obviously done something more
>> with the above example; perhaps, starting the two comments in
>> column 73. Let's see.
>>
>> troutmask:sgk[208] nedit fh.f (unfix to column 73)
>> troutmask:sgk[207] gfc4x -c -Wall fh.f
>> fh.f:4.72:
>>
>> Integer stupid_dummy_variable2 1
>> Warning: Line truncated at (1)
>> fh.f:5.72:
>>
>> Integer stupid_dummy_variable3 1
>> Warning: Line truncated at (1)
>>
>> Yep, the lines of turncated. RTFM.
>>
>> troutmask:sgk[216] gfc4x -c -Wall -ffixed-line-length-none fh.f
>>
>> To re-iterate, fixed-form is restricted to 72 columns. Period.
>>
>
> Steve,
>
> may be I try one more time, this time by attaching the source.
> line 5 emits warning, line 4 not - both lines are longer than 72 chars
> if the comments are taken into consideration. the actual statements
> (decls. of stupid_dummy_variable2,3) both end at column 36.
>
> I guess it'll come down to religious interpretation of the standard
> document (which I don't have access to) whether inline comments are part
> of statements or not.
>
> H.
Actually, this really is a bunch of nit picking. Both lines are truncated. In
the one case, it is truncated before it is determined to be a comment line. We
choose to ignore truncation of comment lines but will warn if you ask for it
with -Wall. On line 5, gfortran never sees the comment marker '!', it just
knows something was there and was truncated.
The warning is provided as a courtesy, not has a big flag that something must be
wrong, end of the world and all that!
Want to have some fun? Try this:
$ gfc -c -Wall -ffixed-line-length-74 foo.f
$ gfc -c -Wall -ffixed-line-length-71 foo.f
foo.f:4.71:
Integer stupid_dummy_variable2
1
Warning: Line truncated at (1)
foo.f:5.71:
Integer stupid_dummy_variable3
1
Warning: Line truncated at (1)
Wow, I can make the warning go away or I can make it warn on both lines!
Amazing isn't it?
Jerry