[J3] Question about the result of the SIZE= specifier in nonadvanced READ

Robert Corbett rpcorbett at att.net
Wed Aug 13 22:55:45 UTC 2025


I am not aware of a change to the standard that makes it acceptable for a comma to appear in a field read under F editing unless the decimal edit mode is COMMA.

Bob Corbett

> On Aug 13, 2025, at 11:02 AM, Daniel Chen via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> 
> Hello all,
> 
> What should be the correct output from the following code?
> 
> ```
>     character(13) c
>     real r1(3), r2(3)
>     integer i1, i2
>  
>     c = '1.2, 1.2, 1.2'
>  
>     write (2, '(2a)') c, ' '
>  
>     write (3, '(2a)') c, ','
>  
>     rewind 2
>     rewind 3
>  
>     read (2, '(3F5.1)', advance='no', size=i1) r1
> print*, i1
>  
>     read (3, '(3F5.1)', advance='no', size=i2) r2
> print*, i2
>  
>     end
> ```
> 
> The standard says the following about the SIZE= specifier
> ```
> The SIZE= specifier in an input statement causes the variable specified to become defined with the count of
> the characters transferred from the file by data edit descriptors during the input operation. Blanks inserted as
> padding are not counted.
> 
> ```
> 
> Different compiler gives different output. Some counts comma and some also counts blank.
> 
> What is the standard conforming output of this code?
> 
> Thanks,
> Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250813/0a1f5dd0/attachment-0001.htm>


More information about the J3 mailing list