• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1! RUN: %S/test_errors.sh %s %t %f18
2  character(len=20) :: access = "direcT"
3  character(len=20) :: access_(2) = (/"direcT", "streaM"/)
4  character(len=20) :: action_(2) = (/"reaD ", "writE"/)
5  character(len=20) :: asynchronous_(2) = (/"nO ", "yeS"/)
6  character(len=20) :: blank_(2) = (/"nulL", "zerO"/)
7  character(len=20) :: decimal_(2) = (/'commA', 'poinT'/)
8  character(len=20) :: delim_(2) = (/"nonE ", "quotE"/)
9  character(len=20) :: encoding_(2) = (/"defaulT", "utF-8  "/)
10  character(len=20) :: form_(2) = (/"formatteD  ", "unformatteD"/)
11  character(len=20) :: pad_(2) = (/"nO ", "yeS"/)
12  character(len=20) :: position_(3) = (/"appenD", "asiS  ", "rewinD"/)
13  character(len=20) :: round_(2) = (/"dowN", "zerO"/)
14  character(len=20) :: sign_(2) = (/"pluS    ", "suppresS"/)
15  character(len=20) :: status_(2) = (/"neW", "olD"/)
16  character(len=20) :: convert_(2) = (/"big_endiaN", "nativE    "/)
17  character(len=20) :: dispose_(2) = (/ "deletE", "keeP  "/)
18  character(len=66) :: cc, msg
19
20  integer :: new_unit
21  integer :: unit10 = 10
22  integer :: unit11 = 11
23  integer :: n = 40
24  integer, parameter :: const_new_unit = 66
25
26  integer(kind=1) :: stat1
27  integer(kind=2) :: stat2
28  integer(kind=4) :: stat4
29  integer(kind=8) :: stat8
30
31  cc = 'scratch'
32
33  open(unit10)
34  open(blank='null', unit=unit10, pad='no')
35  open(unit=unit11, err=3)
363 continue
37
38  open(20, access='sequential')
39  open(21, access=access, recl=n)
40  open(22, access=access_(2), iostat=stat1, iomsg=msg)
41
42  open(30, action='readwrite', asynchronous='n'//'o', blank='zero')
43  open(31, action=action_(2), asynchronous=asynchronous_(2), blank=blank_(2))
44
45  open(unit=40, decimal="comma", delim="apostrophe", encoding="utf-8")
46  open(unit=41, decimal=decimal_(2), delim=delim_(2), encoding=encoding_(2))
47
48  open(50, file='abc', status='unknown', form='formatted')
49  open(51, file=access, status=status_(2), form=form_(2))
50
51  open(newunit=new_unit, pad=pad_(2), status='scr'//'atch'//'')
52  open(newunit=new_unit, pad=pad_(2), status=cc)
53
54  open(unit=60, position='rewind', recl=(30+20/2), round='zero')
55  open(position=position_(1), recl=n, round=round_(2), unit=61)
56
57  open(unit=70, sign='suppress', &
58      status='unknown', iostat=stat2)
59  open(unit=70, sign=sign_(2), status=status_(2))
60
61  open(80, convert='big_endian', dispose='delete')
62  open(81, convert=convert_(2), dispose=dispose_(2))
63
64  open(access='STREAM', 90) ! nonstandard
65  open (unit=91, file='xfile', carriagecontrol='list') ! nonstandard
66
67  !ERROR: OPEN statement must have a UNIT or NEWUNIT specifier
68  !ERROR: If ACCESS='DIRECT' appears, RECL must also appear
69  open(access='direct')
70
71  !ERROR: If STATUS='STREAM' appears, RECL must not appear
72  open(10, access='st'//'ream', recl=13)
73
74  !ERROR: Duplicate NEWUNIT specifier
75  !ERROR: If NEWUNIT appears, FILE or STATUS must also appear
76  open(newunit=n, newunit=nn, iostat=stat4)
77
78  !ERROR: NEWUNIT variable 'const_new_unit' must be definable
79  open(newunit=const_new_unit, status=cc)
80
81  !ERROR: Duplicate UNIT specifier
82  open(unit=100, unit=100)
83
84  !ERROR: Duplicate UNIT specifier
85  open(101, delim=delim_(1), unit=102)
86
87  !ERROR: Duplicate UNIT specifier
88  open(unit=103, &
89      unit=104, iostat=stat8)
90
91  !ERROR: Duplicate UNIT specifier
92  !ERROR: If ACCESS='DIRECT' appears, RECL must also appear
93  open(access='dir'//'ect', 9, 9) ! nonstandard
94
95  !ERROR: Duplicate ROUND specifier
96  open(105, round=round_(1), pad='no', round='nearest')
97
98  !ERROR: If NEWUNIT appears, UNIT must not appear
99  !ERROR: If NEWUNIT appears, FILE or STATUS must also appear
100  open(106, newunit=n)
101
102  !ERROR: RECL value (-30) must be positive
103  open(107, recl=40-70)
104
105  !ERROR: RECL value (-36) must be positive
106  open(108, recl=-  -  (-36)) ! nonstandard
107
108  !ERROR: Invalid ACTION value 'reedwrite'
109  open(109, access=Access, action='reedwrite', recl=77)
110
111  !ERROR: Invalid ACTION value 'nonsense'
112  open(110, action=''//'non'//'sense', recl=77)
113
114  !ERROR: Invalid STATUS value 'cold'
115  open(111, status='cold')
116
117  !ERROR: Invalid STATUS value 'Keep'
118  open(112, status='Keep')
119
120  !ERROR: If STATUS='NEW' appears, FILE must also appear
121  open(113, status='new')
122
123  !ERROR: If STATUS='REPLACE' appears, FILE must also appear
124  open(114, status='replace')
125
126  !ERROR: If STATUS='SCRATCH' appears, FILE must not appear
127  open(115, file='abc', status='scratch')
128
129  !ERROR: If NEWUNIT appears, FILE or STATUS='SCRATCH' must also appear
130  open(newunit=nn, status='old')
131
132  !ERROR: Unimplemented CARRIAGECONTROL value 'fortran'
133  open (unit=116, file='xfile', carriagecontrol='fortran') ! nonstandard
134
135  !ERROR: Invalid CARRIAGECONTROL value 'nonsense'
136  open (unit=116, file='xfile', carriagecontrol='nonsense') ! nonstandard
137end
138