program testnmlread use iso_fortran_env, only: compiler_version implicit none print *,'Compiler version = ',trim(compiler_version()) call test (" ") call test ("!") call test ("/") call test (",") call test (";") call test (achar(9), "tab") call test (achar(10), "lf") call test (achar(13), "ret") contains subroutine test (c, desc) character, intent(in) :: c character(*), intent(in), optional :: desc character(8) :: d character(16) :: line, lines(2) integer :: ios integer :: n namelist/stuff/n character(*), parameter :: s1 = "&stuff", s2 = " n = 666/" d = ">" // c // "<"; if (present (desc)) d = desc ! Prepare input: line = s1 // c // s2 lines(1) = s1 // c ! Left-adjusted lines(2) = s2 ! Single line input n = -1 read(line,nml=stuff,iostat=ios) write(*,*) "1-line: ", trim (d), n, ios ! Multi-line input n = -1 read(lines,nml=stuff, iostat=ios) write(*,*) "2-line/left: ", trim (d), n, ios lines(1) = adjustr (lines(1)) ! Right-adjust first line n = -1 read(lines,nml=stuff, iostat=ios) write(*,*) "2-line/right: ", trim (d), n, ios end subroutine test end program testnmlread