From david@imagine1.com Tue Jul 11 09:16:58 1995
Received: from kitsune.swcp.com (swcp.com) by dkuug.dk with SMTP id AA27247
  (5.65c8/IDA-1.4.4j for <sc22wg5@dkuug.dk>); Tue, 11 Jul 1995 23:17:19 +0200
Received: from ppp45.swcp.com (ppp45.swcp.com [198.59.115.155]) by kitsune.swcp.com (8.6.9/8.6.9) with SMTP id PAA11835 for <sc22wg5@dkuug.dk>; Tue, 11 Jul 1995 15:16:58 -0600
Date: Tue, 11 Jul 1995 15:16:58 -0600
Message-Id: <199507112116.PAA11835@kitsune.swcp.com>
X-Sender: evt@swcp.com
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=====================_805496652==_"
To: sc22wg5@dkuug.dk
From: david@imagine1.com (David L. Epstein)
Subject: CCF (The Conditional Compilation Facility)
X-Mailer: <PC Eudora Version 1.4>
X-Attachments: C:\DE\X3J3\CCF\CCFWG5;
X-Charset: ASCII
X-Char-Esc: 29


--=====================_805496652==_
Content-Type: text/plain; charset="us-ascii"




--=====================_805496652==_
Content-Type: text/plain; charset="us-ascii"


Hello World,

The following has also been sent to X3J3.

David Epstein

-----------------------------------------------------------------------
To:      X3J3
From:    David Epstein
	 with appreciation to Jeanne Martin
Subject: CCF Proposed Technical Report Type 2

Conditional compilation is a programming language feature which permits
selected blocks of code to be ignored (treated as comments) by the 
programming language processor.  There are many uses for conditional 
compilation including writing code that is portable across machines, 
operating systems, different versions of processors, and different 
versions of a programming language (for example FORTRAN 77, Fortran 90, 
HPF, Fortran 2015, etc.)

Less talked about uses of conditional compilation include debugging, 
profiling or timing (for example, calls to CPU_TIME), commenting (for 
example, replacing the high maintenance of starting each line of a 
large comment with a '!' character with the use of a single 
if-construct), and testing.  As a conditional compilation language is a 
language, it is limiting to suggest that there are a finite number of 
applications for conditional compilation.

Considering only the single most popular benefit of conditional 
compilation -- portability -- warrants creating a standard Fortran 
conditional compilation language.  Until there is a standard conditional 
compilation language in Fortran, those seeking both standard Fortran
language and portability must search outside of Fortran for answers.
It is truly ironic that in the previous sentence the words "standard 
Fortran language" and "portability" have different definitions since a 
purpose of the Fortran standard is to promote portability.

One solution for FORTRAN 77 programmers has been to pick a "standard" 
conditional compilation feature from another programming language.  
Particularly popular (and available) is the conditional compilation 
features of cpp, the C preprocessor.  Although workable, this solution
has proven costly as both C and FORTRAN have evolved without a high 
priority placed on the use of cpp with FORTRAN.  A result is that the 
list of guidelines for safely mixing cpp and FORTRAN is constantly 
changing.  A similar argument can be made with other solutions as the 
evolving definition of Fortran does not take into account the 
definitions of other conditional compilation tools such as Mortran, M4, 
fpp, etc.

With the recent investments made to improve FORTRAN 77 into Fortran 90 
(as well as Fortran 95, HPF, and beyond) it is time to offer the 
Fortran programmer the opportunity to program in Fortran.

What follows is a proposed Conditional Compilation Facility (CCF) for 
Fortran.  Interested readers may reference paper X3J3/93-276, paper 
X3J3/95-167, and three articles about CCF in the Fortran Journal 
(94 May/June, 94 Sept/Oct, 95 Jan/Feb).

------------------------------------------------------------------------

Dear CCF Proposed Technical Report Type 2 Reader,

Here is the quick overview.

If you are viewing CCF for the first time, you may notice how similar it
is to Fortran.  This is by design.  Quite simply, the seed of the CCF 
definition was planted by selecting a syntax for the CCF if-construct.

Choosing the if-construct as the desired method for the "conditional" 
part of conditional compilation is the first step and choosing the 
syntax for this if-construct is the second step.  Using a syntax other 
than a subset of Fortran feels relatively complex and not logical.

If, on the other hand, you are familiar with CCF and the nine CCF 
statements (INTEGER, LOGICAL, assignment, IF, ELSEIF, ELSE, ENDIF, 
PRINT, and STOP) there has been one major improvement -- the addition 
of CCF modules.  By adding three CCF statements (MODULE, USE, and 
ENDMODULE), the requirement of "redundant textual specification" 
(C.11.2) in order to declare a group of shared CCF variables has been 
replaced with modules, a more modern Fortran feature.

Related to the addition of CCF modules is the concept of multiple CCF 
program-units.  No longer is there a required emphasis on the "input
source file" -- a term not needed or used in Fortran.  Previously, the
freedom to combine and separate Fortran program-units was hampered by 
the default CCF program scope (the input file).  Instead, CCF 
program-units are separated either by CCF modules of by following a CCF-
executable-construct with a CCF-use-stmt or a CCF-type-declaration-stmt.

Finally, a slight CCF improvement is made with the addition of the 
PARAMETER attibute for CCF variables (as introduced in paper X3J3/93-276).


+++ NOTATION +++
This CCF Proposed Technical Report Type 2 
places all of CCF into a new section -- section 15.  Taking
advantage of the CCF design to be a subset of Fortran has aided this
document as relative sections of the Fortran 95 draft were copied and
modified appropriately so as to describe their CCF counterpart.  

