FileInquire

Asks the runtime about a unit or a file.

Declaration

Syntax

FileInquire(int label, expr? unit, expr? file, expr? iostat, expr? err,
    expr? exist, expr? opened, expr? number, expr? named, expr? name,
    expr? access, expr? sequential, expr? direct, expr? form,
    expr? formatted, expr? unformatted, expr? recl, expr? nextrec,
    expr? blank, expr? position, expr? action, expr? read, expr? write,
    expr? readwrite, expr? delim, expr? pad, expr? flen,
    expr? blocksize, expr? convert, expr? carriagecontrol, expr? size,
    expr? pos, expr? iolength, expr* iolength_vars, expr? decimal,
    expr? sign, expr? encoding, expr? stream, expr? iomsg, expr? round,
    expr? pending, expr? asynchronous)

Arguments

Argument

Description

label

the statement label of the Fortran statement, or -1 when it has none.

unit

the unit to ask about. Exactly one of unit and file is given.

file

the file name to ask about.

iostat

a variable receiving the I/O status: zero on success, non-zero otherwise. The statement does not abort when it is present.

err

the label to branch to when the operation fails.

exist

a logical variable receiving whether the file exists.

opened

a logical variable receiving whether it is connected.

number

an integer variable receiving the unit number.

named

a logical variable receiving whether the unit has a name.

name

a character variable receiving the file name.

access

receives sequential, direct or stream.

sequential

receives whether sequential access is allowed.

direct

receives whether direct access is allowed.

form

receives formatted or unformatted.

formatted

receives whether formatted I/O is allowed.

unformatted

receives whether unformatted I/O is allowed.

recl

receives the record length.

nextrec

receives the number of the next record.

blank

receives the blank mode.

position

receives the position mode.

action

receives read, write or readwrite.

read

receives whether reading is allowed.

write

receives whether writing is allowed.

readwrite

receives whether both are allowed.

delim

receives the delimiter mode.

pad

receives the pad mode.

flen

receives the length of the file.

blocksize

receives the block size of the connection.

convert

receives the byte order conversion mode.

carriagecontrol

receives the carriage control mode.

size

receives the size of the file in bytes.

pos

receives the current stream position.

iolength

receives the record length needed for iolength_vars.

iolength_vars

the output list to measure for iolength=.

decimal

receives the decimal edit mode.

sign

receives the sign mode.

encoding

receives the encoding.

stream

receives whether stream access is allowed.

iomsg

a variable receiving the error message when the operation fails.

round

receives the rounding mode.

pending

receives whether an asynchronous transfer is pending.

asynchronous

receives whether asynchronous transfer is allowed.

Return values

None.

Description

inquire is one statement with many independent outputs, and each of them is a member here. Every member other than the thing being asked about is a variable the runtime writes to, so a backend implements the statement by filling in the members that are not nil.

The iolength= form is different from the others: it measures the output list in iolength_vars instead of asking about a connection, and neither unit nor file is given.

Examples

(FileInquire
  :label -1
  :unit (Var
    :v (SymbolRef 1 "unit")
  )
  :file nil
  :iostat nil
  :err nil
  :exist (Var
    :v (SymbolRef 1 "exists")
  )
  :opened nil
  :number nil
  :named nil
  :name nil
  :access nil
  :sequential nil
  :direct nil
  :form nil
  :formatted nil
  :unformatted nil
  :recl nil
  :nextrec nil
  :blank nil
  :position nil
  :action nil
  :read nil
  :write nil
  :readwrite nil
  :delim nil
  :pad nil
  :flen nil
  :blocksize nil
  :convert nil
  :carriagecontrol nil
  :size nil
  :pos nil
  :iolength nil
  :iolength_vars []
  :decimal nil
  :sign nil
  :encoding nil
  :stream nil
  :iomsg nil
  :round nil
  :pending nil
  :asynchronous nil
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "exists" (Variable
              :parent_symtab 1
              :name "exists"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Logical
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "iostat" (Variable
              :parent_symtab 1
              :name "iostat"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "n" (Variable
              :parent_symtab 1
              :name "n"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "unit" (Variable
              :parent_symtab 1
              :name "unit"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (FileOpen
            :label -1
            :newunit (Var
              :v (SymbolRef 1 "unit")
            )
            :filename (StringConstant
              :s "data.txt"
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 8
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
            )
            :status (StringConstant
              :s "old"
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 3
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
            )
            :form nil
            :access nil
            :iostat (Var
              :v (SymbolRef 1 "iostat")
            )
            :iomsg nil
            :action nil
            :delim nil
            :recl nil
            :position nil
            :blank nil
            :encoding nil
            :sign nil
            :decimal nil
            :round nil
            :pad nil
            :asynchronous nil
          )
          (FileRead
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :fmt nil
            :iomsg nil
            :iostat (Var
              :v (SymbolRef 1 "iostat")
            )
            :advance nil
            :size nil
            :id nil
            :pos nil
            :values [
              (Var
                :v (SymbolRef 1 "n")
              )
            ]
            :overloaded nil
            :is_formatted true
            :nml nil
            :rec nil
            :pad nil
          )
          (FileWrite
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :iomsg nil
            :iostat nil
            :id nil
            :values [
              (Var
                :v (SymbolRef 1 "n")
              )
            ]
            :separator nil
            :end nil
            :overloaded nil
            :is_formatted true
            :nml nil
            :rec nil
            :pos nil
            :asynchronous nil
          )
          (FileBackspace
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :iostat nil
            :iomsg nil
            :err nil
          )
          (FileRewind
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :iostat nil
            :err nil
            :iomsg nil
          )
          (FileEndfile
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :iostat nil
            :iomsg nil
            :err nil
          )
          (Flush
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :err nil
            :iomsg nil
            :iostat nil
          )
          (FileInquire
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :file nil
            :iostat nil
            :err nil
            :exist (Var
              :v (SymbolRef 1 "exists")
            )
            :opened nil
            :number nil
            :named nil
            :name nil
            :access nil
            :sequential nil
            :direct nil
            :form nil
            :formatted nil
            :unformatted nil
            :recl nil
            :nextrec nil
            :blank nil
            :position nil
            :action nil
            :read nil
            :write nil
            :readwrite nil
            :delim nil
            :pad nil
            :flen nil
            :blocksize nil
            :convert nil
            :carriagecontrol nil
            :size nil
            :pos nil
            :iolength nil
            :iolength_vars []
            :decimal nil
            :sign nil
            :encoding nil
            :stream nil
            :iomsg nil
            :round nil
            :pending nil
            :asynchronous nil
          )
          (FileClose
            :label -1
            :unit (Var
              :v (SymbolRef 1 "unit")
            )
            :iostat nil
            :iomsg nil
            :err nil
            :status nil
          )
        ]
      )
    }
  )
  :items []
)

See Also

FileOpen, FileClose