Motivated by a current thread, and extending some code in the Pure-Fortran project, I created using Codex
It handles not only scalar intent(out) arguments but array arguments where some values may not be set. For example, for the code
module m
implicit none
contains
subroutine sub(x,y1,y2,z,a,b)
real, intent(in) :: x
real, intent(out) :: y1, y2, z(3), a(:), b(:)
y1 = x
z(1) = x
if (size(a) > 0) a(1) = x
if (size(b) >= 2) b(1:2) = x
end subroutine sub
end module m
program main
use m
implicit none
real :: x = 10.0, y1, y2, z(3), a(4)
real, allocatable :: b(:)
allocate (b(2*3))
call sub(x, y1, y2, z, a, b)
print*,y1,y2
print*,z
print*,"a =", a
print*,"b =", b
end program main
python xintent.py xintent_out.f90 --warn-unset-intent-out says
Summary of 0 functions and 4 subroutines with declared intent(out) arguments not wholly set in 1 source file:
xintent_out.f90 subroutine sub:a [only element 1 may be set; other elements may be unset]
xintent_out.f90 subroutine sub:b [only section 1:2 may be set; other elements may be unset]
xintent_out.f90 subroutine sub:y2
xintent_out.f90 subroutine sub:z [indices 2:3 not set]
There are probably larger procedures for which it fails. (If you encounter one and want a fix, please create an issue in the repo.) Codex is good at creating static analysis tools in Python.