program main
  implicit none
  character(32) :: f
  logical        :: exst
  logical        :: opnd
  character(128) :: nam
  integer        :: num
  character(16)  :: frm
  character(16)  :: acss
  integer        :: rcl
  character(16)  :: act
  character(16)  :: pos
  character(16)  :: conv
  integer, parameter :: un = 11

  f = 'inquire.f90'
  open(un, file=f, status='old')
  inquire(un, exist=exst, opened=opnd, name=nam, number=num, form=frm, &
          access=acss, recl=rcl, action=act, position=pos, convert=conv)

  print*, 'Opened '//trim(f)//' with the unit number ', un
  print*, '  number  : ', num
  print*, '  exist   : ', exst
  print*, '  opened  : ', opnd
  print*, '  name    : ', trim(nam)
  print*, '  form    : ', trim(frm)
  print*, '  access  : ', trim(acss)
  print*, '  recl    : ', rcl
  print*, '  action  : ', trim(act)
  print*, '  position: ', trim(pos)
  print*, '  convert : ', trim(conv)

  close(un)
  inquire(un, exist=exst, opened=opnd, name=nam, number=num, form=frm, &
          access=acss, recl=rcl, action=act, position=pos, convert=conv)
  print*, 'Closed.'
  print*, '  number  : ', num
  print*, '  exist   : ', exst
  print*, '  opened  : ', opnd
  print*, '  name    : ', trim(nam)
  print*, '  form    : ', trim(frm)
  print*, '  access  : ', trim(acss)
  print*, '  recl    : ', rcl
  print*, '  action  : ', trim(act)
  print*, '  position: ', trim(pos)
  print*, '  convert : ', trim(conv)

  f = 'tmp.bin'
  open(un, file=f, form='unformatted', access='direct', &
       recl=4*10, status='old')
  inquire(file=f, &
          exist=exst, opened=opnd, name=nam, number=num, form=frm, &
          access=acss, recl=rcl, action=act, position=pos, convert=conv)
  print*, 'Opened '//trim(f)//' with the unit number ', un
  print*, '  number  : ', num
  print*, '  exist   : ', exst
  print*, '  opened  : ', opnd
  print*, '  name    : ', trim(nam)
  print*, '  form    : ', trim(frm)
  print*, '  access  : ', trim(acss)
  print*, '  recl    : ', rcl
  print*, '  action  : ', trim(act)
  print*, '  position: ', trim(pos)
  print*, '  convert : ', trim(conv)

  close(un)
  inquire(file=f, &
          exist=exst, opened=opnd, name=nam, number=num, form=frm, &
          access=acss, recl=rcl, action=act, position=pos, convert=conv)
  print*, 'Closed.'
  print*, '  number  : ', num
  print*, '  exist   : ', exst
  print*, '  opened  : ', opnd
  print*, '  name    : ', trim(nam)
  print*, '  form    : ', trim(frm)
  print*, '  access  : ', trim(acss)
  print*, '  recl    : ', rcl
  print*, '  action  : ', trim(act)
  print*, '  position: ', trim(pos)
  print*, '  convert : ', trim(conv)

  inquire(-999, exist=exst)
  print*, 'Unit number -999'
  print*, '  exist: ', exst

  inquire(file='hoge.bin', exist=exst)
  print*, 'File hoge.bin'
  print*, '  exist: ', exst
end program main