- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
Is there any way to disable the "unused variable" warning for one specific occurrence of an unused variable in ifort?
The reason why I am asking that is the following; I have several classes which implement, in a different way, an abstract function defined somewhere in a parent class, let us say, myfunc_abstract(a,b,c). However, some implementations use all the three variables, some use two of them only - and I cannot remove the dummy argument because the interface has to be the same as defined in the abstract interface declaration.
Honestly, I don't think the compiler should throw the "unused variable" warning in these situations; is there a compiler option or preprocessor trick to avoid that?
I am using ifort 12.1.5 20120612.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It does not really know that it is implementing a deferred procedure, and there's nothing preventing the routine from being called independently. However, we support an old Microsoft trick - a "do nothing" routine called UNUSEDQQ. So you could do something like:
use ifcore
...
if (.false.) call unusedqq(notused)
You have to do a USE IFCORE to make it visible. The if (.false.) will prevent the call from actually getting generated.
use ifcore
...
if (.false.) call unusedqq(notused)
You have to do a USE IFCORE to make it visible. The if (.false.) will prevent the call from actually getting generated.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The classic way is to put:
b = b
in the routime somewhere. The compiler would eventually optimize this away. How is the compiler supposed to know you didn't intend to use the dummy argument?
b = b
in the routime somewhere. The compiler would eventually optimize this away. How is the compiler supposed to know you didn't intend to use the dummy argument?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As it is an INTENT(IN) variable only I cannot really do that, but I surelly can do other spurious usages.
The compiler knows that this routine is implementing a deferred procedure for sure; as so, it should know that I am forced to let the dummy argument there, regardless if I use it or not.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It does not really know that it is implementing a deferred procedure, and there's nothing preventing the routine from being called independently. However, we support an old Microsoft trick - a "do nothing" routine called UNUSEDQQ. So you could do something like:
use ifcore
...
if (.false.) call unusedqq(notused)
You have to do a USE IFCORE to make it visible. The if (.false.) will prevent the call from actually getting generated.
use ifcore
...
if (.false.) call unusedqq(notused)
You have to do a USE IFCORE to make it visible. The if (.false.) will prevent the call from actually getting generated.

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