FileOpen¶
Connects a unit to a file.
Declaration¶
Syntax¶
FileOpen(int label, expr? newunit, expr? filename, expr? status,
expr? form, expr? access, expr? iostat, expr? iomsg, expr? action,
expr? delim, expr? recl, expr? position, expr? blank,
expr? encoding, expr? sign, expr? decimal, expr? round, expr? pad,
expr? asynchronous)
Arguments¶
Argument |
Description |
|---|---|
|
the statement label of the Fortran statement, or |
|
a variable receiving a unit number chosen by the runtime, for |
|
the name of the file to connect. |
|
|
|
|
|
|
|
a variable receiving the I/O status: zero on success, non-zero otherwise. The statement does not abort when it is present. |
|
a variable receiving the error message when the operation fails. |
|
|
|
the delimiter used around character values in list-directed and namelist output. |
|
the record length of a direct access file. |
|
|
|
|
|
|
|
|
|
|
|
the rounding mode for formatted conversion. |
|
|
|
|
Return values¶
None.
Description¶
Every specifier of the open statement has its own member, so nothing has to
be recovered from a list of keyword arguments later. All of them are optional
and a nil member means the specifier was not written, leaving the default to
the runtime.
newunit and a user-chosen unit number are alternatives: with newunit= the
runtime picks a free unit and stores it in that variable.
Examples¶
(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
)
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 []
)