A comparison can be done by removing the "15." from the front of all the
CCF sections (except, of course, 15.15 :)).  For example, section 15.3.3
corresponds to section 3.3 of the Fortran draft.

Also, syntax rules can be compared by removing the letter 'C'.  For 
example, RC504 corresponds to R504.

Slight modifications to sections 1 through 14 of the Fortran 95 draft
are saved until a more appropriate moment.
+++ ENDNOTATION +++

Enjoy,
David Epstein
+1-503-383-4846

------------------------------------------------------------------------

Section 15:  The Conditional Compilation Facility 

	15.1   CCF Overview

	15.1.1  Conditional Compilation

The Conditional Compilation Facility (CCF) for Fortran consists of twelve CCF  
statements which supplies the Fortran programmer the needed tools to acheive 
conditional compilation.  Conditional compilation is a feature which permits
blocks of source to be ignored by a processor based on certain conditions.

	15.2   CCF terms and concepts

	15.2.1  High level syntax

This section introduces the terms associated with CCF program units and other 
CCF concepts above the construct, statement, and expression levels and 
illustrates their relationships.  

RC201    CCF-program is      CCF-program-unit

			    [ CCF-program-unit ] ...

A CCF-program shall contain exactly one CCF-complete-program program-unit.

RC202    CCF-program-unit    is      CCF-complete-program

			     or      CCF-module

RC1101   CCF-complete-program    is      [ CCF-specification-part ]

					 [ CCF-executable-construct ] ...

A CCF-complete-program shall contain at least one CCF statement.

RC1104   CCF-module  is      CCF-module-stmt

			     [ CCF-specification-part ]

			     CCF-end-module-stmt

RC204    CCF-specification-part      is      [ CCF-use-stmt ] ...

					     [ CCF-type-decl-stmt ] ...

RC215    CCF-executable-construct    is      CCF-action-stmt

				     or      CCF-if-construct

RC216    CCF-action-stmt     is      CCF-assignment-stmt

			     or      CCF-print-stmt

			     or      CCF-stop-stmt

	15.2.2  CCF program unit concepts

CCF program units are the fundamental components of a CCF program.  A CCF 
program unit may be a CCF complete program, or a CCF module.  A CCF module 
contains definitions that are to be made accessible to other CCF program 
units.  Both types of CCF program units are described in Section 15.11.

	15.2.2.1  CCF program

A CCF program consists of exactly one CCF complete program unit and any number 
(including zero) of CCF module program units.  The set of CCF program units 
may include any combination of the two kinds of CCF program units in any order 
as long as there is only one CCF complete program unit. 

Since a CCF module is required to be available by the time a CCF module 
reference (15.11.3.1) is processed, a processor may require a specific order 
of processing of the CCF program units. 

	15.2.2.2  CCF complete program

The CCF complete program is described in 15.11.1.

	15.2.2.4  CCF module

A CCF module contains (or accesses from other CCF modules) definitions that are 
to be made accessible to other CCF program units.  These definitions are CCF 
data object declarations.  The purpose of a CCF module is to make the 
definitions it contains accessible to all other CCF program units in a CCF 
program that request such accessibility.  CCF modules are further described 
in 15.11. 


Table 15.2.1   Requirements on CCF statement ordering

      -----------------------------------
     |  CCF MODULE statement             |
      -----------------------------------
     |  CCF USE statements               |
      -----------------------------------
     |  CCF type declaration statements  |
      -----------------------------------
     |  CCF executable constructs        |
      -----------------------------------
     |  CCF ENDMODULE statement          |
      -----------------------------------

	15.2.3.2  CCF statement order

The syntax rules of Section 15.2.1 specify the CCF statement order within CCF 
program units. These rules are illustrated in Table 15.2.1 and Table 15.2.2.
Table 15.2.1 shows the ordering rules for CCF statements and applies to all 
CCF program units.  CCF USE statements, if any, shall appear before CCF
type declaration statements, if any.  CCF type declaration statements, if any, 
shall appear before CCF executable constructs, if any.  Table 15.2.2 shows 
which CCF statements are allowed in a CCF program unit. 

Table 15.2.2   CCF statements allowed in CCF program units

 Kind of CCF program unit:             CCF Complete       CCF Module
				       Program

   CCF USE Statement                     Yes                 Yes
   CCF Type Declaration Statement        Yes                 Yes
   CCF Executable Construct              Yes                 No

	15.3   CCF lexical tokens, and source form

This section lists some of the various CCF lexical tokens and describes the 
rules for the form that CCF programs may take.

	15.3.2.2  CCF constants

RC305    CCF-constant        is      CCF-literal-constant

			     or      CCF-named-constant

RC306    CCF-literal-constant        is      CCF-int-literal-constant

				     or      CCF-logical-literal-constant

RC307    CCF-named-constant  is      name

	15.3.2.4  CCF statement start

RC314    CCF-stmt-start      is      !CCF$

Constraint:     The characters "!CCF$" shall be in character positions 1 to 5 
of the source line.

	15.3.3  CCF source form

A CCF program unit is a sequence of one or more lines, organized as CCF 
statements, and CCF comments.  A CCF statement is a sequence of one or more 
complete or partial lines.  A line is a sequence of zero or more characters.

A CCF character context means characters within a CCF character literal 
constant (RC420).

A CCF comment may contain any character that may occur in any CCF character 
context.

In CCF source form, each source line may contain from zero to 132 characters 
and there are restrictions on where a CCF statement (or portion of a CCF 
statement) may appear within a line.  However, if a line contains any 
character that is not of default kind (4.3.2.1), the number of characters 
allowed on the line is processor dependent. 

