URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gfortran.dg/] [namelist_27.f90] - Rev 302
Compare with Previous | Blame | View Log
! { dg-do run }! PR31052 Bad IOSTAT values when readings NAMELISTs past EOF.! Patch derived from PR, submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>program gfcbug61implicit noneinteger :: statopen (12, status="scratch")write (12, '(a)')"!================"write (12, '(a)')"! Namelist REPORT"write (12, '(a)')"!================"write (12, '(a)')" &REPORT type = 'SYNOP' "write (12, '(a)')" use = 'active'"write (12, '(a)')" max_proc = 20"write (12, '(a)')" /"write (12, '(a)')"! Other namelists..."write (12, '(a)')" &OTHER i = 1 /"rewind (12)! Read /REPORT/ the first timerewind (12)call position_nml (12, "REPORT", stat)if (stat.ne.0) call abort()if (stat == 0) call read_report (12, stat)! Comment out the following lines to hide the bugrewind (12)call position_nml (12, "MISSING", stat)if (stat.ne.-1) call abort ()! Read /REPORT/ againrewind (12)call position_nml (12, "REPORT", stat)if (stat.ne.0) call abort()containssubroutine position_nml (unit, name, status)! Check for presence of namelist 'name'integer :: unit, statuscharacter(len=*), intent(in) :: namecharacter(len=255) :: lineinteger :: ios, idx, klogical :: firstfirst = .true.status = 0ios = 0line = ""do k=1,10read (unit,'(a)',iostat=ios) lineif (first) thenfirst = .false.end ifif (ios < 0) then! EOF encountered!backspace (unit)status = -1returnelse if (ios > 0) then! Error encountered!status = +1returnend ifidx = index (line, "&"//trim (name))if (idx > 0) thenbackspace (unit)returnend ifend doend subroutine position_nmlsubroutine read_report (unit, status)integer :: unit, statusinteger :: iuse, ios, k!------------------! Namelist 'REPORT'!------------------character(len=12) :: type, useinteger :: max_procnamelist /REPORT/ type, use, max_proc!-------------------------------------! Loop to read namelist multiple times!-------------------------------------iuse = 0do k=1,5!----------------------------------------! Preset namelist variables with defaults!----------------------------------------type = ''use = ''max_proc = -1!--------------! Read namelist!--------------read (unit, nml=REPORT, iostat=ios)if (ios /= 0) exitiuse = iuse + 1end doif (iuse.ne.1) call abort()status = iosend subroutine read_reportend program gfcbug61
