1!
2! Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
3!
4! Licensed under the Apache License, Version 2.0 (the "License");
5! you may not use this file except in compliance with the License.
6! You may obtain a copy of the License at
7!
8!     http://www.apache.org/licenses/LICENSE-2.0
9!
10! Unless required by applicable law or agreed to in writing, software
11! distributed under the License is distributed on an "AS IS" BASIS,
12! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13! See the License for the specific language governing permissions and
14! limitations under the License.
15!
16
17
18program testnewline
19parameter(N=20)
20integer :: results(N)
21integer :: expected(N)
22
23character*5 c1, c2, c3
24logical l1(3), l2(3)
25integer*8 abc(20)
26integer iosint(3)
27integer myintread(20)
28integer myintwrite(20)
29       data results / -1, -1, 0, 0, -1, 0, 0, 0, &
30                      -2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0/
31       data expected / -1, -1, 0, 0, -1, 0, 0, 0, &
32                      -2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0/
33
34
35
36! new_line
37open(28, file='t.txt', status='replace', access='stream', form='formatted')
38write(28,'(a)') 'hello'//new_line('x')//'world'
39close(28)
40!
41
42! end of file
43open(28, file='t.txt', form='formatted')
44read(28,100,iostat=ios) c1
45l1(1) = is_iostat_end(ios)
46l2(1) = is_iostat_eor(ios)
47read(28,100,iostat=ios) c2
48l1(2) = is_iostat_end(ios)
49l2(2) = is_iostat_eor(ios)
50read(28,100,iostat=ios) c3
51l1(3) = is_iostat_end(ios)
52l2(3) = is_iostat_eor(ios)
53100 format(a5)
54close(28)
55
56results(1)=(c1 == 'hello')
57results(2)=(c2 == 'world')
58results(3)=l1(1)
59results(4)=l1(2)
60results(5)=l1(3)
61results(6)=l2(1)
62results(7)=l2(2)
63results(8)=l2(3)
64
65
66
67!end of record
68open(28, file='t2.txt',status='replace',form='formatted')
69write(28,'(i13)') myintwrite
70close(28)
71
72open(28, file='t2.txt', form='formatted')
73read(28,200,advance='no',iostat=ios) myintread
74200 format(i20)
75close(28)
76
77results(9)=ios
78results(10)=is_iostat_end(ios)
79results(11)=is_iostat_eor(ios)
80
81open(28, file='t2.txt', form='formatted')
82read(28,300,advance='no',iostat=ios) myintread
83300 format(i13)
84close(28)
85
86results(12)=ios
87results(13)=is_iostat_end(ios)
88results(14)=is_iostat_eor(ios)
89
90!testing array
91iosint=0
92iosint=is_iostat_end(iosint)
93results(15:17)=iosint
94
95iosint=is_iostat_eor(iosint)
96results(18:20)=iosint
97
98
99call check(results,expected,N)
100
101end
102