This question is connected to the problem: how to detect violation of intent(in)
inside subprograms. But I haven't found the answer in the related question Enforce intent(in) declared variables in Fortran as constant also in called subroutines/functions.
A variable which is declared as intent(in)
can be modified by another subprogram/function with omitted intent declaration.
For example:
module test
implicit none
contains
subroutine fun1(x)
real(8), intent(in)::x
call fun2(x)
end subroutine
subroutine fun2(x)
real(8) :: x
x = 10
end subroutine
end module
This code can be compiled without any errors/warnings by gfortran and ifort. So my questions are:
- Is it possible to forbid omitting intent declaration?
- Is it possible to force a Fortran compiler to interpret omitted intent as
intent(inout)
?