1! { dg-do run } 2! { dg-options "-std=legacy" } 3! 4! PR34795 inquire statement , direct= specifier incorrectly returns YES 5! Test case from PR, modified by Jerry DeLisle <jvdelisle@gcc.gnu.org 6program testinquire 7implicit none 8character drct*7, acc*12, frmt*12, seqn*12, fname*15 9logical opn 10 11fname="inquire_13_test" 12inquire(unit=6, direct=drct, opened=opn, access=acc) 13if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 14 15inquire(unit=10, direct=drct, opened=opn, access=acc) 16if (drct.ne."UNKNOWN" .and. opn .and. acc.ne."UNDEFINED") call abort 17 18inquire(unit=10, direct=drct, opened=opn, access=acc, formatted=frmt) 19if (drct.ne."UNKNOWN" .and. opn .and. acc.ne."UNDEFINED") call abort 20if (frmt.ne."UNKNOWN") call abort 21 22open(unit=19,file=fname,status='replace',err=170,form="formatted") 23inquire(unit=19, direct=drct, opened=opn, access=acc,formatted=frmt) 24if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 25if (frmt.ne."YES") call abort 26 27! Inquire on filename, open file with DIRECT and FORMATTED 28inquire(file=fname, direct=drct, opened=opn, access=acc, FORMATTED=frmt) 29if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 30if (frmt.ne."YES") call abort 31close(19) 32 33! Inquire on filename, closed file with DIRECT and FORMATTED 34inquire(file=fname, direct=drct, opened=opn, access=acc, formatted=frmt) 35if (drct.ne."UNKNOWN" .and. opn .and. acc.ne."UNDEFINED") call abort 36if (frmt.ne."UNKNOWN") call abort 37 38open(unit=19,file=fname,status='replace',err=170,form="unformatted") 39inquire(unit=19, direct=drct, opened=opn, access=acc, formatted=frmt) 40if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 41if (frmt.ne."NO") call abort 42close(19) 43 44open(unit=19,file=fname,status='replace',err=170,form="formatted") 45 46inquire(unit=19, direct=drct, opened=opn, access=acc, unformatted=frmt) 47if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 48 49! Inquire on filename, open file with DIRECT and UNFORMATTED 50inquire(file=fname, direct=drct, opened=opn, access=acc, UNFORMATTED=frmt) 51if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 52if (frmt.ne."NO") call abort 53close(19) 54 55! Inquire on filename, closed file with DIRECT and UNFORMATTED 56inquire(file=fname, direct=drct, opened=opn, access=acc, unformatted=frmt) 57if (drct.ne."UNKNOWN" .and. opn .and. acc.ne."UNDEFINED") call abort 58if (frmt.ne."UNKNOWN") call abort 59 60open(unit=19,file=fname,status='replace',err=170,form="unformatted") 61 62inquire(unit=19, direct=drct, opened=opn, access=acc,unformatted=frmt) 63if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 64if (frmt.ne."YES") call abort 65close(19) 66 67open(unit=19,file=fname,status='replace',err=170) 68 69inquire(unit=19, direct=drct, opened=opn, access=acc) 70if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 71close(19) 72 73open(unit=19,file=fname,status='replace',err=170,access='SEQUENTIAL') 74 75inquire(unit=19, direct=drct, opened=opn, access=acc) 76if (drct.ne."NO" .and. .not.opn .and. acc.ne."SEQUENTIAL") call abort 77 78! Inquire on filename, open file with SEQUENTIAL 79inquire(file=fname, SEQUENTIAL=seqn, opened=opn, access=acc) 80if (seqn.ne."YES" .and. .not.opn .and. acc.ne."DIRECT") call abort 81close(19) 82 83! Inquire on filename, closed file with SEQUENTIAL 84inquire(file=fname, SEQUENTIAL=seqn, opened=opn, access=acc) 85if (seqn.ne."UNKNOWN" .and. opn .and. acc.ne."UNDEFINED") call abort 86 87open(unit=19,file=fname,status='replace',err=170,form='UNFORMATTED',access='DIRECT',recl=72) 88 89inquire(unit=19, direct=drct, opened=opn, access=acc) 90if (drct.ne."YES" .and. .not.opn .and. acc.ne."DIRECT") call abort 91 92! Inquire on filename, open file with DIRECT 93inquire(file=fname, direct=drct, opened=opn, access=acc) 94if (drct.ne."YES" .and. .not.opn .and. acc.ne."DIRECT") call abort 95close(19, status="delete") 96 97! Inquire on filename, closed file with DIRECT 98inquire(file=fname, direct=drct, opened=opn, access=acc) 99if (drct.ne."UNKNOWN" .and. opn .and. acc.ne."UNDEFINED") call abort 100stop 101 102170 write(*,*) "ERROR: unable to open testdirect.f" 103end 104