Fix compilation failure with C++98 compilers
[official-gcc.git] / gcc / testsuite / gfortran.dg / namelist_71.f90
blobb50c8c60a26866478dbdb7b86e121f8bcff3c889
1 ! { dg-do run }
2 ! PR47778 Reading array of structures from namelist
3 ! Test case derived from the reporters test case.
4 program test_nml
5 type field_descr
6 integer number
7 end type
8 type fsetup
9 type (field_descr), dimension(3) :: vel ! 3 velocity components
10 type (field_descr), dimension(3) :: scal ! 3 scalars
11 end type
12 type (fsetup) field_setup
13 namelist /nl_setup/ field_setup
14 field_setup%vel%number = 0
15 field_setup%scal%number = 0
16 ! write(*,nml=nl_setup)
17 open(10, status="scratch")
18 write(10,'(a)') "&nl_setup"
19 write(10,'(a)') " field_setup%vel(1)%number= 3,"
20 write(10,'(a)') " field_setup%vel(2)%number= 9,"
21 write(10,'(a)') " field_setup%vel(3)%number= 27,"
22 write(10,'(a)') " field_setup%scal(1)%number= 2,"
23 write(10,'(a)') " field_setup%scal(2)%number= 4,"
24 write(10,'(a)') " field_setup%scal(3)%number= 8,"
25 write(10,'(a)') "/"
26 rewind(10)
27 read(10,nml=nl_setup)
28 if (field_setup%vel(1)%number .ne. 3) STOP 1
29 if (field_setup%vel(2)%number .ne. 9) STOP 2
30 if (field_setup%vel(3)%number .ne. 27) STOP 3
31 if (field_setup%scal(1)%number .ne. 2) STOP 4
32 if (field_setup%scal(2)%number .ne. 4) STOP 5
33 if (field_setup%scal(3)%number .ne. 8) STOP 6
34 !write(*,nml=nl_setup)
35 end program test_nml