Good practice dictates that subroutine arguments in Fortran should each have a specified intent (i.e. intent(in)
, intent(out)
or intent(inout)
as described this question):
subroutine bar (a, b)
real, intent(in) :: a
real, intent(inout) :: b
b = b + a
...
However, not specifying an intent is valid Fortran:
subroutine bar (a, b)
real, intent(in) :: a
real :: b
b = b + a
...
Are there any real differences beyond compile time checking for an argument specified as intent(inout)
and an argument without a specified intent? Is there anything I should worry about if I'm retrofitting intents to older, intent free, code?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…