Ifort suppress unused variable warning, leave all others intact

两盒软妹~` 提交于 2020-01-14 12:58:08

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3870330/ifort-suppress-unused-variable-warning-leave-all-others-intact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!