Let us consider a derived type which has a private method:
type c_t
integer i
contains
procedure, pass , private :: private_set
end type c_t
and an initialize method interfaced to c_t
interface c_t ! initializer
module function new_c_t ( i ) result ( u )
implicit none
integer, intent(in) , optional :: i
type (c_t) :: u
end function new_c_t
end interface c_t
Calling the method c_t%private_set from within the [interfaced to c_t] “new_c_t” :
call u%private_set( i )
compiles and gives expected result with gfortran/8.1/0 (and ifort18)
but does not compile with pgf90:
pgf90 constrp.f90
PGF90-S-0155-cannot access PRIVATE type bound procedure private_set$tbp (constrp.f90: 41)
0 inform, 0 warnings, 1 severes, 0 fatal for new_c_t
Is this compiler issue or just some default compilation option ?
The full code is pasted bellow:
= = = = = =
module m_t
type c_t
integer i
contains
procedure, pass , private :: private_set
end type c_t
interface c_t ! initializer
module function new_c_t ( i ) result ( u )
implicit none
integer, intent(in) , optional :: i
type (c_t) :: u
end function new_c_t
end interface c_t
interface ! the explicit interface to pass this to submodule
module subroutine private_set(this, i)
implicit none
class(c_t) :: this
integer , intent(in) :: i
end subroutine private_set
end interface
end module m_t
! implementations moved to submodule
submodule (m_t) sub_m_t
contains
module function new_c_t ( i ) result ( u)
implicit none
integer, intent(in) , optional :: i
type(c_t) :: u
u%i = -999 ! unassgn
! if(present(i)) call private_set( u, i) ! this works(expected)
if(present(i)) call u%private_set ( i ) !pgi19.9 ?;
end function new_c_t
module subroutine private_set(this, i)
implicit none
class(c_t) :: this
integer , intent(in) :: i
this%i = i
end subroutine private_set
end submodule sub_m_t
! main code
program main
use m_t
implicit none
type (c_t) c
c = c_t ( i = 10 )
print*,‘c%i=’, c%i
end program main