Skip to content

Fall back to MNH_VERSION when MASDEV is absent - #6

Open
HugoFara wants to merge 1 commit into
QuentinRodier:mainfrom
HugoFara:fix/version-detection-fallback
Open

Fall back to MNH_VERSION when MASDEV is absent#6
HugoFara wants to merge 1 commit into
QuentinRodier:mainfrom
HugoFara:fix/version-detection-fallback

Conversation

@HugoFara

Copy link
Copy Markdown

read_netcdf indexes theFile['MASDEV'] unconditionally to decide whether a file is recent enough. netCDF4 raises when the variable is missing, so the read aborts before the version test runs:

IndexError: MASDEV not found in /

Reproduced with a diachronic file declaring MNH_VERSION = [6, 1, 0] and no MASDEV variable: main raises the above, this branch reads it and returns the data.

Meso-NH writes MNH_VERSION as three integers (src/MNH/io/mode_io_write_nc4.f90) and reads it back through IO_Mnhversion_get, so this uses it as the fallback, and compares major and minor separately rather than treating the packed MASDEV integer as one number.

Ported from Meso-NH's copy at src/LIB/Python/read_MNHfile.py; the two files are identical again.

read_TIMESfiles indexed theFile['MASDEV'] unconditionally to decide
whether a file is new enough to read. netCDF4 raises when the variable
is missing, so any diagnostic file written without MASDEV aborts the
read before the version test can be applied.

Meso-NH writes an MNH_VERSION global attribute alongside MASDEV
(src/MNH/io/mode_io_write_nc4.f90), and reads it back the same way in
IO_Mnhversion_get, so use it as the fallback. The version test is also
reworked to compare major and minor separately rather than treating the
packed MASDEV integer as a single number.

Ported from Meso-NH's in-tree copy of the module
(src/LIB/Python/read_MNHfile.py), which has carried this since the 6.x
IO changes; the two copies now match byte for byte again.
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