J3/04-119 Date: 10 Dec. 2003 To: J3 From: Dan Nagle Subject: Enhanced IMPLICIT Statement Within a scoping unit, IMPLICIT statements set the rules for type declarations. However, "type" in Fortran is a two dimensional affair, with kind being the second dimension. Thus, some way of selecting the default kind is desirable. A way of setting the initial value of variables may also have some value, especially for older programs. Number: Title: Enhanced IMPLICIT Statement Submitted By: J3 Status: For Consideration References: Section 5.3 Basic Functionality: Enhance the IMPLICIT statement to set the default kind of variables and literals, and to set the initial value of saved variables not explicitly given one. Rationale: Specifying the type of a variable means specifying the type and the kind. Specifying the value of a literal means specifying the kind. Vendors recognize the value of user-selectable defaults; many compilers support options such as -r8, -r4, -i8, -i4 to do so. Providing the same functionality within the program would give greater portability and greater documentation of programmer intent. Also, some older programs rely on all variables having an initial value of zero. Many compilers ahve an option for setting this, too. The default initial value should apply only to variables given the SAVE attribute (one way or another). Again, it's better to have these assumptions included in the source code rather than spread around makefiles and compilation scripts. Note that while selecting the kinds of variables is not too hard (changing real*8 to real( mydouble) ), finding and changing literals is well nigh impossible for most programmers to do automatically (an editing script to find all . may well corrupt formats). Estimated Impact: Changing the compiler's defaults may have a considerable effect of compilers, so care must be taken when specifying how default kind is to be set. For example, it may be desirable to allow only one type to have its default kind set, other types follow suit (that is, a compiler may want to have only one numeric storage unit which perforce may be set only once). However, so many compilers have some means of setting these quantities that it must be do-able, and there must be customer demand for it. Detailed Specification: Enhance the IMPLICIT statement as follows: To set default kind: IMPLICIT : KIND( kind-value) [, ...] To set default initial value: IMPLICIT : VALUE( value) [, ...] A processor should be free to require at least consistency among the values (that is, it may require that all initial values will be the same bit pattern). The KIND and VALUE specifications should be allowed along with NONE, but I propose that they not be allowed with the initial letter specifications. Therefore, a type name followed by "(" indicates the initial letter, a type name followed by ":" indicates kind and/or value. Also, letters setting does not occur with NONE. Example: ! default real is double = 0.0 IMPLICIT NONE, & REAL: KIND( SELECTED_REAL_KIND( P= 15)), & VALUE( 0.0) History: