Skip to content

EAMxx: replace AtmosphereInput with a lean FieldReader class#8388

Open
bartgol wants to merge 8 commits into
masterfrom
bartgol/eamxx/field-reader
Open

EAMxx: replace AtmosphereInput with a lean FieldReader class#8388
bartgol wants to merge 8 commits into
masterfrom
bartgol/eamxx/field-reader

Conversation

@bartgol
Copy link
Copy Markdown
Contributor

@bartgol bartgol commented May 12, 2026

Replace the AtmosphereInput class with a lightweight class that is native to eamxx_field library.

[BFB]


A few highlights.

  • Along the FieldReader class, there are also a few overloads of a read_fields function, which is helpful for one-off reads, that are not interested in keeping a reader around.
  • The new class is much slimmer, which is all we really need in eamxx.
  • There is no need to link against eamxx_io to read in fields. This utility simply relies on eamxx_field and eamxx_scorpio_interface. E.g., grids and remappers (that are built before eamxx_io) can use the utility to get stuff from IC/map files.
  • I am thinking of also having a FieldWriter class, which does NO averaging, NO remapping, NO diags calculation, it JUST writes fields to a file. IO could use it as a building block, but more importantly it can be used in atm process for debugging, without the heavy machinery of AtmosphereOutput, and can also help for unit tests (e.g., remap unit tests do a bunch of scorpio::xyz calls to write to file, while we could just do write_fields (filename,{a,b,c});.

bartgol added 2 commits May 12, 2026 16:35
We were allowed to call get_view<double*> on an IntType field
@bartgol bartgol self-assigned this May 12, 2026
@bartgol bartgol force-pushed the bartgol/eamxx/field-reader branch 2 times, most recently from 5f2e4ef to 1e5bfe7 Compare May 15, 2026 15:28
bartgol and others added 5 commits May 15, 2026 09:29
This class will replace AtmosphereInput, as a very lightweight
class with very little dependencies (only the Field class and
the scorpio interfaces)
Avoid hand-rolling of the same code multiple times
- in grid: when resetting a field tag name, we must update any
  geo data currently stored to reflect the change
- in scorpio interface: when creating single-dim decomp, store the dim
  in the DimDecomp structure
Instead, use FieldReader class or read_fields util
When FieldReader::reset_filename switches to a new file, scorpio
dimension decompositions are per-file and thus lost. Reads then fell
back to the non-decomposed path, causing all ranks to read the full
global array into local-sized buffers (SIGBUS/SIGSEGV with 2+ ranks).

Fix by storing the MPI comm alongside the decomp GIDs in FieldReader,
and re-applying set_dim_decomp to the new file inside reset_filename
whenever a decomp had previously been established.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bartgol bartgol force-pushed the bartgol/eamxx/field-reader branch from 1e5bfe7 to 8622bc8 Compare May 15, 2026 15:29
… grid

The special name is ONLY needed to read fields,
so just rename the tag in the field aliases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant