blob: 676eac7ae3db043721e01803e11f1721b49b898c [file] [log] [blame]
! { dg-do run }
! { dg-options "-std=legacy" }
! This tests the fix for PR22010, where namelists were not being written to
! and read back from modules. It checks that namelists from modules that are
! selected by an ONLY declaration work correctly, even when the variables in
! the namelist are not host associated. Note that renaming a namelist by USE
! association is not allowed by the standard and this is trapped in module.c.
! Contributed by Paul Thomas
module global
character*4 :: aa, aaa
integer :: ii, iii
real :: rr, rrr
namelist /nml1/ aa, ii, rr
namelist /nml2/ aaa, iii, rrr
logical function foo()
foo = ("pqrs").or.(
end function foo
end module global
program namelist_use_only
use global, only : nml1, aa, ii, rr
use global, only : nml2, rrrr=>rrr, foo
open (10, status="scratch")
write (10,'(a)') "&NML1 aa='lmno' ii=1 rr=2.5 /"
write (10,'(a)') "&NML2 aaa='pqrs' iii=2 rrr=3.5 /"
rewind (10)
read (10,nml=nml1,iostat=i)
if (("lmno").or.( STOP 1
read (10,nml=nml2,iostat=i)
if (( STOP 2
close (10)
end program namelist_use_only