- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Call me lazy, but I love to rely on the compiler's warnings to help me write better code faster. One mistake I make occasionally is forgetting to check whether an optional dummy argument was present. I would really like ifort to tell me when any dummy argument's presence hasn't been checked within the procedure.
E.g. compiling this with -warn all should give a warning about "norm"...
[fortran]module testmod1 contains real function fn(a,b,norm) implicit none real, intent(in) :: a real, intent(in) :: b real, optional, intent(in) :: norm ! fn = a/norm + b end function fn end module program test use testmod1 print *, fn(1.2,3.14,200.1) end program[/fortran]
Is there some reason why this warning does not exist?
I hope this forum is an appropriate place to make suggestions like this.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see... Thanks for your answer.
Seems to me that if a procedure has an optional dummy foo and there is no present(foo) anywhere in the procedure, that would be a good enough reason to issue a warning, or at least an info.
I can't remember whether it was ifort or gfortran, but I'm pretty sure I've seen warnings from a -check uninit-like option (~ "this variable is used but may be uninitialized") which were sometimes wrong (perhaps because their rules were too simple), but they are still very useful..
In other words, isn't an info or warning message, if phrase appropriately ("may", "appears to be"), allowed to be wrong?
Doesn't your argument above apply equally to -check uninit?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We could add a run-time check which is what -check uninit does. But as I mentioned you're going to get an error anyway - a segfault. As I mentioned earlier, PRESENT is not the only way you can avoid referencing an omitted argument.
I will add a feature request on your behalf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page