Ifort 220.127.116.11 Build 20130514 gives the following warning:
warning #7937: The OPTIONAL attribute should not be used for arguments with the VALUE attribute.
when compiling this code:
module test_mod contains subroutine test_routine(iopt) integer, optional, value :: iopt if (present(iopt)) then print *, 'present' else print *, 'absent' endif end subroutine end module program test use test_mod call test_routine(iopt=1) call test_routine() end program
The executable does not give the expected result:
(the second time the routine is called, the argument is not present, therefore the present(iopt) should be .FALSE.)
This looks like a bug to me. If the standard says that we can't have OPTIONAL and VALUE together (I haven't checked), then ifort should throw an error, not a warning. If the standard does allow it, then the implementation is buggy. FWIW, NAGfor generates an executable with the expected behaviour.