Ifort suppress unused variable warning, leave all

2019-06-27 18:53发布

i use ifort and gfortran to compile my Fortran program.

However i also use a coworkers source and he has got a lot of unused variables. How can i suppress these for the compile, seeing as they are not really an error?

However i dont want to disable -pedantic and -stan in the compiler options and thus want all the other warnings.

cheers and thanks for the help

2条回答
祖国的老花朵
2楼-- · 2019-06-27 19:24

Yes, as High Performance Mark pointed out, the best way to get rid of those warnings is to tell your coworker to fix his code.

As for easy solutions, with gfortran, have a look at the -Wunused-### options in gcc's manual: Warning Options. Notably, -Wno-unused-variable might do what you want.

[...] why the heck would you use gfortran when you have Intel Fortran ?

When developing, running your code through multiple compilers helps in finding bugs and producing portable code.

查看更多
放荡不羁爱自由
3楼-- · 2019-06-27 19:27

With ifort try -warn [no]unused.

And, while I'm here, I suggest you remove unused variables. The compiler may not regard them as an error, but disciplined software engineering regards all dead and unused code as erroneous; it imposes a maintenance burden.

查看更多
登录 后发表回答