GCC offers a deprecated attribute:
module a
contains
subroutine foo
!GCC$ ATTRIBUTES DEPRECATED :: FOO
print *, "Don't call me."
end subroutine
end module
use a, only: foo
call foo
end
that shows a message when compiled
/app/example.f90:10:8:
10 | call foo
| 1
Warning: Using subroutine 'foo' at (1) is deprecated [-Wdeprecated-declarations]
Compiler returned: 0
I never checked if other Fortran compilers also support this.