pgfortran: Conflict between Modules with PRIVATE Interfaces

When two modules with the PRIVATE attribute define matching interfaces, pgfortran produces a severe error and terminates.

pgfortran 14.10-0 64-bit target on Apple OS/X -tp sandybridge

$ pgfortran -c iso_instrinsic.f90 
PGF90-S-0087-Non-constant expression where constant expression required (iso_instrinsic.f90: 21)
PGF90-S-0081-Illegal selector - KIND parameter has unknown value for data type  (iso_instrinsic.f90: 21)
  0 inform,   0 warnings,   2 severes, 0 fatal for n

The two modules, m and n, are identical except that n USES m. The error manifests itself as confusion over the definition of c_double from the ISO_C_BINDING module.

All other compilers in my arsenal correctly compile the following code:

module m
implicit none
private
	interface
		real(c_double) function frick(x) BIND(C)
		use, intrinsic :: iso_c_binding
		implicit none
		real(c_double), intent(in) :: x(*)
		end function
	end interface
end module

module n
use m
implicit none
private
	interface
		real(c_double) function frack(x) BIND(C)
		use, intrinsic :: iso_c_binding
		implicit none
		real(c_double), intent(in) :: x(*)
		end function
	end interface
end module

Adding “use, intrinsic :: iso_c_binding” at the module level in n makes the error go away, but that is just weird (and should be unnecessary).

Thanks.

Hi Tom,

We’re aware of this one. We have an internal debate on if the use iso_c_binding is necessary at the module level given the scoping of the function return type definition. In other words, if you declare “real(c_double) function” is the scope of where “c_double” is defined at the module level or the function level? Right now we have it defined at the module level but are in the process of relaxing this so that it’s the same as if you had declared the return type in the body of the interface.

   interface 
      function frack(x) BIND(C) 
      use, intrinsic :: iso_c_binding 
      implicit none 
      real(c_double) :: frack
      real(c_double), intent(in) :: x(*) 
      end function 
   end interface
  • Mat