In CCF source form, blank characters shall not appear within CCF lexical tokens
other than in a CCF character context.  Blanks may be inserted freely between 
CCF tokens to improve readability.  A sequence of blank characters outside of a 
CCF character context is equivalent to a single blank character. 

A blank shall be used to separate CCF names, or CCF constants from adjacent 
keywords, CCF names, or CCF constants.

	15.3.3.1.1  CCF commentary

A line that is not a CCF statement or a partial CCF statement is called a CCF 
comment line.  Within a CCF statement, the character "!" in any character 
position other than character position 1 initiates a CCF comment except when 
it appears within a CCF character context.  The comment extends to the end of 
the source line.  If the first nonblank character on a line after character 
position 5 is an "!", the line is also a CCF comment line.  Lines containing 
only blanks after character position 5 or containing no characters after 
character position 5 are also CCF comment lines.  CCF comments may appear 
anywhere in a CCF program unit and may precede the first CCF statement of a 
CCF program unit.  

NOTE TO REVIEWER:  The below sentence from the Fortran standard is removed
since CCF comments of the form '!CCF> ...' or '!CCF* ...' are recognized as
lines that were previously commented by CCF.
F95: "Comments have no effect on the interpretation of the program unit."
ENDNOTE TO REVIEWER

 Note 15.3.1
 Examples of CCF comment lines are:

 gender = GetRabbitGender(a_rabbit) ! a Fortran statement?
 ! a Fortran comment
 !CCF$ ! set "system" to "system_A"
 !CCF>     OPEN(UNIT=6, FILE='system.dependent.name')
 !CCF*     OPEN(UNIT=6, FILE='sysdpnt.nam')
 ENDNote 15.3.1

	15.3.3.1.3  CCF statement continuation

The character "&" is used to indicate that the current CCF statement is 
continued on the next line that is not a CCF comment line.  CCF comment lines 
shall not be continued; an "&" in a CCF comment has no effect.  Comments may 
occur within a continued CCF statement.  When used for continuation, the "&" 
is not part of the CCF statement.  No line shall contain a single "&" as the 
only nonblank character after character position 5 in a CCF-non-comment 
line or as the only nonblank character before an "!". 

	15.3.3.1.3.1  CCF-non-character context continuation

If an "&" not in a CCF comment is the last nonblank character on a line or the 
last nonblank character before an "!", the CCF statement is continued on the 
next line that is not a CCF comment line.  If the first nonblank character 
after character position 5 on the next CCF-non-comment line is an "&", the 
CCF statement continues at the next character following the "&"; otherwise, 
it continues with the first character position after character position 5
of the next CCF-non-comment line. 

If a CCF lexical token is split across the end of a line, the first nonblank 
character after character position 5 on the first following CCF-non-comment 
line shall be an "&" immediately followed by the successive characters of the 
split token. 

 Note 15.3.2
 An example of CCF-non-character context continuation is:

 !CCF$ LOGICAL :: too_good&
 !CCF$&_to_be_&
 !CCF$&true =             &
 !CCF$           .FALSE.     ! These four lines contain 1 CCF statement
 ENDNote 15.3.2

3.3.1.3.2  CCF character context continuation

If a CCF character context is to be continued, the "&" shall be the last 
nonblank character on the line and shall not be followed by CCF commentary.  
An "&" shall be the first nonblank character after character position 5 on the 
next line that is not a CCF comment line and the CCF statement continues with 
the next character following the "&". 

 Note 15.3.3
 An example of CCF character context continuation is:

 !CCF$ print *, 'de&
 !CCF$             &f&
 !CCF$              &inately choosing Fortran' ! 3 lines - 1 CCF statement
 ENDNote 15.3.3

	15.3.3.1.4  CCF statements

A CCF statement shall contain the characters "!CCF$" in character 
positions 1 through 5.  

A CCF statement shall not have more than 39 continuation lines.

 Note 15.3.4
 Examples of CCF statements are:

 !CCF$ INTEGER, PARAMETER :: system_A = 1
 !CCF$   IF (.FALSE.) THEN
 !CCF$ MODULE CCF_system_variables
 ENDNote 15.3.4

	15.4.3.1.1  CCF integer type

RC404    CCF-int-literal-constant    is      digit-string

	15.4.3.2.1  CCF character type

RC420    CCF-char-literal-constant   is      ' [ rep-char ] ...  '

				     or      " [ rep-char ] ...  "

	15.4.3.2.2  CCF logical type

RC421    CCF-logical-literal-constant        is      .TRUE.

					     or      .FALSE. 

	15.5.1   CCF type declaration statements

RC501    CCF-type-declaration-stmt   is      

     CCF-stmt-start CCF-type-spec [ [ , PARAMETER ] :: ] CCF-entity-decl-list 

RC502    CCF-type-spec       is      INTEGER

			     or      LOGICAL

RC504    CCF-entity-decl     is      object-name [ CCF-initialization ] 

RC505    CCF-initialization  is      = CCF-initialization-expr

 Note 15.5.1
 Examples of CCF type declaration statements are:

 !CCF$ integer, parameter :: F77 = 1, F90 = 2, F95 = 3
 !CCF$ integer :: fortran_level = F90
 !CCF$ logical :: debug_procedure_entry_exit
 ENDNote 15.5.1


	15.6   CCF variables

RC601    CCF-variable        is      CCF-scalar-variable-name

Constraint:     CCF-scalar-variable-name shall not have the PARAMETER attribute.

Constraint:     CCF-scalar-variable-name shall appear as an object-name in
a CCF-type-declaration-stmt before appearing elsewhere in a CCF program unit.

NOTE TO REVIEWER:  The above constraint is a way to state "no implicit
declarations".
ENDNOTE TO REVIEWER

	15.7.1.1.1  CCF primary

