file_io

moment_kinetics.file_io.debug_output_fileConstant

An nc_info instance that may be initialised for writing debug output

This is a non-const module variable, so does cause type instability, but it is only used for debugging (from debug_dump()) so performance is not critical.

source
moment_kinetics.file_io.append_to_dynamic_varFunction
append_to_dynamic_var(io_var, data, t_idx, parallel_io, coords...; only_root=false)

Append data to the dynamic variable io_var. The time-index of the data being appended is t_idx. parallel_io indicates whether parallel I/O is being used. coords... is used to get the ranges to write from/to (needed for parallel I/O) - the entries in the coords tuple can be either coordinate instances or integers (for an integer n the range is 1:n).

If only_root=true is passed, the data is only written once - from the global root process if parallel I/O is being used (if parallel I/O is not used, this has no effect as each file is only written by one process).

source
moment_kinetics.file_io.create_dynamic_variable!Function
create_dynamic_variable!(file_or_group, name, type,
                         coords::{coordinate,NamedTuple}...;
                         description=nothing, units=nothing)

Create a time-evolving variable in file_or_group named name of type type. coords are the coordinates corresponding to the dimensions of the array, in the order of the array dimensions - they may be either coordinate structs or NamedTuples that contain at least the fields name, n. The species dimension does not have a coordinate, so the number of species is passed as nspecies. A description and/or units can be added with the keyword arguments.

source
moment_kinetics.file_io.debug_dumpFunction
debug_dump(ff, dens, upar, ppar, phi, t; istage=0, label="")
debug_dump(fvec::scratch_pdf, fields::em_fields_struct, t; istage=0, label="")

Dump variables into a NetCDF file for debugging

Intended to be called more frequently than write_data_to_binary(), possibly several times within a timestep, so includes a label argument to identify the call site.

Writes to a file called debug_output.h5 in the current directory.

Can either be called directly with the arrays to be dumped (fist signature), or using scratch_pdf and em_fields_struct structs.

nothing can be passed to any of the positional arguments (if they are unavailable at a certain point in the code, or just not interesting). t=nothing will set t to the value saved in the previous call (or 0.0 on the first call). Passing nothing to the other arguments will set that array to 0.0 for this call (need to write some value so all the arrays have the same length, with an entry for each call to debug_dump()).

source
moment_kinetics.file_io.write_Dict_to_sectionMethod
write_Dict_to_section(section_io, section_dict, parallel_io)

Write the contents of section_dict into the I/O group section_io.

Any nested Dicts in section_dict are written to subsections.

All the keys in section_dict (and any nested Dicts) should be Strings.

parallel_io is a Bool indicating whether parallel I/O is being used.

source
moment_kinetics.file_io.write_single_value!Function
write_single_value!(file_or_group, name,
                    data::Union{Number, AbstractString, AbstractArray{T,N}},
                    coords::Union{coordinate,mk_int,NamedTuple}...; parallel_io,
                    description=nothing, units=nothing) where {T,N}

Write a single variable to a file or group. If a description or units are passed, add as attributes of the variable.

source