Silo
Silo copied to clipboard
Handle bare DB_F77NULL pointers correctly from Fortran callers
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