RC701    CCF-primary is      CCF-constant

		     or      CCF-variable

		     or      ( CCF-expr )

Constraint: A CCF-variable shall be defined (15.14.7.5) before appearing 
as a CCF-primary.

	15.7.1.1.3  Level-2 expressions

RC706    CCF-add-operand     is  [ CCF-add-operand mult-op ] primary

RC707    CCF-level-2-expr    is  [ [ CCF-level-2-expr ] add-op ] CCF-add-operand

	15.7.1.1.5  Level-4 expressions

RC713    CCF-level-4-expr    is  [ CCF-level-2-expr rel-op ] CCF-level-2-expr

	15.7.1.1.6  Level-5 expressions

RC715    CCF-and-operand     is  [ not-op ] CCF-level-4-expr

RC716    CCF-or-operand      is  [ CCF-or-operand and-op ] CCF-and-operand

RC717    CCF-equiv-operand   is  [ CCF-equiv-operand or-op ] CCF-or-operand

RC718    CCF-level-5-expr    is  [ CCF-level-5-expr equiv-op ] CCF-equiv-operand

	15.7.1.1.7  General form of a CCF expression

RC723    CCF-expr    is      CCF-level-5-expr

	15.7.1.4  Data type of a CCF expression

The data type of a CCF expression depends on the operators and on the data 
types of the CCF primaries used in the expression, and are determined 
recursively from the syntactic form of the expression.  The data type of a CCF 
expression is either Integer or Logical.

RC725    CCF-logical-expr    is     CCF-expr

Constraint:     CCF-logical-expr shall be type logical.

 NOTE TO REVIEWER: The term "CCF-integer-expr" is not defined here as it is
 not used in the BNF rules (which I suppose is the reason that real-expr and
 complex-expr is not defined in section 7.1.4 of the Fortran 95 draft).
 END NOTE TO REVIEWER:

	15.7.1.6.1  CCF constant expression

RC730    CCF-initialization-expr     is      CCF-expr

Constraint:     A CCF-initialization-expr shall be an initialization expression.

	15.7.5.1  CCF assignment statement

A CCF variable may be defined or redefined by execution of a CCF assignment 
statement.

RC735    CCF-assignment-stmt is      CCF-stmt-start CCF-variable = CCF-expr

where CCF-variable is defined in RC601 and CCF-expr is defined in RC723.

In a CCF assignment statement, the types of CCF-variable and CCF-expr shall 
either both be integer or both be logical.

 Note 15.7.1
 Examples of CCF assignment statements are:

 !CCF$ debug_level = debug_level + 1
 !CCF$ is_company_x_machine = (system == sysE) .OR. (system = sysF)
 !CCF$    project_level = foo_version + latest_release
 ENDNote 15.7.1

	15.8  CCF execution control and conditional compilation

The execution sequence may be controlled by CCF if constructs containing CCF 
blocks and by a CCF stop statement.  Conditional compilation is controlled by 
CCF if constructs.

 Note 15.8.1
 A CCF program is not required to contain any CCF if constructs or CCF stop
 statements.  Execution of such a CCF program has no effect other than output
 if the CCF program contains any CCF print statements.
 END Note 15.8.1

	15.8.1  CCF blocks

A CCF block is a sequence of CCF executable constructs that are treated as a 
unit.

RC801    CCF-block   is      [ CCF-execution-construct ] ...

CCF executable constructs may be used to control which CCF blocks of a CCF 
program are executed.  

A CCF statement belongs to the innermost CCF if construct in which it appears.

	15.8.1.1.3  Execution of a CCF block

Execution of a CCF block begins with the execution of the first CCF executable 
construct in the CCF block.  The execution of the CCF block is completed when
the last CCF executable construct in the sequence is executed.

	15.8.1.2  CCF IF construct

The CCF IF construct selects for execution no more than one of its constituent 
CCF blocks.  This CCF block is called the CCF TRUE block.  The remainder of
the CCF blocks in a CCF IF construct, if any, are selected to be ignored by
the processor (treated as if they are comments).  These CCF blocks are called 
CCF FALSE blocks.

	15.8.1.2.1  Form of the CCF IF construct

RC802    CCF-if-construct    is      CCF-if-then-stmt

					    CCF-block

				     [ CCF-else-if-stmt

					    CCF-block ] ...

				     [ CCF-else-stmt

					    CCF-block ]

				     CCF-end-if-stmt

RC803    CCF-if-then-stmt    is    

	       CCF-stmt-start IF ( CCF-scalar-logical-expr ) THEN

RC804    CCF-else-if-stmt    is    

	       CCF-stmt-start ELSE IF ( CCF-scalar-logical-expr ) THEN 

RC805    CCF-else-stmt       is    CCF-stmt-start ELSE 

