The line number given in warning messages for unused variables in a procedure with an internal procedure, is that of the first line of the internal procedure, instead of the host procedure. I find this a bit confusing:
erik:~$ cat -n swap.f90 1 subroutine sort() 2 real :: a 3 4 contains 5 6 subroutine swap() 7 end subroutine swap 8 9 end subroutine sort erik:~$ gfortran -Wall -c swap.f90 swap.f90: In function 'sort': swap.f90:6: warning: unused variable 'a' (The optimal thing would of course be to give the line where the variable was declared, but since a variable can have several declarations (e.g. one for type and a separate one for dimension), this is not allways possible.) -- Summary: Missleading line number for 'unused variable' warnings Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: diagnostic Severity: minor Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: eedelman at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25693