Unused variables in Fortran programs

Erik Schnetter schnetter@aei.mpg.de
Mon Jan 3 20:42:00 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 03 January 2005 21:24, Gordon Sande wrote:
> Erik Schnetter wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Is there a way to make gfortran not warn about certain unused
> > variables when -Wunused is used?  I am looking for the equivalent
> > of __attribute__((unused)) for some automatically generated parts
> > of Fortran code.
> >
> > Do you know how other Fortran compilers do this?  Do they maybe
> > offer some special comments, as in
> >
> >  integer i
> >  ! unused i
>
> You could always try
>
>    common / otherwise_unused_vars / i
>    integer i
>
> depending on how effective the checking is. A useful variant would be
> that if NO variable in the common is used then the common should get
> the citation for being unused. That would make this trick useless as
> it is just exploiting a flaw in the usage analysis.

There are two kinds of unused variables.  Some are already in common 
blocks (and there is a feature request to gfortran to not warn about 
these), but others are actually routine arguments, as in

 subroutine a(x, y)
   implicit none
   integer x
   integer y
 end subroutine a

where the list of arguments is partly automatically generated (through 
cpp macros), and where some of the variables may not be used.  I would 
like to avoid only those warnings about those arguments that are 
automatically generated.

- -erik

- -- 
Erik Schnetter <schnetter@aei.mpg.de>   http://www.aei.mpg.de/~eschnett/

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFB2a38m3uiSwno3f0RAqmZAJ4j2SVcuoyX0fFKnkSW1WKprkS8xACgyV2v
aVlFHbVDvzPCgINGmvfXSII=
=PKL0
-----END PGP SIGNATURE-----



More information about the Fortran mailing list