Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress unused variable warning

What is the best practice in Fortran to suppress warning messages like:

remark #7712: This variable has not been used.

for just one particular variable (imagine function in API that we do not want to break)?

Note: I do not want to suppress all warnings for a file

Note2: Something similar for gcc: __attribute__((__unused__)) or other common C practice with MACRO

Note3: I am particularly interested in ifort, but multi-compiler would be better.

like image 279
Peter Avatar asked Jul 02 '14 10:07

Peter


1 Answers

Since you're using Intel Fortran (I can tell from the particular message), you have a couple of options. One is to add a dummy reference, for example:

if (.false.) unused=1

Another is to disable just unused variable warnings:

/warn:all,nounused

or for Linux:

-warn all,nounused

Microsoft Fortran had an interesting library function UNUSEDQQ for this purpose - you added a call to UNUSEDQQ passing the variable, and this disabled the check. Intel Fortran doesn't support that.

like image 89
Steve Lionel Avatar answered Sep 30 '22 04:09

Steve Lionel