2009-10-05 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / namelist_11.f
blob672ee261c2003813a7576615ff45e26fa53c0112
1 c { dg-do run { target fd_truncate } }
2 c This program tests: namelist comment, a blank line before the nameilist name, the namelist name,
3 c a scalar qualifier, various combinations of space, comma and lf delimiters, f-formats, e-formats
4 c a blank line within the data read, nulls, a range qualifier, a new object name before end of data
5 c and an integer read. It also tests that namelist output can be re-read by namelist input.
6 c provided by Paul Thomas - pault@gcc.gnu.org
8 program namelist_1
10 REAL x(10)
11 REAL(kind=8) xx
12 integer ier
13 namelist /mynml/ x, xx
15 do i = 1 , 10
16 x(i) = -1
17 end do
18 x(6) = 6.0
19 x(10) = 10.0
20 xx = 0d0
22 open (10,status="scratch")
23 write (10, *) "!mynml"
24 write (10, *) ""
25 write (10, *) "&gf /"
26 write (10, *) "&mynml x(7) =+99.0e0 x=1.0, 2.0 ,"
27 write (10, *) " 2*3.0, ,, 7.0e0,+0.08e+02 !comment"
28 write (10, *) ""
29 write (10, *) " 9000e-3 x(4:5)=4 ,5 "
30 write (10, *) " x=,,3.0, xx=10d0 /"
31 rewind (10)
33 read (10, nml=mynml, IOSTAT=ier)
34 if (ier.ne.0) call abort
35 rewind (10)
37 do i = 1 , 10
38 if ( abs( x(i) - real(i) ) .gt. 1e-8 ) call abort
39 end do
40 if ( abs( xx - 10d0 ) .gt. 1e-8 ) call abort
42 write (10, nml=mynml, iostat=ier)
43 if (ier.ne.0) call abort
44 rewind (10)
46 read (10, NML=mynml, IOSTAT=ier)
47 if (ier.ne.0) call abort
48 close (10)
50 do i = 1 , 10
51 if ( abs( x(i) - real(i) ) .gt. 1e-8 ) call abort
52 end do
53 if ( abs( xx - 10d0 ) .gt. 1e-8 ) call abort
55 end program