From: Arjen M. <Arj...@de...> - 2016-05-12 06:35:12
|
Hi Alan, NOTE: What follows is rather specific to the Fortran language and has little to do with PLplot as such, other than that has some consequences for our Fortran binding and possibly the examples. > -----Original Message----- > From: Alan W. Irwin [mailto:ir...@be...] > Sent: Wednesday, May 11, 2016 7:51 PM > To: Arjen Markus > Cc: Wadud Miah; plp...@li... > Subject: Re: Avoiding untyped variables in our Fortran binding and examples > > P.S. > > Hi Arjen: > > From > <https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for- > windows/topic/346554> > it appears that you should use the /check:uninit option with the ifort compiler to > detect undefined variables. > > I also see from <http://www.nag.com/nagware/np/r53_doc/nagfor.html> that that > compiler has a -C=undefined option to check for undefined variables. > > Note, I am not sure of the exact meaning of "undefined variable" in these two > references. My hope is it simply means "undefined type", i.e., implicit declaration, > but I am not sure. For example, some use the term "undefined variable" when they > really mean that a properly typed variable is uninitialized. And, of course, an > uninitialized variable is much more difficult to detect than an undefined type. > My intention is to add IMPLICIT NONE anywhere where this is required: - At the beginning of a module, but not in the contained routines, as they inherit that feature (the module provides the scope) - At the beginning of a subroutine or function statement inside an interface block, as the interface defines a new scope. These new scopes also make it necessary to import any names used inside the interface. See the problem Wadud reported. So, all in all, a number of IMPLICIT NONE statements and one or two imports have to be added, but they will not clutter then CONTAINS section. As for undefined variables: Fortran "standardese" distinguishes between declarations (affected by IMPLICIT statements) and definitions (variables having been assigned a value or not). Simply put: An undefined variable has no reliable value. This can occur in various contexts, but really is a run-time property. A variable that is not explicitly declared can be detected at compile-time. Most compilers have some option to detect that. Detecting undefinedness is much harder. Regards, Arjen DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail. |