fortranprocedurefortran2008

Can we Modify the accessibility of Type-bound Procedures in Fortran


MODULE MyTypeMod

TYPE MyType
PRIVATE
INTEGER, ALLOCATABLE :: Num
CONTAINS
  PROCEDURE, PUBLIC :: IsNum!To check Allocation of Num
  ...
END TYPE MyType

CONTAINS
...
END MODULE MyTypeMod
PROGRAM testMyType
USE MyTypeMod, ONLY : MyType

...
END PROGRAM testMyType

Here In this Module and Program, Can we modify accessibility status "IsNum" type-bound procedure? Can we make the "IsNum" procedure PRIVATE in just the testMyTypeMod PROGRAM?


Solution

  • According to paragraph 9 of section 7.5.5 of the Fortran 2018 draft standard

    A public type-bound procedure is accessible via any accessible object of the type. A private type-bound procedure is accessible only within the module containing the type definition, and within its descendants.

    And so changing the accessibility of a type-bound procedure is not possible.

    There is currently a proposal to update a future Fortran standard that suggests making a subset of what you want to do possible.

    You may want to make a new proposal to update the standard. This is also likely the best way to find out why what you want to do is not currently possible.