Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExodusII IO has variable ID bug which can prevent coordinates from being read-in from a file #3823

Open
EdwardPalmer99 opened this issue Apr 5, 2024 · 4 comments

Comments

@EdwardPalmer99
Copy link

Brief

  • Version 5.22b of the exodusii library contains a bug in the ex_get_coord function. Note that this issue is not present in version v8.11.

What is the problem?

  • NetCDF variable IDs are numbered starting from 0 in C (from 1 in Fortran) https://docs.unidata.ucar.edu/netcdf-c/current/tutorial_ncids.html
  • Version 5.22b contains a bug in the file ex_get_coord.c on line 238 where if the variable ID of a coordinate is 0 (which is a valid variable ID!) then the coordinate data will not be read from the file. This will result in one of the coordinates being an array of zeros. This was a problem that I encountered when reading in certain ExodusII files.
  • This bug has been addressed in more recent versions of the ExodusII library by comparing against a value of (-1) which is not a valid variable ID. I recommend updating the exodusii reader or changing this line in the source code.

Links

Code
if (coor != NULL && coordid != 0)

@jwpeterson
Copy link
Member

Hi @EdwardPalmer99,

Thanks for the info. For quite a while now, I believe we default to using Exodus v8.11 in libMesh, so hopefully this bug does not affect many of our users. I'm curious, if you are actually using libmesh and still getting Exodus 5.22b, what version of libmesh are you using and how is it configured?

We could try and patch the 5.22 sources that we bundle with libmesh, but at this point it might be more productive to actually remove them from master and make sure that everyone is using v8.11.

@EdwardPalmer99
Copy link
Author

Hi, the libmesh commit hash is 7dbd90a (2nd April 2024). This is the version currently in use by the master branch of Moose. Libmesh was built without the optional HDF5 library which may be why the older 5.22 Exodus version was used.
Screenshot from 2024-04-05 11-56-07
Screenshot from 2024-04-05 11-52-41

@roystgnr
Copy link
Member

roystgnr commented Apr 9, 2024

We default to v8.11 when we have HDF5 available, but I think it's important to keep v5.22 around for users without HDF5.

The diff is much larger, but it looks like a fix would be a half dozen lines of it. I wouldn't want to futz around forking old Exodus without better test coverage of the issue too, though. Can you come up with a short Exodus file that triggers the bug?

@EdwardPalmer99
Copy link
Author

Yes, this is a simple ExodusII file. It can be read-in successfully using Coreform Cubit. Please note that I have changed the extension to 'txt' in order to upload it to Github.

simple-cube-hex8-dodgy.txt

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

No branches or pull requests

3 participants