10.1.5. Passing Null Pointers

Up: Contents Next: Duplicating Multiple Vectors Previous: Calling Fortran Routines from C (and C Routines from Fortran)

In several PETSc C functions, one has the option of passing a 0 (null) argument (for example, the fifth argument of MatCreateSeqAIJ()). From Fortran, users must pass PETSC_NULL_XXX to indicate a null argument (where XXX is INTEGER, DOUBLE, CHARACTER, or SCALAR depending on the type of argument required); passing 0 from Fortran will crash the code. Note that the C convention of passing PETSC_NULL (or 0) cannot be used. For example, when no options prefix is desired in the routine OptionsGetInt(), one must use the following command in Fortran:

    call OptionsGetInt(PETSC_NULL_CHARACTER,'-name',N,flg,ierr) 
This Fortran requirement is inconsistent with C, where the user can employ PETSC_NULL for all null arguments.


Up: Contents Next: Duplicating Multiple Vectors Previous: Calling Fortran Routines from C (and C Routines from Fortran)