2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / namelist_79.f90
blob2b2ef310d093763f8c7ad8e854cb620f6292073e
1 ! { dg-do run }
2 ! PR libfortran/52512 - Cannot match namelist object name
3 ! Test case derived from PR.
5 program testje
7 implicit none
9 integer :: getal, jn
10 type ptracer
11 character(len = 8) :: sname !: short name
12 logical :: lini !: read in a file or not
13 end type ptracer
14 type(ptracer) , dimension(3) :: tracer
15 namelist/namtoptrc/ getal,tracer
17 ! standard values
18 getal = 9999
19 do jn = 1, 3
20 tracer(jn)%sname = 'default_name'
21 tracer(jn)%lini = .false.
22 end do
24 open (10, status='scratch')
25 write (10, '(a)') "&namtoptrc"
26 write (10, '(a)') " getal = 7"
27 write (10, '(a)') " tracer(1) = 'DIC ', .true."
28 write (10, '(a)') " tracer(2) = 'Alkalini', .true."
29 write (10, '(a)') " tracer(3) = 'O2 ', .true."
30 write (10, '(a)') "/"
31 rewind(10)
32 read(10, nml=namtoptrc)
33 close (10)
35 if (getal /= 7) call abort
36 if (tracer(1)%sname /= 'DIC ') call abort
37 if (tracer(2)%sname /= 'Alkalini') call abort
38 if (tracer(3)%sname /= 'O2 ') call abort
39 if (.not. tracer(1)%lini) call abort
40 if (.not. tracer(2)%lini) call abort
41 if (.not. tracer(3)%lini) call abort
43 end program testje