Namelist having problems with whitespace?

Jerry DeLisle jvdelisle@verizon.net
Sat Jun 14 03:23:00 GMT 2008


Steve Edwards wrote:
> Dear all,
> 
> I have just run across what appears to be strange behaviour with namelists. First spotted in a custom build of gcc 4.3.0 and I've just got a reduced test case on my home machine with 4.3.0 20080428 (Red Hat 4.3.0-8)
> 
> It came from some legacy Fortran77 code (and I know namelists were not part of that standard!) and used to run with g77 okay.
> 
> Apologies if my email distorts the whitespace.
> 
>> cat check1.f
>       program check1
>       real x
>       namelist/casein/x
>       read(1,casein)
>       print*,x
>       end
> 
>> cat fort.1
> &CASEIN	
> 		x=1.,
> /
> 
> Note that the whitespace in front of the x consists of 2 tab characters.
> 
> This produces as expected:
>   1.00000000
> 
> Add a single tab to the end of CASEIN and it produces:
> 
> At line 4 of file check1.f (unit = 1, file = 'fort.1')
> Fortran runtime error: Cannot match namelist object name
> 
> Remove one tab from immediately in front of x and it works again.
> 
> There are a few other combinations of multiple tabs and spaces I tried but the only one that appeared to work flawlessly was replacing all tabs with spaces.
> 
> Any opinions on this?
> 
> I can always _try_ and tell users to always untab their input files, but I'm certain there will be several who forget.... (and there are bound to be some who will insist that tabs are 'best' anyway...)

I can confirm the problem, work around is to avoid the tabs until I get this 
fixed.  I will open a PR.

Jerry



More information about the Fortran mailing list