Does your comment apply to all three of the cases I asked about, or to just the pipe and here document forms? Does standard input in the case of redirection (my first example) give stdin all the characteristics of the connected file itself?
As a practical matter, this is what gfortran does for the three cases for a small test file:
program stdin
use, intrinsic :: iso_fortran_env, only: input_unit, output_unit
implicit none
integer :: i, j
character(*), parameter :: cfmt = '(*(g0))'
do i = 1, 5
read(input_unit,*) j
write(output_unit,cfmt) 'line ', i, ' read. j= ', j
enddo
rewind input_unit
write(output_unit,cfmt) 'after rewind'
do i = 1, 5
read(input_unit,*) j
write(output_unit,cfmt) 'line ', i, ' read. j= ', j
enddo
end program stdin
Here is an input file:
cat >input.dat <<EOF
1
2
3
4
5
EOF
Redirection:
$ a.out <input.dat
line 1 read. j= 1
line 2 read. j= 2
line 3 read. j= 3
line 4 read. j= 4
line 5 read. j= 5
after rewind
line 1 read. j= 1
line 2 read. j= 2
line 3 read. j= 3
line 4 read. j= 4
line 5 read. j= 5
Pipe:
$ cat input.dat | a.out
line 1 read. j= 1
line 2 read. j= 2
line 3 read. j= 3
line 4 read. j= 4
line 5 read. j= 5
At line 10 of file stdin.f90 (unit = 5, file = 'stdin')
Fortran runtime error: Illegal seek
Error termination. Backtrace:
#0 0x1049f380e
#1 0x1049f44b5
#2 0x1049f50cb
#3 0x1049e9c3b
#4 0x1049e9e5c
Here document:
$ a.out <<EOF
1
2
3
4
5
EOF
line 1 read. j= 1
line 2 read. j= 2
line 3 read. j= 3
line 4 read. j= 4
line 5 read. j= 5
after rewind
line 1 read. j= 1
line 2 read. j= 2
line 3 read. j= 3
line 4 read. j= 4
line 5 read. j= 5
Maybe this is a question for the compiler writers. What exactly is the difference in these three cases regarding the fortran i/o library? How much of this behavior is determined/required by the fortran and POSIX standards? How much is just a quality of implementation issue for the various compilers?