RC806    CCF-end-if-stmt     is    CCF-stmt-start END IF

 Note 15.8.2
 An example of two CCF if constructs (one nested within the other) is:

 !CCF$ if (is_company_x_machine) then 
 !CCF$  if (fortran_level == F95) then
	 pure function GetRabbitWeight(a_rabbit) result(weight)
	  type (rabbit), intent(in) :: a_rabbit
 !CCF$  elseif (fortran_level == F90) THEN
	 function GetRabbitWeight(a_rabbit) result(weight)
	  type (rabbit) :: a_rabbit
 !CCF$  else 
 !CCF$   STOP 'We do not have a FORTRAN 77 product from company X'
 !CCF$  endif ! (fortran_level == ...
 !CCF$ else
	 function GetRabbitWeight() result(weight)
	  ! Only have Fortran 90 derived types with company X, so
	  ! return a weight of 1 for now
 !CCF$ endif ! (is_company_x_machine)  
 ENDNote 15.8.2

	15.8.1.2.2  Execution of an IF construct

At most one of the CCF blocks in the CCF IF construct is executed.  If there 
is a CCF ELSE statement in the construct, exactly one of the CCF blocks in the 
construct will be executed.  The CCF scalar logical expressions are evaluated 
in the order of their appearance in the construct until a true value is found 
or a CCF ELSE statement or CCF END IF statement is encountered.  If a true 
value or a CCF ELSE statement is found, the CCF block immediately following is 
executed and this completes the execution of the construct.  The CCF scalar 
logical expressions in any remaining CCF ELSE IF statements of the CCF IF 
construct are not evaluated.  If none of the evaluated expressions is true and 
there is no CCF ELSE statement, the execution of the construct is completed 
without the execution of any CCF block within the construct. 

Execution of a CCF END IF statement has no effect. 

	15.8.1.2.C3  Execution of a CCF TRUE block

Source lines contained in a CCF TRUE block are selected as possible Fortran
statements for the processor and are handled according to the rules 
in 15.15.

	15.8.1.2.C4  Execution of a CCF FALSE block

Source lines contained in a CCF FALSE block are selected as comment lines
for the processor and are handled according to the rules in 15.15.

	15.8.4  CCF STOP statement

RC840    CCF-stop-stmt       is      CCF-stmt-start STOP [ stop-code ]

Execution of a CCF STOP statement causes termination of execution of the 
CCF program.  At the time of termination, the stop code, if any, is available 
in a processor-dependent manner.  Leading zero digits in the stop code are not
significant.

Whether or not a processor continues processing source lines after the
execution of a CCF STOP statement is processor defined.

 NOTE TO REVIEWER: The purpose of the CCF STOP statement is to handle CCF
 error conditions.  Other uses (such as removing the bottom section of the
 source text) is discouraged by not specifying any more than what is stated
 above.
 END NOTE TO REVIEWER:

 Note 15.8.3
 Examples of CCF stop statements are:

 !CCF$ STOP 47
 !CCF$ STOP 'system shall be set to "sys1" or "sys2"'
 ENDNote 15.8.3

	15.9.4  CCF data transfer output statement

The CCF PRINT statement is the CCF data transfer output statement.

RC911    CCF-print-stmt   is  CCF-stmt-start PRINT *  [ , CCF-output-item-list ]

	15.9.4.2  CCF data transfer output list

A CCF output list specifies the entities whose values are transferred by a CCF
data transfer output statement. 

RC915    CCF-output-item     is      CCF-expr

			     or      CCF-char-literal-constant

Section 15.11  CCF program units

The terms and basic concepts of CCF program units were introduced in 15.2.2.  
A CCF program unit is a CCF complete program, or a CCF module.

This section describes both of these CCF program units. 

	15.11.1  CCF complete program

A CCF complete program is a CCF program unit that does not contain a 
CCF MODULE statement as its first statement. 

RC1101   CCF-complete-program    is      [ CCF-specification-part ]

					 [ CCF-executable-construct ] ...

A CCF-complete-program shall contain at least one CCF statement.

 Note 15.11.1
 A processor may limit its support of the number of CCF complete programs
 allowed in source text as long this number is at least one.
 ENDNote 15.11.1

 NOTE TO REVIEWER: The term "source text" is used elsewhere in the standard
 (only in the section about the INCLUDE line in Section 3).
 END NOTE TO REVIEWER:

	15.11.1.2  CCF complete program executable part

The sequence of CCF-executable-construct statements specifies the actions of 
the CCF complete program during CCF program execution.  Execution of a CCF 
program begins with the first executable construct of the CCF complete program. 

Execution of a CCF program ends with execution of the final CCF statement of 
the CCF complete program or with execution of a CCF STOP statement in the CCF 
program. 

	15.11.3  CCF modules

A CCF module contains specifications that are to be accessible to 
other CCF program units. 

RC1104   CCF-module  is      CCF-module-stmt

			     [ CCF-specification-part ]

			     CCF-end-module-stmt

RC1105   CCF-module-stmt     is    CCF-stmt-start MODULE CCF-module-name
				
RC1106   CCF-end-module-stmt is 

		       CCF-stmt-start END [ MODULE [ CCF-module-name ] ]

Constraint:     If the CCF-module-name is specified in the CCF-end-module-stmt, 
it shall be identical to the CCF-module-name specified in the CCF-module-stmt. 

The CCF module name is global to the CCF program, and shall not be the same as 
the name of any other CCF program unit, nor be the same as any local name in 
the CCF module. 

	15.11.3.1  CCF module reference

A CCF USE statement specifying a CCF module name is a CCF module reference.  At 
the time a CCF module reference is processed, the specified CCF module shall 
be available.  A CCF module shall not reference itself, either directly or 
indirectly. 

	15.11.3.2  The CCF USE statement 

The CCF USE statement provides the means by which a CCF program unit accesses 
named data objects in a module.  The accessed entities have the attributes 
specified in the CCF module. 

RC1107   CCF-use-stmt        is      CCF-stmt-start USE module-name

The CCF USE statement provides access to all entities in the specified CCF 
module. 

At most one CCF USE statement for a given CCF module shall appear in a 
CCF program unit.  

Two or more accessible entities may have the same name only if the name is not
used to refer to an entity in the CCF program unit.  The local name of any 
entity given accessibility by a CCF USE statement shall differ from the local 
names of all other entities accessible to the CCF program unit through CCF USE 
statements and otherwise. 

The local name of an entity made accessible by a CCF USE statement may appear in 
no other CCF type declaration statement that would cause the PARAMETER 
attribute (15.5.1.2) of the entity to be respecified in the CCF program unit 
that contains the CCF USE statement.

	15.14  CCF scope, and CCF variable definition

	15.14.1  Scope of CCF variables

CCF variables have the scope of the CCF program in which they
are declared or are made accessible by a CCF USE statement.

	15.14.7.5  Events that cause CCF variables to become defined

CCF variables become defined as follows:

(1)     Execution of a CCF assignment statement
causes the CCF variable that precedes the equals to become defined.  

(2)     Execution of a CCF initialization in a CCF type declaration statement
causes the CCF variable that precedes the equals to become defined.  

(3)     Execution of the CCF-set-option (15.15.2.2) causes the CCF variable to 
become defined.

	15.15  The CCF program, CCF options, and the CCF file

	15.15.1  The CCF program

	15.15.1.1  A conforming CCF program

A CCF program shall contain CCF statements that abide by the syntax and 
semantics rules previously described in this section (15.1 through 15.14).
A processor shall accept CCF programs, CCF options (15.15.2), and be capable 
of creating the CCF file (15.15.3).

	15.15.1.2  A nonconforming CCF program

A processor shall have a mechanism to report a nonconforming CCF program
(erroneous CCF syntax or erroneous CCF semantics).  In the case of a 
nonconforming CCF program, it is processor dependent whether or not the 
processor will recover and continue with the CCF program, ignore the rest of 
the CCF program and continue processing the Fortran source, or cease 
processing completely.
	
	15.15.2  CCF options

There are three CCF options - the CCF-on-option, the CCF-set-option, and the 
CCF-file-option.  A processor shall supply at least one method of recognizing 
CCF options separate from the CCF program.  For example, the invocation line 
may be the chosen method of communicating CCF options to the processor.

 Note 15.15.1 
A second example would be a CCF input file which could supply all the
values for the desired CCF options.
 ENDNote 15.15.1

	15.15.2.1  The CCF ON option
	
The CCF-on-option is a method to specify whether or not the processor
is to recognize CCF programs.

 Note 15.15.2
 Since it may be desirable to apply conditional compilation only
 for certain situations, the Fortran programmer is able to specify when
 the CCF program is recognized by using the CCF-on-option.  For example, the
 CCF program may only be recognized when moving a source program from one
 operating system to another operating system or when starting or ending 
 debugging sessions.
 ENDNote 15.15.2

	15.15.2.2  The CCF SET option

The CCF-set-option is a method of either assigning an initial value to a CCF 
variable (RC601) or overriding the initial value assigned to a CCF variable 
in a CCF initialization expression (RC730) without editing the CCF program.

 Note 15.15.3
 Recall that a CCF variable shall not have the PARAMETER attribute.
 ENDNote 15.15.3

The CCF-set-option minimally consists of a CCF-set-option-variable and a
CCF-set-option-literal-constant.  A processor may supply additional 
representations for the CCF logical literal constant; for example, the 
characters 'T' or 'F' could be used to represent .TRUE. or .FALSE. 
respectively.  In this case it is as if .TRUE. or .FALSE. were specified as 
the CCF-set-option-literal-constant.

The CCF-set-option acts as if a CCF assignment statement (RC735) -- which 
consists of the CCF-set-option-variable as the CCF variable and the
CCF-set-option-literal-constant as the CCF expression (RC723) -- were placed 
in between the last CCF type declaration statement (RC501) and the first CCF 
executable construct (RC215) of the CCF program.

NOTE TO REVIEWER: Although this may be a convenient way to implement the
CCF-set-option, I am unsure as to whether or not it is a reasonable way
to describe the CCF-set-option.  Essentially, any value assigned in the
CCF type declaration statement is replaced with the value in the CCF set 
option.
ENDNOTE TO REVIEWER

The CCF-set-option-variable must be a CCF variable in the CCF program either
declared in the CCF type declaration statement or made accessible by a CCF use
statement.  The type of this CCF variable shall match the type of the 
CCF-set-option-literal-constant.  The CCF-set-option-literal-constant shall be 
a CCF literal constant (RC306).

If this CCF variable appears in the CCF program as the CCF variable in a CCF 
assignment statement, it shall appear at least once in a previous CCF 
executable construct.

NOTE TO REVIEWER
This may clarify any confusion as to whether or not the CCF-set-option
may be used to override the value assigned in a CCF assignment statement, 
since not every programmer will read the next note.
ENDNOTE TO REVIEWER

 Note 15.15.4
 The value assigned to a CCF variable with the CCF-set-option shall not 
 override the value assigned to a CCF variable with the CCF assignment 
 statement.
 ENDNote 15.15.4

The CCF-set-option may or may not appear if the CCF-on-option specifies 
that the CCF program is to be recognized by the processor.

	15.15.2.3  The CCF FILE option

The CCF file (15.15.3) may be created as output from CCF in order to show 
exactly which blocks of code, if any, are selected to be ignored (treated as 
comments) by the processor based on the conditional compilation specified with 
CCF if constructs.  

There are different flavors of the CCF file; each serves to feed a different 
personal style of Fortran source input or different uses of conditional 
compilation.  The CCF-file-option is a method of specifying which flavor of 
the CCF file is desired.

The CCF-file-option minimally consists of a method to specify which flavor
of the CCF file is to be generated by the CCF program - either the
CCF-short-file (15.15.3.2), the CCF-shift-file (15.15.3.3), or the 
CCF-overwrite-file (15.15.3.4).  Whether or not the name of the CCF file may 
be specified in the CCF-file-option is processor defined.

 Note 15.15.5
 The CCF file need not be generated in order to achieve conditional
 compilation as executing the CCF program may result in direct communication 
 to the processor as to which blocks of source text are to be ignore.  
 ENDNote 15.15.5

If the CCF-file-option specifies the CCF-shift-file as the CCF file flavor,
the CCF program shall not contain a CCF-overwrite-comment-line (15.15.3.1.3)
within a CCF if construct (RC802).  
If the CCF-file-option specifies the CCF-overwrite-file as the CCF file flavor,
the CCF program shall not contain a CCF-shift-comment-line (15.15.3.1.1)
within a CCF if construct.
If the CCF-file-option specifies the CCF-short-file as the CCF file flavor,
the CCF program shall not contain both CCF-shift-comment-lines and  
CCF-overwrite-comment-lines within the CCF if constructs. 

A processor may require that the CCF-file-option appear if the CCF-on-option 
specifies that the CCF program is to be recognized by the processor.

NOTE TO REVIEWER
It is left to the processor since some may decide that the CCF file is
always generated so as to leave no confusion as to exactly which lines were
processed.
ENDNOTE TO REVIEWER

	15.15.3  The CCF file

The CCF file may be created by the execution of CCF programs.  There are three 
flavors of the CCF file - the CCF-short-file, the CCF-shift-file and the 
CCF-overwrite-file.  Creating the CCF file requires recognizing four forms of a
CCF comment line (15.3.3.1.1) - the CCF-shift-comment-line, the 
CCF-unshift-comment-line, the CCF-overwrite-comment-line, and the
CCF-unoverwrite-comment-line.

 Note 15.15.6
 By creating either the CCF-shift-file or the CCF-overwrite-file,
 it is possible to replace the input source with the CCF file without 
 losing information.  This is made possible by categorizing CCF comment 
 lines.
 ENDNote 15.15.6

	15.15.3.1  CCF comment lines

CCF comment lines are all source lines that are not CCF statements or partial
CCF statements.  Execution of an CCF if construct in CCF programs requires the
recognition of two forms of CCF comment lines -- CCF shift comment lines and
CCF overwrite comment lines.  CCF comment lines that are CCF shift comment 
lines or CCF overwrite comment lines may be modified by the execution of CCF 
TRUE blocks and CCF FALSE blocks.

	15.15.3.1.1  CCF shift comment lines

The CCF-shift-comment-line is a CCF comment line that has the characters 
"!CCF>" in character positions 1 to 5.

A CCF comment line that is not a CCF-shift-comment-line becomes a 
CCF-shift-comment-line by shifting its contents 5 character positions to the 
right and placing the characters "!CCF>" in character positions 1 to 5.  If a 
CCF comment line becomes a CCF-shift-comment-line, the length of the 
CCF-shift-comment-line shall be equal to five plus the length of the CCF 
comment line.  The length of the CCF-shift-comment-line, not including 
trailing blanks, shall be less than or equal to 132.

 Note 15.15.7
 For example, these two lines are CCF comment lines that are not CCF 
 shift comment lines:         
  
     !234567890123456789012345678
       line_len = 23 .OR. 28

 These two lines, turned into CCF shift comment lines, would become:

     !CCF>!234567890123456789012345678
     !CCF>  line_len = 23 .OR. 28

 ENDNote 15.15.7

	15.15.3.1.2  CCF unshift comment lines

The CCF-unshift-comment-line is a CCF shift comment line that has been shifted 
to the left 5 character positions.  The length of the CCF-unshift-comment-line 
is equal to the length of the CCF shift comment line minus five.

 Note 15.15.8
 For example, these two lines are CCF shift comment lines:         
  
     !CCF>!234567890123456789012345678
     !CCF>  line_len = 23 .OR. 28

 These two lines, turned into CCF unshift comment lines, would become:

     !234567890123456789012345678
       line_len = 23 .OR. 28

 ENDNote 15.15.8
		     
	15.15.3.1.3  CCF overwrite comment lines

The CCF-overwrite-comment-line is a CCF comment line that has the characters 
"!CCF*" in character positions 1 to 5.

A CCF comment line that is not a CCF-overwrite-comment-line becomes a 
CCF-overwrite-comment-line by replacing the characters in character positions 
1 to 5 with the characters "!CCF*".  The replaced characters shall be "     "
(5 blanks).

 Note 15.15.9
 For example, these two lines are CCF comment lines that are not CCF 
 overwrite comment lines (each lines starts with 5 blanks):

	  !78901234567890123456
	  line_len = 18

 These two lines, turned into CCF overwrite comment lines, would become:

     !CCF*!78901234567890123456
     !CCF*line_len = 18

 ENDNote 15.15.9

	15.15.3.1.4  CCF unoverwrite comment lines

The CCF-unoverwrite-comment-line is a CCF overwrite comment line that has 
replaced the characters "!CCF*" in character positions 1 to 5 with the 
characters "     " (five blanks).  The length of the 
CCF-unoverwrite-comment-line is equal to the length of the CCF overwrite 
comment line.

 Note 15.15.10
 For example, these two lines are CCF overwrite comment lines:         
  
     !CCF*!78901234567890123456
     !CCF*line_len = 18

 These two lines, turned into CCF unoverwrite comment lines, would become
 (each lines starts with 5 blanks):

	  !78901234567890123456
	  line_len = 18

 ENDNote 15.15.10

	15.15.3.2  The CCF short file

The CCF-short-file shall consist of all the CCF comment lines, possibly
modified, in the order in which they appear in the CCF program except those 
that are in a CCF FALSE block.  There are no CCF statement lines in the 
CCF-short-file.  The CCF-short-file shall have at most the same number of 
lines as the source text.

Execution of a CCF TRUE block changes each CCF shift comment line contained in 
the CCF TRUE block to a CCF-unshift-comment-line in the CCF-short-file
according to 15.15.3.1.2.

Execution of a CCF TRUE block changes each CCF overwrite comment line 
contained in the CCF TRUE block to a CCF-unoverwrite-comment-line in the 
CCF-short-file according to 15.15.3.1.4.

 Note 15.15.11
 For example, consider the following CCF program:
  
     !CCF$ integer, parameter :: vendorA = 1, vendorB = 2
     !CCF$ integer :: using_vendor = vendorA
     !CCF$ if (using_vendor == vendorA) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif
	   
	   INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER

 If the CCF-file-option specifies the CCF-short-file and the CCF-set-option
 is not specified, the following CCF short file would be created by executing
 the above CCF program.

	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
	   
	   INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER

 ENDNote 15.15.11

	15.15.3.3  The CCF shift file

The CCF-shift-file shall consist of all the CCF comment lines, possibly
modified, and all the CCF statement lines in the order in which they appear 
in the CCF program.  The CCF-shift-file shall have the same number of lines 
as the source text.

Execution of a CCF FALSE block changes each CCF comment line that is not a
CCF shift comment line contained in the CCF FALSE block to a CCF shift 
comment line in the CCF-shift-file according to 15.15.3.1.1.

A processor shall not change a CCF shift comment line that appears in a CCF 
FALSE block. 

Execution of a CCF TRUE block changes each CCF shift comment line contained in 
the CCF TRUE block to a CCF unshift comment line in the CCF-shift-file 
according to 15.15.3.1.2.

 Note 15.15.12
 For example, consider the following CCF program:
  
     !CCF$ integer, parameter :: vendorA = 1, vendorB = 2
     !CCF$ integer :: using_vendor = vendorA
     !CCF$ if (using_vendor == vendorA) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
     !CCF>      INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif
	   
	   INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER

 If the CCF-file-option specifies the CCF-shift-file and the CCF-set-option
 specifies that the value of CCF variable "using_vendor" shall be "vendorB",
 the following CCF shift file would be created by executing
 the above CCF program.

     !CCF$ integer, parameter :: vendorA = 1, vendorB = 2
     !CCF$ integer :: using_vendor = vendorA
     !CCF$ if (using_vendor == vendorA) then
     !CCF>      INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif
	   
	   INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER

 ENDNote 15.15.12

	15.15.3.4  The CCF overwrite file

The CCF-overwrite-file shall consist of all the CCF comment lines, possibly 
modified, and all the CCF statement lines in the order in which they appear 
in the CCF program.  The CCF-overwrite-file shall have the same number of 
lines as the source text.

Execution of a CCF FALSE block changes each CCF comment line that is not a
CCF overwrite comment line contained in the CCF FALSE block to a CCF 
overwrite comment line in the CCF-overwrite-file according to 15.15.3.1.3.

A processor shall not change a CCF overwrite comment line that appears in a 
CCF FALSE block. 

Execution of a CCF TRUE block changes each CCF overwrite comment line 
contained in the CCF TRUE block to a CCF unoverwrite comment line in the
CCF-overwrite-file according to 15.15.3.1.4.

 Note 15.15.13
 For example, consider the following CCF program:
  
     !CCF$ integer, parameter :: vendorA = 1, vendorB = 2
     !CCF$ integer :: using_vendor = vendorA
     !CCF$ if (using_vendor == vendorA) then
     !CCF* INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif
	   
	   INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER

 If the CCF-file-option specifies the CCF-overwrite-file and the 
 CCF-set-option is not specified, the following CCF overwrite file 
 would be created by executing the above CCF program.

     !CCF$ integer, parameter :: vendorA = 1, vendorB = 2
     !CCF$ integer :: using_vendor = vendorA
     !CCF$ if (using_vendor == vendorA) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
     !CCF* INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif
	   
	   INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER

 ENDNote 15.15.13

	15.15.3.5   Replacing the input file with the CCF file

The above definitions of CCF shift comment lines, CCF overwrite comment lines,
the CCF shift file, and the CCF overwrite file permits replacing the input
source file with the CCF file.  Replacing the input source file with the
CCF short file, however, would result in deleting the CCF program and possibly
CCF comment lines.

 Note 15.15.14
 For example, consider the CCF if construct:
  
     !CCF$ if (using_vendor == vendorA) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif
	   
 If the CCF-file-option specifies the CCF-overwrite-file and CCF variable
 "using_vendor" is set to "vendorA", the following would appear in the
 CCF overwrite file created by executing the above CCF if construct. 

     !CCF$ if (using_vendor == vendorA) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
     !CCF* INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif

 If the CCF-file-option specifies the CCF-overwrite-file and CCF variable
 "using_vendor" is set to "vendorB", the following would appear in the
 CCF overwrite file created by executing the above CCF if construct. 

     !CCF$ if (using_vendor == vendorA) then
     !CCF* INTEGER, PARAMETER :: FOUR_BYTE_INT = 1
     !CCF$ elseif (using_vendor == vendorB) then
	   INTEGER, PARAMETER :: FOUR_BYTE_INT = 4
     !CCF$ else  ! error with the value of using_vendor on CCF-set-option
     !CCF$  print *, 'CCF variable "using_vendor" shall be set to 1 or 2'
     !CCF$  stop 'Set "using_vendor" correctly on the CCF-set-option'
     !CCF$ endif

 If the CCF-file-option specifies the CCF-overwrite-file and CCF variable
 "using_vendor" is set to the value 3, the contents of the
 CCF overwrite file created by executing the above CCF if construct is
 processor defined.
 ENDNote 15.15.14


--=====================_805496652==_--

