Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifort 17.0.4.196 hangs at 100% CPU if input from stdin is not newline-terminated

Paolo_Tosco
Beginner
273 Views
        program test_read_stdin

        implicit none
        
        character*200 line

10      read(*,'(a)', end=20,err=30) line
        write(0,'(a)') line
        goto 10
20      write(0,'(a)') 'EOF'
        stop
30      write(0,'(a)') 'ERROR'
        stop
        end program test_read_stdin

Compiling the above simple program with gfortran or ifort 14.0.4.211 I get:

$ ifort test_read_stdin.f -o test_read_stdin
$ echo -n "a" | ./test_read_stdin
a                                                                                                                                                                                                       
EOF

as expected.

Instead, compiling with ifort 17.0.4.196 the above command hangs and top shows very high CPU usage:

$ echo -n "a" | ./test_read_stdin
▒
[1]+  Stopped                 echo -n "a" | ./test_read_stdin
$ bg
[1]+ echo -n "a" | ./test_read_stdin &
$ ps
  PID TTY          TIME CMD
 7841 pts/1    00:00:00 bash
19313 pts/1    00:00:02 test_read_stdin
19314 pts/1    00:00:00 ps
$ top -p 19313
top - 09:55:42 up 5 days, 56 min,  3 users,  load average: 0.80, 0.34, 0.12
Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.8%us,  4.8%sy,  0.0%ni, 94.3%id,  0.0%wa,  0.1%hi,  0.0%si,  0.0%st
Mem:   8058848k total,  6804384k used,  1254464k free,   336976k buffers
Swap:  6168572k total,   209088k used,  5959484k free,  5221952k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                                                                           
19313 build     20   0 14028 1048  684 R 100.0  0.0   0:27.52 test_read_stdin                  

Is this intentional or is it a bug?

This change in behaviour may break a number of existing programs.

Thanks, kind regards
Paolo

0 Kudos
1 Reply
Devorah_H_Intel
Moderator
273 Views

Thank you for your report! Please submit a bug report via our Online Service Center at https://supporttickets.intel.com/  Our engineering team will investigate this further.

Instructions on how to file a ticket are available here: 
https://software.intel.com/en-us/articles/how-to-create-a-support-request-at-online-service-center  

0 Kudos
Reply