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
30 integer :: ios
, idx
, k
37 read (unit
,'(a)',iostat
=ios
) line
43 else if (ios
> 0) then
48 idx
= index (line
, "&"//trim (name
))
55 end subroutine position_nml
57 subroutine read_report (unit
, status
)
58 integer :: unit
, status
60 integer :: iuse
, ios
, k
64 character(len
=12) :: type
65 namelist /REPORT
/ type
66 !-------------------------------------
67 ! Loop to read namelist multiple times
68 !-------------------------------------
71 !----------------------------------------
72 ! Preset namelist variables with defaults
73 !----------------------------------------
78 call position_nml (unit
, "REPORT", status
)
84 read (unit
, nml
=REPORT
, iostat
=ios
)
90 end subroutine read_report