Hello,
To illustrate, here 2 files :
- main.f90
program test
integer a,b
real(kind=4) r1
a = 1
b = 2
call sub1(a,b,1)
CALL sub2(a,b,1)
CALL sub3(r1)
! call sub1(a,b)
end
subroutine sub2(a,b)
integer, intent(in) :: a,b
print*,'a,b=',a,b
end subroutine sub2
subroutine sub3(a)
integer, intent(in) :: a
print*,'a=',a
end subroutine sub3
- sub1.f90
subroutine sub1(a,b)
integer, intent(in) :: a,b
print*,'a,b=',a,b
end subroutine sub1
- Compilation :
gfortran -Wall sub1.f90 main.f90
main.f90:13:22:
13 | CALL sub2(a,b,1)
| 1
Error: More actual than formal arguments in procedure call at (1)
main.f90:14:19:
14 | CALL sub3(r1)
| 1
Error: Type mismatch in argument āaā at (1); passed REAL(4) to INTEGER(4)
- Remark:
** arguments are checked inside the same file
** arguments are not checked when the subroutine is defined in another file
Do you know if there is an option (compilation flag or free external script) to get this check even if the subroutine is defined in another file ?