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

Handle bare DB_F77NULL pointers correctly from Fortran callers #256

Open
markcmiller86 opened this issue Apr 14, 2022 · 0 comments
Open

Comments

@markcmiller86
Copy link
Member

markcmiller86 commented Apr 14, 2022

In some cases in the Silo C library, a pointer can be NULL (or not) and an equality comparison to NULL is used to decide whether to write the associated data the pointer references. In other cases, an associated size or count integer argument signifies whether there is data to write from the pointer and the pointer is never compared with NULL to decide to issue the write.

From Fortran, the constant DB_F77NULL (which is integer value -99) is used to indicate pointer arguments that are NULL.

For any of those cases where the pointer is of the first kind described in the first paragraph, where it is compared with NULL to decide to write it references or not, in the Fortran wrapper code, silo_f.c, we need to compare the passed argument with DB_F77NULL and either pass NULL or pass the pointer given through to the C interface.

I've encountered a few cases where we don't handle this correctly and fear there are many other lurking that I haven't had time to go investigate.

We need to audit the Fortran wrapper code, silo_f.c and find and fix any other cases. The fix is to instead of just passing the pointer (say p) to the C function, we need to pass *p==DB_F77NULL?NULL:p

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

1 participant