Interoperability of optional arguments (TS 29113)

Procedures that have optional dummy arguments can interoperate with C functions. You can specify the OPTIONAL attribute for a dummy argument in a procedure interface that has the BIND(C) attribute.

With this feature, you can call Fortran procedures with optional dummy arguments from C. You can also call a C function, with a corresponding interoperable Fortran interface that has one or more optional dummy arguments, from Fortran.

For example, the following subroutine interface has one optional dummy argument arg:
INTERFACE
  SUBROUTINE sub(arg) BIND(C)
    USE, INTRINSIC :: ISO_C_BINDING
    INTEGER(C_INT), OPTIONAL :: arg
  END SUBROUTINE
END INTERFACE
Restriction: An interoperable dummy argument cannot have both the OPTIONAL and VALUE attributes.


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us