OSDN Git Service

2010-04-24 Kai Tietz <kai.tietz@onevision.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / streamio_11.f90
1 ! { dg-do run }
2 ! PR29277 Stream IO test 11, tests formatted form.
3 ! Contributed by Tobias Burnas.
4 program stream_test
5     implicit none
6     character(len=*), parameter :: rec1 = 'record1'
7     character(len=*), parameter :: rec2 = 'record2'
8     character(len=50) :: str1,str2
9     integer           :: len, i
10     real              :: r
11
12     open(10,form='formatted',access='stream',&
13          status='scratch',position='rewind')
14     write(10,'(a)') rec1//new_line('a')//rec2
15     rewind(10)
16     read(10,*) str1
17     read(10,*) str2
18     if(str1 /= rec1 .or. str2 /= rec2) call abort()
19     rewind(10)
20     read(10,'(a)') str1
21     read(10,'(a)') str2
22     if(str1 /= rec1 .or. str2 /= rec2) call abort()
23     close(10)
24
25     open(10,form='formatted',access='stream',&
26          status='scratch',position='rewind')
27     write(10,*) '123 '//trim(rec1)//'  1e-12'
28     write(10,*) '12345.6789'
29     rewind(10)
30     read(10,*) i,str1
31     read(10,*) r
32     if(i /= 123 .or. str1 /= rec1 .or. r /= 12345.6789) &
33       call abort()
34     close(10)
35
36     open(unit=10,form='unformatted',access='stream', &
37          status='scratch',position='rewind')
38     write(10) rec1//new_line('a')//rec2
39     len = len_trim(rec1//new_line('a')//rec2)
40     rewind(10)
41     read(10) str1(1:len)
42     if(str1 /= rec1//new_line('a')//rec2) call abort()
43 end program stream_test