OSDN Git Service

PR c++/41920
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / namelist_12.f
1 c{ dg-do run { target fd_truncate } }
2 c{ dg-options "-std=legacy" }
3 c
4 c This program repeats many of the same tests as test_nml_1 but for integer
5 c instead of real. It also tests repeat nulls, comma delimited character read,
6 c a triplet qualifier, a range with an assumed start, a quote delimited string,
7 c a qualifier with an assumed end and a fully explicit range.  It also tests
8 c that integers and characters are successfully read back by namelist.
9 c Provided by Paul Thomas - pault@gcc.gnu.org
10
11       program namelist_12
12
13       integer x(10)
14       integer(kind=8) xx
15       integer ier
16       character*10 ch , check
17       namelist /mynml/ x, xx, ch
18  
19 c set debug = 0 or 1 in the namelist! (line 33)
20
21       do i = 1 , 10
22         x(i) = -1
23       end do
24       x(6) = 6
25       x(10) = 10
26       xx = 0
27       ch ="zzzzzzzzzz"
28       check="abcdefghij"
29
30       open (10,status="scratch", delim="apostrophe")
31       write (10, '(a)') "!mynml"
32       write (10, '(a)') " "
33       write (10, '(a)') "&mynml  x(7) =+99 x=1, 2 ,"
34       write (10, '(a)') " 2*3, ,, 2* !comment"
35       write (10, '(a)') " 9 ch='qqqdefghqq' , x(8:7:-1) = 8 , 7"
36       write (10, '(a)') " ch(:3) =""abc"","
37       write (10, '(a)') " ch(9:)='ij' x(4:5)=4 ,5 xx = 42/"
38       rewind (10)
39
40       read (10, nml=mynml, IOSTAT=ier)
41       if (ier.ne.0) call abort
42       rewind (10)
43
44       write (10, nml=mynml, iostat=ier)
45       if (ier.ne.0) call abort
46       rewind (10)
47
48       read (10, NML=mynml, IOSTAT=ier)
49       if (ier.ne.0) call abort
50       close (10)
51
52       do i = 1 , 10
53         if ( abs( x(i) - i ) .ne. 0 ) call abort ()
54         if ( ch(i:i).ne.check(I:I) ) call abort
55       end do
56       if (xx.ne.42) call abort ()
57       end program