Если я объявил тип как
type test(NSIZE)
integer, len :: NSIZE
real :: dummy(NSIZE)
contains
procedure, pass(this) :: proc
end test
type(test(NSIZE=10)) :: test_type
, моя подпрограмма proc
будет PURE.Мой proc возвращает одно значение и не имеет побочных эффектов.
pure subroutine proc(this, n)
implicit none
class(test(NSIZE=*)), intent(inout) :: this
integer, intent(inout) :: n
n = n +1
end subroutine proc
Теперь внутри другой подпрограммы, также объявленной как PURE, я вызываю proc
pure subroutine test2
integer :: n
call test_type% proc(n)
end subroutine test2
Я получаю ошибку на call test% proc(n)
высказывание следующее:
error #7140: This global use associated object appears in a 'defining' context in a PURE procedure or in an internal procedure contained in a PURE procedure.
Автономный пример
module mod1
implicit none
type test (size)
integer, len :: size
real :: dum(size)
contains
procedure, pass(this) :: dum_proc
end type
type(test(size=10)) :: test1
contains
pure subroutine dum_proc(this, n )
implicit none
class(test(size=*)), intent(inout) :: this
integer, intent(out) :: n
n =n +2
end subroutine dum_proc
end module mod1
program SUPPORT
implicit none
integer :: n
n = 0
call caller(n)
contains
pure subroutine caller( nk )
use mod1, only : test1
implicit none
integer, intent(inout) :: nk
call test1% dum_proc(nk)
end subroutine
end program SUPPORT`