2 ! PR31052 Bad IOSTAT values when readings NAMELISTs past EOF.
3 ! Patch derived from PR, submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
6 integer, parameter :: nmlunit = 12 ! Namelist unit
9 open (nmlunit, status="scratch")
10 write(nmlunit, '(a)') "&REPORT type='report1' /"
11 write(nmlunit, '(a)') "&REPORT type='report2' /"
12 write(nmlunit, '(a)') "!"
15 ! The call to position_nml is contained in the subroutine
16 call read_report (nmlunit, stat)
18 call position_nml (nmlunit, 'MISSING', stat)
20 call read_report (nmlunit, stat) ! gfortran fails here
24 subroutine position_nml (unit, name, status)
25 ! Check for presence of namelist 'name'
26 integer :: unit, status
27 character(len=*), intent(in) :: name
29 character(len=255) :: line
37 read (unit,'(a)',iostat=ios) line
43 else if (ios > 0) then
48 idx = index (line, "&"//trim (name))
54 end subroutine position_nml
56 subroutine read_report (unit, status)
57 integer :: unit, status
63 character(len=12) :: type
64 namelist /REPORT/ type
65 !-------------------------------------
66 ! Loop to read namelist multiple times
67 !-------------------------------------
70 !----------------------------------------
71 ! Preset namelist variables with defaults
72 !----------------------------------------
77 call position_nml (unit, "REPORT", status)
80 if (iuse /= 2) call abort()
83 read (unit, nml=REPORT, iostat=ios)
88 end subroutine read_report