Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Local Variables Declaration and Initialization

$
0
0

This is a two part question.

  1. I been struggling to come up with a clear and concise way to handle the declaration of local variables. For reason I do not understand, any local variable given a value during its declaration is assumed to be SAVEd.In this case, I add the keyword “save” to make the declaration clear:

real(kind=dp), save :: climate = 0.0_dp

            so I assumed to declare a variable that is not SAVEd (to make it clear) I would use:

real(kind=dp), automatic :: temperature

I get the following message: warning #7410: Fortran 2008 does not allow this keyword. [AUTOMATIC].  Can someone explain this error and suggest another way to declare a variable as “not SAVEd”? I prefer not to depend on any compiler options. I have the warning for non-standard Fortran set for Fortran 2008.

  1. Does Fortran offer an easy way to initialize non-SAVEd variables everytime a subroutine or functions is called other than explicitly assigning a value at the start of the routine? For example, a keyword (in the source, not compiler) which would initialize all local variables to zero. Any other variables which needed a non-zero assignment could be added explicitly.The reason I ask is for large routines with many local variables the initialization section of the routine can be several pages long.Since this section is normally set once and ignored, it would be nice to find a way to minimize the amount of code required to initialize the local variables especially if the value to be set is zero.Any thoughts or suggestions would be welcome.

Local Variables Declaration and Initialization

  


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>