Industry standard format input and output

GeoEnergyIO.StandardIO — Module

Pure Julia readers and writers for unformatted industry standard format keyword files.

input and output provide the file-specific interfaces. read_binary and write_binary also handle arbitrary keyword files (INIT, UNRST, RFT, etc.) without discarding repeated keywords or unknown simulator-specific arrays.

source

Reading output

Paths may include the file extension or specify the case basename. The default backend is pure Julia. See resdata backend for backend=:python.

using GeoEnergyIO
grid = read_egrid("CASE")
mesh = mesh_from_grid_section(grid)
init = read_init("CASE"; units = :si, actnum = grid["ACTNUM"])
steps = read_restart("CASE"; units = :si, steps = [1, 3])
summary = read_summary("CASE"; format = :structured)

INIT and restart arrays use native units by default. units=:si converts known physical quantities; unknown arrays keep their file values. EGRID geometry defaults to metres. ACTNUM masks reduce full-grid cell arrays.

Summary values use the units declared in SMSPEC. The default layout is a flat dictionary, for example summary["WOPR"]["PRODUCER"]. format=:structured groups arrays in VALUES and includes dimensions, units, elapsed seconds, start date and column metadata.

GeoEnergyIO.StandardIO.input.read_restart — Function
read_restart(path; steps=missing, actnum=missing, egrid=missing,
             units=:native, extra_out=false)

Read unified UNRST or separate Xnnnn restart files as a vector of dictionaries, with report_step, days, and date metadata. steps selects report positions. Gaps in separate file numbering are supported. An EGRID is optional; pass actnum to reduce full-grid cell arrays explicitly.

source
GeoEnergyIO.StandardIO.input.read_init — Function
read_init(path; actnum=missing, units=:native, extra_out=false)

Read INIT arrays into a dictionary. ACTNUM masks reduce full-grid cell arrays. units=:si converts known physical quantities to SI. extra_out=true also returns the ordered KeywordFile.

source
GeoEnergyIO.StandardIO.input.read_egrid — Function
read_egrid(path; extra_out=false, units=:si)

Read the main EGRID grid in the dictionary format accepted by mesh_from_grid_section. Coordinates are converted to metres by default; units=:native retains the file's length unit. extra_out=true also returns the ordered KeywordFile, including any local grids and NNC arrays.

source
GeoEnergyIO.StandardIO.input.read_summary — Function
read_summary(path; format=:legacy, extra_out=false)

Read SMSPEC with unified UNSMRY or separate Snnnn data. The default dictionary contains arrays by keyword and identity (s["WOPR"]["PROD"], s["FOPT"]). START_DATE contains the start date. format=:structured returns DIMENS, TIME, VALUES and UNIT_SYSTEM, with FIELD, WELLS, GROUP and other collections. TIME contains a start date and elapsed seconds; value arrays retain their declared units. extra_out returns (summary, (spec=KeywordFile, data=Vector{KeywordFile})). Summary values retain the units declared by SMSPEC. Restart-chain history is not merged automatically; each case's own data are read.

source

Writing output

write_egrid(grid, "COPY")
init, raw_init = read_init("CASE"; extra_out = true)
write_init(raw_init, "COPY")
steps, raw_steps = read_restart("CASE"; extra_out = true)
write_restart(raw_steps, "COPY")
write_summary(summary, "COPY"; unified = false)

Writers support metric, field and laboratory units. Summary arrays use UNIT_SYSTEM; TIME.seconds uses seconds. SI summaries default to metric output. Set units=:field or units=:lab to select another system. With column metadata, VALUES supplies arrays and COLUMNS supplies their order and identities. Input arrays are not modified.

GeoEnergyIO.StandardIO.output.write_egrid — Function
write_egrid(data, path; units=:metric, input_units=:si)

Write a deck GRID dictionary or a whole deck to EGRID. Deck geometry uses SI units by default. Pass a raw KeywordFile to write_binary to preserve local grids and other records.

source
GeoEnergyIO.StandardIO.output.write_restart — Function
write_restart(steps, path; unified=true)

Write restart dictionaries (as returned by read_restart) or raw ordered KeywordFile blocks. Separate files are named .Xnnnn using report_step. These files contain reservoir solution arrays; they do not serialize a simulator's complete well/control restart state.

source
GeoEnergyIO.StandardIO.output.write_summary — Function
write_summary(summary, path; unified=true)

Write SMSPEC and UNSMRY (or separate Snnnn files) from a structured summary dictionary, as returned by read_summary(...; format=:structured). Required entries are DIMENS, UNITSYSTEM, TIME (`startdateand seconds), and VALUES (FIELD, WELLS and GROUP collections). SI values are converted to metric by default. Setunits` to choose another system for recognized quantities. When COLUMNS metadata is present, values are taken from the VALUES dictionary while preserving column order and identities. Long well names use the Cnnn string format. Input arrays are not mutated.

source

Keyword files

The ordered interface preserves numeric types, repeated keywords, local grids and unknown arrays.

raw = read_binary("CASE.INIT")
porosity = raw["PORO"]
all_porosity = keyword_values(raw, "PORO")
write_binary("COPY.INIT", raw)
GeoEnergyIO.StandardIO.read_binary — Function
read_binary(path_or_io; endian=:auto)

Read unformatted industry standard format records with 32-bit Fortran record markers. Numeric types and keyword ordering are preserved. Both byte orders are accepted. Malformed record markers, truncated arrays and unsupported types are errors.

source
GeoEnergyIO.StandardIO.write_binary — Function
write_binary(path_or_io, keywords; endian=:big)

Write a KeywordFile, vector of BinaryKeywords or dictionary of arrays. Repeated keywords require the ordered representation. Files use standard 1000-element numeric and 105-element string payload blocks.

source

INTE, REAL, DOUB, LOGI, CHAR, Cnnn and MESS records support both byte orders. Output defaults to big endian. String padding and LOGI true values are normalized on write. Formatted text, arrays above the signed 32-bit element limit and PVT-M unit conversion are not supported.

EGRID dictionaries represent the main grid; raw records include local grids and dual-grid metadata. Restart export contains reservoir solution arrays, without the well, control and solver state needed to resume another simulator. Summary history referenced through RESTART is not merged automatically.