ADIOS2.jl
ADIOS2.jl is a Julia interface to the ADIOS2, the Adaptable Input Output System version 2.
Installation
julia>]
pkg> add ADIOS2
ADIOS2 binaries are downloaded by default using the ADIOS2_jll
package
Using a custom or system provided ADIOS2 library
Set the environment variable JULIA_ADIOS2_PATH
to the top-level installation directory for ADIOS2, i.e. the libadios2_c
and libadios2_c_mpi
(if using MPI-enabled ADIOS2) libraries should be located under $JULIA_ADIOS2_PATH/lib
or $JULIA_ADIOS2_PATH/lib64
. Then run import Pkg; Pkg.build("ADIOS2")
. This is preferred in high-performance computing (HPC) systems for system-wide installations for libraries built against vendor MPI implementations. It is highly recommended that MPIPreferences points at the system MPI implementation used to build ADIOS2.
Example:
$ export JULIA_ADIOS2_PATH=/opt/adios2/2.8.3
Then in Julia, run:
pkg> build
Basic API
Types
ADIOS2.Error
— Type@enum Error begin
error_none
error_invalid_argument
error_system_error
error_runtime_error
error_exception
end
Error
return types for all ADIOS2 functions
Based on the library C++ standardized exceptions. Each error will issue a more detailed description in the standard error output, stderr
ADIOS2.AdiosType
— Typeconst AdiosType = Union{AbstractString,
Float32,Float64,
Complex{Float32},Complex{Float64},
Int8,Int16,Int32,Int64,
UInt8,UInt16,UInt32,UInt64}
A Union of all scalar types supported in ADIOS files.
ADIOS2.Mode
— Type@enum Mode begin
mode_undefined
mode_write
mode_read
mode_append
mode_readRandomAccess
mode_deferred
mode_sync
end
Mode specifies for various functions. write
, read
, append
, and readRandomAccess
are used for file operations. deferred
and sync
are used for get and put operations.
ADIOS2.StepMode
— Type@enum StepMode begin
step_mode_append
step_mode_update
step_mode_read
end
ADIOS2.StepStatus
— Type@enum StepStatus begin
step_status_other_error
step_status_ok
step_status_not_ready
step_status_end_of_stream
end
ADIOS2.ShapeId
— Type@enum ShapeId begin
shapeid_unknown
shapeid_global_value
shapeid_global_array
shapeid_joined_array
shapeid_local_value
shapeid_local_array
end
Adios functions
ADIOS2.Adios
— Typemutable struct Adios
Holds a C pointer adios2_adios *
.
This value is finalized automatically. It can also be explicitly finalized by calling finalize(adios)
.
ADIOS2.adios_init_mpi
— Functionadios = adios_init_mpi(comm::MPI.Comm)
adios = adios_init_mpi(config_file::AbstractString, comm::MPI.Comm)
adios::Union{Adios,Nothing}
Starting point for MPI apps. Creates an ADIOS handler. MPI collective and it calls MPI_Comm_dup
.
ADIOS2.adios_init_serial
— Functionadios = adios_init_serial()
adios = adios_init_serial(config_file::AbstractString)
adios::Union{Adios,Nothing}
Initialize an Adios struct in a serial, non-MPI application. Doesn’t require a runtime config file.
See also the ADIOS2 documentation.
ADIOS2.declare_io
— Functionio = declare_io(adios::Adios, name::AbstractString)
io::Union{AIO,Nothing}
Declare a new IO handler.
See also the ADIOS2 documentation.
ADIOS2.adios_finalize
— Functionerr = adios_finalize(adios::Adios)
err::Error
Finalize the ADIOS context adios
. It is usually not necessary to call this function.
Instead of calling this function, one can also call the finalizer via finalize(adios)
. This finalizer is also called automatically when the Adios object is garbage collected.
See also the ADIOS2 documentation
IO functions
ADIOS2.AIO
— Typestruct AIO
Holds a C pointer adios2_io *
.
ADIOS2.define_variable
— Functionvariable = define_variable(io::AIO, name::AbstractString, type::Type,
shape::Union{Nothing,NTuple{N,Int} where N,CartesianIndex}=nothing,
start::Union{Nothing,NTuple{N,Int} where N,CartesianIndex}=nothing,
count::Union{Nothing,NTuple{N,Int} where N,CartesianIndex}=nothing,
constant_dims::Bool=false)
variable::Union{Nothing,Variable}
Define a variable within io
.
Arguments
io
: handler that owns the variablename
: unique variable identifiertype
: primitive typendims
: number of dimensionsshape
: global dimensionstart
: local offsetcount
: local dimensionconstant_dims
:true
: shape, start, count won't change;false
: shape, start, count will change after definition
ADIOS2.inquire_variable
— Functionvariable = inquire_variable(io::AIO, name::AbstractString)
variable::Union{Nothing,Variable}
Retrieve a variable handler within current io
handler.
Arguments
io
: handler to variableio
ownername
: unique variable identifier withinio
handler
ADIOS2.inquire_all_variables
— Functionvariables = inquire_all_variables(io::AIO)
variables::Union{Nothing,Vector{Variable}}
Returns an array of variable handlers for all variable present in the io
group.
Arguments
io
: handler to variables io owner
ADIOS2.inquire_group_variables
— Functionvars = inquire_group_variables(io::AIO, full_prefix::AbstractString)
vars::Vector{String}
List all variables in the group full_prefix
.
ADIOS2.define_attribute
— Functionattribute = define_attribute(io::AIO, name::AbstractString, value)
attribute::Union{Nothing,Attribute}
Define an attribute value inside io
.
ADIOS2.define_attribute_array
— Functionattribute = define_attribute_array(io::AIO, name::AbstractString,
values::AbstractVector)
attribute::Union{Nothing,Attribute}
Define an attribute array inside io
.
ADIOS2.define_variable_attribute
— Functionattribute = define_variable_attribute(io::AIO, name::AbstractString, value,
variable_name::AbstractString,
separator::AbstractString="/")
attribute::Union{Nothing,Attribute}
Define an attribute single value associated to an existing variable by its name.
ADIOS2.define_variable_attribute_array
— Functionattribute = define_variable_attribute_array(io::AIO, name::AbstractString,
values::AbstractVector,
variable_name::AbstractString,
separator::AbstractString="/")
attribute::Union{Nothing,Attribute}
Define an attribute array associated to an existing variable by its name.
ADIOS2.inquire_attribute
— Functionattribute = inquire_attribute(io::AIO, name::AbstractString)
attribute::Union{Nothing,Attribute}
Return a handler to a previously defined attribute by name.
ADIOS2.inquire_variable_attribute
— Functionattribute = inquire_variable_attribute(io::AIO, name::AbstractString,
variable_name::AbstractString,
separator::AbstractString="/")
attribute::Union{Nothing,Attribute}
Return a handler to a previously defined attribute by name.
ADIOS2.inquire_all_attributes
— Functionattributes = inquire_all_attributes(io::AIO)
attributes::Union{Nothing,Vector{Attribute}}
Return an array of attribute handlers for all attribute present in the io group.
ADIOS2.inquire_group_attributes
— Functionvars = inquire_group_attributes(io::AIO, full_prefix::AbstractString)
vars::Vector{String}
List all attributes in the group full_prefix
.
ADIOS2.inquire_subgroups
— Functiongroups = inquire_subgroups(io::AIO, full_prefix::AbstractString)
groups::Vector{String}
List all subgroups in the group full_prefix
.
Base.open
— Functionengine = open(io::AIO, name::AbstractString, mode::Mode)
engine::Union{Nothing,Engine}
Open an Engine to start heavy-weight input/output operations.
In MPI version reuses the communicator from adios_init_mpi
. MPI Collective function as it calls MPI_Comm_dup
.
Arguments
io
: engine ownername
: unique engine identifiermode
:mode_write
,mode_read
,mode_append
(not yet supported)
ADIOS2.engine_type
— Functiontype = engine_type(io::AIO)
type::Union{Nothing,String}
Return engine type string. See set_engine
.
ADIOS2.get_engine
— Functionengine = get_engine(io::AIO, name::AbstractString)
engine::Union{Nothing,Engine}
Variable functions
ADIOS2.Variable
— Typestruct Variable
Holds a C pointer adios2_variable *
.
ADIOS2.name
— Methodvar_name = name(variable::Variable)
var_name::Union{Nothing,String}
Retrieve variable name.
ADIOS2.type
— Methodvar_type = type(variable::Variable)
var_type::Union{Nothing,Type}
Retrieve variable type.
ADIOS2.shapeid
— Methodvar_shapeid = shapeid(variable::Variable)
var_shapeid::Union{Nothing,ShapeId}
Retrieve variable shapeid.
Base.ndims
— Methodvar_ndims = ndims(variable::Variable)
var_ndims::Union{Nothing,Int}
Retrieve current variable number of dimensions.
ADIOS2.shape
— Methodvar_shape = shape(variable::Variable)
var_shape::Union{Nothing,NTuple{N,Int} where N}
Retrieve current variable shape.
ADIOS2.start
— Methodvar_start = start(variable::Variable)
var_start::Union{Nothing,NTuple{N,Int} where N}
Retrieve current variable start.
Base.count
— Methodvar_count = count(variable::Variable)
var_count::Union{Nothing,NTuple{N,Int} where N}
Retrieve current variable count.
ADIOS2.steps_start
— Methodvar_steps_start = steps_start(variable::Variable)
var_steps_start::Union{Nothing,Int}
Read API, get available steps start from available steps count (e.g. in a file for a variable).
This returns the absolute first available step, don't use with adios2_set_step_selection
as inputs are relative, use 0
instead.
ADIOS2.steps
— Methodvar_steps = steps(variable::Variable)
var_steps::Union{Nothing,Int}
Read API, get available steps count from available steps count (e.g. in a file for a variable). Not necessarily contiguous.
ADIOS2.selection_size
— Methodvar_selection_size = selection_size(variable::Variable)
var_selection_size::Union{Nothing,Int}
Return the minimum required allocation (in number of elements of a certain type, not bytes) for the current selection.
Base.minimum
— Methodvar_min = minimum(variable::Variable)
var_min::Union{Nothing,T}
Read mode only: return the absolute minimum for variable.
Base.maximum
— Methodvar_max = maximum(variable::Variable)
var_max::Union{Nothing,T}
Read mode only: return the absolute maximum for variable.
Attribute functions
ADIOS2.Attribute
— Typestruct Attribute
Holds a C pointer adios2_attribute *
.
ADIOS2.name
— Methodattr_name = name(attribute::Attribute)
attr_name::Union{Nothing,String}
Retrieve attribute name.
ADIOS2.type
— Methodattr_type = type(attribute::Attribute)
attr_type::Union{Nothing,Type}
Retrieve attribute type.
ADIOS2.is_value
— Methodattr_is_value = is_value(attribute::Attribute)
attr_is_value::Union{Nothing,Bool}
Retrieve attribute type.
Base.size
— Methodattr_size = size(attribute::Attribute)
attr_size::Union{Nothing,Int}
Retrieve attribute size.
ADIOS2.data
— Methodattr_data = data(attribute::Attribute)
attr_data::Union{Nothing,AdiosType,Vector{<:AdiosType}}
Retrieve attribute Data.
Engine functions
ADIOS2.Engine
— Typestruct Engine
Holds a C pointer adios2_engine *
.
ADIOS2.name
— Functionvar_name = name(variable::Variable)
var_name::Union{Nothing,String}
Retrieve variable name.
attr_name = name(attribute::Attribute)
attr_name::Union{Nothing,String}
Retrieve attribute name.
engine_name = name(engine::Engine)
engine_name::Union{Nothing,String}
Retrieve engine name.
ADIOS2.type
— Functionvar_type = type(variable::Variable)
var_type::Union{Nothing,Type}
Retrieve variable type.
attr_type = type(attribute::Attribute)
attr_type::Union{Nothing,Type}
Retrieve attribute type.
engine_type = type(engine::Engine)
engine_type::Union{Nothing,String}
Retrieve engine type.
ADIOS2.openmode
— Functionengine_openmode = openmode(engine::Engine)
engine_openmode::Union{Nothing,Mode}
Retrieve engine openmode.
ADIOS2.begin_step
— Functionstatus = begin_step(engine::Engine, mode::StepMode,
timeout_seconds::Union{Integer,AbstractFloat})
status = begin_step(engine::Engine)
status::Union{Noting,StepStatus}
Begin a logical adios2 step stream.
ADIOS2.current_step
— Functionstep = current_step(engine::Engine)
step::Union{Noting,Int}
Inspect current logical step.
ADIOS2.steps
— Functionvar_steps = steps(variable::Variable)
var_steps::Union{Nothing,Int}
Read API, get available steps count from available steps count (e.g. in a file for a variable). Not necessarily contiguous.
step = steps(engine::Engine)
step::Union{Noting,Int}
Inspect total number of available steps.
Base.put!
— Functionerr = Base.put!(engine::Engine, variable::Variable,
data::Union{Ref,DenseArray,SubArray,Ptr},
launch::Mode=mode_deferred)
err = Base.put!(engine::Engine, variable::Variable, data::AdiosType,
launch::Mode=mode_deferred)
err::Error
Schedule writing a variable to file. The buffer data
must be contiguous in memory.
Call perform_puts!
to perform the actual write operations.
The reference/array/pointer target must not be modified before perform_puts!
is called. It is most efficient to schedule multiple put!
operations before calling perform_puts!
.
ADIOS2.perform_puts!
— Functionperform_puts!(engine::Engine)
Execute all currently scheduled write operations.
Base.get
— Functionerr = Base.get(engine::Engine, variable::Variable,
data::Union{Ref,DenseArray,SubArray,Ptr},
launch::Mode=mode_deferred)
err::Error
Schedule reading a variable from file into the provided buffer data
. data
must be contiguous in memory.
Call perform_gets
to perform the actual read operations.
The reference/array/pointer target must not be modified before perform_gets
is called. It is most efficient to schedule multiple get
operations before calling perform_gets
.
ADIOS2.perform_gets
— Functionperform_gets(engine::Engine)
Execute all currently scheduled read operations.
ADIOS2.end_step
— Functionend_step(engine::Engine)
Terminate interaction with current step.
Base.flush
— Methodflush(engine::Engine)
Flush all buffered data to file. Call this after perform_puts!
to ensure data are actually written to file.
Base.close
— Methodclose(engine::Engine)
Close a file. This implicitly also flushed all buffered data.
High-Level API
ADIOS2.AdiosFile
— Typestruct AdiosFile
Context for the high-level API for an ADIOS file
ADIOS2.adios_open_serial
— Functionadios = adios_open_serial(filename::AbstractString, mode::Mode)
adios::AdiosFile
Open an ADIOS file. Use mode = mode_write
for writing and mode = mode_read
for reading.
ADIOS2.adios_open_mpi
— Functionadios = adios_open_mpi(comm::MPI.Comm, filename::AbstractString, mode::Mode)
adios::AdiosFile
Open an ADIOS file for parallel I/O. Use mode = mode_write
for writing and mode = mode_read
for reading.
Base.flush
— Methodflush(file::AdiosFile)
Flush an ADIOS file. When writing, flushing or closing a file is necesssary to ensure that data are actually written to the file.
Base.close
— Methodclose(file::AdiosFile)
Close an ADIOS file. When writing, flushing or closing a file is necesssary to ensure that data are actually written to the file.
ADIOS2.adios_subgroup_names
— Functiongroups = adios_subgroup_names(file::AdiosFile, groupname::AbstractString)
vars::Vector{String}
List (non-recursively) all subgroups in the group groupname
in the file.
ADIOS2.adios_define_attribute
— Functionadiosdefineattribute(file::AdiosFile, name::AbstractString, value::AdiosType)
Write a scalar attribute.
adios_define_attribute(file::AdiosFile, name::AbstractString,
value::AbstractArray{<:AdiosType})
Write an array-valued attribute.
adios_define_attribute(file::AdiosFile, path::AbstractString,
name::AbstractString, value::AdiosType)
Write a scalar attribute into the path path
in the file.
adios_define_attribute(file::AdiosFile, path::AbstractString,
name::AbstractString,
value::AbstractArray{<:AdiosType})
Write an array-valued attribute into the path path
in the file.
ADIOS2.adios_all_attribute_names
— Functionattrs = adios_all_attribute_names(file::AdiosFile)
attrs::Vector{String}
List (recursively) all attributes in the file.
ADIOS2.adios_group_attribute_names
— Functionvars = adios_group_attribute_names(file::AdiosFile, groupname::AbstractString)
vars::Vector{String}
List (non-recursively) all attributes in the group groupname
in the file.
ADIOS2.adios_attribute_data
— Functionattr_data = adios_attribute_data(file::AdiosFile, name::AbstractString)
attr_data::Union{Nothing,AdiosType}
Read an attribute from a file. Return nothing
if the attribute is not found.
attr_data = adios_attribute_data(file::AdiosFile, path::AbstractString,
name::AbstractString)
attr_data::Union{Nothing,AdiosType}
Read an attribute from a file in path path
. Return nothing
if the attribute is not found.
ADIOS2.adios_put!
— Functionadios_put!(file::AdiosFile, name::AbstractString, scalar::AdiosType)
Schedule writing a scalar variable to a file.
The variable is not written until adios_perform_puts!
is called and the file is flushed or closed.
adios_put!(file::AdiosFile, name::AbstractString,
array::AbstractArray{<:AdiosType}; make_copy::Bool=false)
Schedule writing an array-valued variable to a file.
make_copy
determines whether to make a copy of the array, which is expensive for large arrays. When no copy is made, then the array must not be modified before adios_perform_puts!
is called.
The variable is not written until adios_perform_puts!
is called and the file is flushed or closed.
ADIOS2.adios_perform_puts!
— Functionadios_perform_puts!(file::AdiosFile)
Execute all scheduled adios_put!
operations.
The data might not be in the file yet; they might be buffered. Call adios_flush
or adios_close
to ensure all data are written to file.
ADIOS2.adios_all_variable_names
— Functionvars = adios_all_variable_names(file::AdiosFile)
vars::Vector{String}
List (recursively) all variables in the file.
ADIOS2.adios_group_variable_names
— Functionvars = adios_group_variable_names(file::AdiosFile, groupname::AbstractString)
vars::Vector{String}
List (non-recursively) all variables in the group groupname
in the file.
ADIOS2.IORef
— Typemutable struct IORef{T,D}
A reference to the value of a variable that has been scheduled to be read from disk. This value cannot be accessed bofre the read operations have actually been executed.
Use fetch(ioref::IORef)
to access the value. fetch
will trigger the actual reading from file if necessary. It is most efficient to schedule multiple read operations at once.
Use adios_perform_gets
to trigger reading all currently scheduled variables.
Base.isready
— Methodisready(ioref::IORef)::Bool
Check whether an IORef
has already been read from file.
Base.fetch
— Methodvalue = fetch(ioref::IORef{T,D}) where {T,D}
value::Array{T,D}
Access an IORef
. If necessary, the variable is read from file and then cached. (Each IORef
is read at most once.)
Scalars are handled as zero-dimensional arrays. To access the value of a zero-dimensional array, write array[]
(i.e. use array indexing, but without any indices).
ADIOS2.adios_get
— Functionioref = adios_get(file::AdiosFile, name::AbstractString)
ioref::Union{Nothing,IORef}
Schedule reading a variable from a file.
The variable is not read until adios_perform_gets
is called. This happens automatically when the IORef
is accessed (via fetch
). It is most efficient to first schedule multiple variables for reading, and then executing the reads together.
ADIOS2.adios_perform_gets
— Functionadios_perform_gets(file::AdiosFile)
Execute all currently scheduled read opertions. This makes all pending IORef
s ready.