2 ! PR34795 inquire statement , direct= specifier incorrectly returns YES
3 ! Test case from PR, modified by Jerry DeLisle <jvdelisle@gcc.gnu.org
6 character drct
*7, acc
*12, frmt
*12, seqn
*12, fname
*15
9 fname
="inquire_13_test"
10 inquire(unit
=6, direct
=drct
, opened
=opn
, access
=acc
)
11 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
13 inquire(unit
=10, direct
=drct
, opened
=opn
, access
=acc
)
14 if (drct
.ne
."UNKNOWN" .and
. opn
.and
. acc
.ne
."UNDEFINED") call abort
16 inquire(unit
=10, direct
=drct
, opened
=opn
, access
=acc
, formatted
=frmt
)
17 if (drct
.ne
."UNKNOWN" .and
. opn
.and
. acc
.ne
."UNDEFINED") call abort
18 if (frmt
.ne
."UNKNOWN") call abort
20 open(unit
=19,file
=fname
,status
='replace',err
=170,form
="formatted")
21 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
,formatted
=frmt
)
22 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
23 if (frmt
.ne
."YES") call abort
25 ! Inquire on filename, open file with DIRECT and FORMATTED
26 inquire(file
=fname
, direct
=drct
, opened
=opn
, access
=acc
, FORMATTED
=frmt
)
27 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
28 if (frmt
.ne
."YES") call abort
31 ! Inquire on filename, closed file with DIRECT and FORMATTED
32 inquire(file
=fname
, direct
=drct
, opened
=opn
, access
=acc
, formatted
=frmt
)
33 if (drct
.ne
."UNKNOWN" .and
. opn
.and
. acc
.ne
."UNDEFINED") call abort
34 if (frmt
.ne
."UNKNOWN") call abort
36 open(unit
=19,file
=fname
,status
='replace',err
=170,form
="unformatted")
37 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
, formatted
=frmt
)
38 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
39 if (frmt
.ne
."NO") call abort
42 open(unit
=19,file
=fname
,status
='replace',err
=170,form
="formatted")
44 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
, unformatted
=frmt
)
45 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
47 ! Inquire on filename, open file with DIRECT and UNFORMATTED
48 inquire(file
=fname
, direct
=drct
, opened
=opn
, access
=acc
, UNFORMATTED
=frmt
)
49 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
50 if (frmt
.ne
."NO") call abort
53 ! Inquire on filename, closed file with DIRECT and UNFORMATTED
54 inquire(file
=fname
, direct
=drct
, opened
=opn
, access
=acc
, unformatted
=frmt
)
55 if (drct
.ne
."UNKNOWN" .and
. opn
.and
. acc
.ne
."UNDEFINED") call abort
56 if (frmt
.ne
."UNKNOWN") call abort
58 open(unit
=19,file
=fname
,status
='replace',err
=170,form
="unformatted")
60 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
,unformatted
=frmt
)
61 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
62 if (frmt
.ne
."YES") call abort
65 open(unit
=19,file
=fname
,status
='replace',err
=170)
67 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
)
68 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
71 open(unit
=19,file
=fname
,status
='replace',err
=170,access
='SEQUENTIAL')
73 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
)
74 if (drct
.ne
."NO" .and
. .not
.opn
.and
. acc
.ne
."SEQUENTIAL") call abort
76 ! Inquire on filename, open file with SEQUENTIAL
77 inquire(file
=fname
, SEQUENTIAL
=seqn
, opened
=opn
, access
=acc
)
78 if (seqn
.ne
."YES" .and
. .not
.opn
.and
. acc
.ne
."DIRECT") call abort
81 ! Inquire on filename, closed file with SEQUENTIAL
82 inquire(file
=fname
, SEQUENTIAL
=seqn
, opened
=opn
, access
=acc
)
83 if (seqn
.ne
."UNKNOWN" .and
. opn
.and
. acc
.ne
."UNDEFINED") call abort
85 open(unit
=19,file
=fname
,status
='replace',err
=170,form
='UNFORMATTED',access
='DIRECT',recl
=72)
87 inquire(unit
=19, direct
=drct
, opened
=opn
, access
=acc
)
88 if (drct
.ne
."YES" .and
. .not
.opn
.and
. acc
.ne
."DIRECT") call abort
90 ! Inquire on filename, open file with DIRECT
91 inquire(file
=fname
, direct
=drct
, opened
=opn
, access
=acc
)
92 if (drct
.ne
."YES" .and
. .not
.opn
.and
. acc
.ne
."DIRECT") call abort
93 close(19, status
="delete")
95 ! Inquire on filename, closed file with DIRECT
96 inquire(file
=fname
, direct
=drct
, opened
=opn
, access
=acc
)
97 if (drct
.ne
."UNKNOWN" .and
. opn
.and
. acc
.ne
."UNDEFINED") call abort
100 170 write(*,*) "ERROR: unable to open testdirect.f"