From: Cheng Xu <[email-masked]>
Date: Tue, 12 Dec 1995 10:06:37 +0800

/*****************************************************/
/*    HPF Semantic Routine Requirement               */
/*                 (Proposal!)                       */
/*---------------------------------------------------*/
/*           Please set tabstop=4                    */
/*****************************************************/

The tasks of semantic routine can be divided into two parts: 

1) checking and reporting semantic errors
2) semantic actions to facilitate later parts of compilation

In following 5 sections, we will introduce our proposal about the tasks of HPF Semantic routine in detail. 

Section 1	HPF Source Program Structure, Type Definition, 
            Data Object Declaration and Specification

Semantic routine requirements involved in HPF source program structure, type Definition, data object Declaration and specification will be introduced in following six parts:

1) program structure
	order of statements

2) intrinsic data type definition
	legality of kind_param: 
				a. nonnegative
				b. valid
				c. default value
	implicity declaration's information

3) derived type definition
	a. attribute declaration legality and constraints 
	b. component that can not occur
	c. component legality

4) attribute declaration statement 
	a. legality
	b. variable name valid

5) array
	a. attribute declaration constraints
	b. elements 
	c. subscript 
	d. requirement of different kinds array

6) common statement and equivalence statement
	a. common statement and common block constraints
	b. equivalence statement constraints
	c. constraints of common statement and equivalence association
	d. constraints of storage and sequence association

In the following part of this section, We will discuss above mentioned 6 kinds of requirements in more details.

1. Declaration statement

1.1 intrinsic type 

1.1.1 numeric type

1.1.1.1 INTEGER             
	 R401 signed_digit_string           is   [sign]digit_string
	 R402 digit_string                  is   digit[digit]...             
	 R403 signed_int_literal_constant   is   [sign]int_literal_constant
	 R404 int_literal_constant          is   digit_string[_kind_param]
	 R405 kind_param                    is   digit_string
					or   scalar_int_constant_name
	 R406 sign                          is   +
					or   -
	Constraint: value of kind_param must not be negative
	Constraint: value of kind_param must express an expression method that the 
		processor supports

	In DATA statement, an unsigned binary, octal, hexadecimal literal constant 
	must match a integer vector variable
	 
	 R407 boz_literal_constant          is    binary_constant
					or    octal_constant
					or    hex_constant
	Constraint: boz_literal_constant can only present in DATA statement

	 R408 binary_constant               is    B'digit[digit]...'
					or    B"digit[digit]..."
	Constraint: value of digit must be 0 or 1

	 R409 octal_constant                is    O'digit[digit]...'
					or    O"digit[digit]..."
	Constraint: value of digit must be one from 0 to 7

	 R410 hex_constant                  is    Z'hex_digit[hex_digit]...'
					or    Z"hex_digit[hex_digit]..."
	 R411 hex_digit                     is    digit
					or    A
					or    B
					or    C
					or    D
					or    E
					or    F
	if processor suport lower character, hex_digit A through F can be expressed
	by matched lower character.

1.1.1.2 REAL
	 R412 signed_real_literal_constant  is    [sign]real_literal_constant
	 R413 real_literal_constant         is    significand[exponent_letter exponent][_kind_param]
					or    digit_string exponent_letter exponent[_kind_param]
	 R414 significand                   is    digit_string.[digit_string]
					or    .digit_string
	 R415 exponent_letter               is    E
					or    D
	 R416 exponent                      is    signed_digit_string
	Constraint: if have declared type keyword REAL but not declared type kind 
		parameter, kind_param default value is KIND(0.0) and this data 
		entity is default real
	Constraint: if type keyword is DOUBLE PRECISION, it can not declare type 
		kind parameter (its value is KIND(0.0D0)), and this data entity 
		is double precision
	Constraint: if both of kind_param and exponent_letter have been declared, 
		exponent_letter must be E
	Constraint: value of kind_param must be an expression method that the processor 
		supports
	
1.1.1.3 COMPLEX 
	 R417 complex_literal_constant      is    (real_part,imag_part)
	 R418 real_part                     is    signed_int_literal_constant
					or    signed_real_literal_constant
	 R419 imag_part                     is    signed_int_literal_constant
					or    signed_real_literal_constant

1.1.2 nonnumric type
	
1.1.2.1 CHARACTER 
	 R420 char_literal_constant         is    [kind_param_]'[rep_char]...'
					or    [kind_param_]"[rep_char]..."
	Constraint: value of kind_param must present one expression method that the 
		processor suport

1.1.2.2 LOGICAL 
	 R421 logical_literal_constant      is    .TURE.[_kind_param]
					or    .FALSE.[_kind_param]
	Constraint: value of kind_param must present one expression method that the 
		processor suport

1.2 derived type
	 
	 R422 derived_type_def              is    derived_type_stmt
						[private_sequence_stmt]...
						  component_def_stmt
						  [component_def_stmt]...
						  end_type_stmt
	 R423 private_sequence_stmt         is    PRIVATE
					or    SEQUENCE
	 R424 derived_type_stmt             is    TYPE[[,access_spec]::]type_name
	Constraint: in a given derived_type_def, the same private_sequence_stmt can 
		not present more than once
	Constraint: if SEQUENCE is declared, all derived type in the declaration of 
		components must be sequence type 
	Constraint: only if type definition is in the declaration part of a module, 
		there can have access_spec or PRIVATE statement in the definition
	Constraint: if one component of the derived type is declared as a private type, 
		it must be that definition of derived type include PRIVATE statement 
		or the derived type is private
	Constraint: type_name of derived type can not match any name of intrinsic type, 
		and can not match any other type_name of derived type which can 
		be accessed either
	 
	 R425 end_type_stmt                 is    END TYPE[type_name]
	Constraint: if END TYPE followed by type_name, this type_name must match the 
		type_name of associated derived_type_stmt

	 R426 component_def_stmt            is    type_spec[[,component_attr_spec_list]::]component_decl_list
	 R427 component_attr-spec           is    POINTER
					or    DIMENSION(component_array_spec)
	Constraint: the component_attr_spec can not present more than once in component_def_stmt
	Constraint: if one component does not have POINTER attribution, the type_spec 
		in the component_def_stmt must be declared as intrinsic type 
		or derived type that has been declared
	Constraint: if one component has POINTER attribution, the type_spec in the 
		component_def_stmt must be declared as intrinsic type or derived 
		type that has been declared or is just declared

	 R428 component_array_spec          is    explicit_shape_spec_list
					or    deferred_shape_spec_list
	 R429 component_decl                is    component_name[(component_array_spec)][*char_length]
	Constraint: if there is no POINTER attribution, every component_array_spec must 
		be explicit_shape_spec_list
	Constraint: if there is POINTER attribution, every component_array_spec must 
		be deferred_shape_spec_list
	Constraint: the option * char_length is legal only if declared type is character
	Constraint: the length of character which is declared by char_length of component_decl 
		or by char_selector of type_spec must be a constant literal expression.
	Constraint: every bound in explicit_shape_spec must be a constant literal expression.
	Constraint: if declared DIMENSION attribute or POINTER attribute or both, 
		'::' in component_def_stmt is required, otherwise it is option.
	Constraint: entities in difference scoping unit may have the same type, if they 
		was declared by difference types, and these types have the same
		name, both have SEQUENCE attribute, and their components do not 
		have PRIVATE accessibility, and their components' order, name and 
		attributes are all identical.
	Constraint: if one component of a derived type is a pointer, constructor expression 
		must evaluate an object, and this object will be the target
		associated the pointer in the pointer assignment statement.
  
1.3 Construction of array value
	 
	 R431 array_constructor             is    (/ac_value_list/)
	 R432 ac_value                      is    expr
					or    ac_implied_do
	 R433 ac_implied_do                 is    (ac_value_list,ac_implied_do_control)
	 R434 ac_implied_do_control         is    ac_do_variable=scalar_int_expr,scalar_int_expr[,scalar_int_expr]
	 R435 ac_do_variable                is    scalar_int_variable
	Constraint: ac_do_variable must be a named variable
	Constraint: every ac_value expression in array_constructor must have the same 
		types and kind parameters.

2. Data object declaration and specification

2.1 type declaration statement
	 
	 R501 type_declaration_stmt         is    type_spec[[,attr_spec]...::]entity_decl_list
	 R502 type_spec                     is    INTEGER [kind_selector]
					or    REAL [kind_selector]
					or    DOUBLE PRECISION
					or    COMPLEX [kind_selector]
					or    CHARACTER [kind_selector]
					or    LOGICAL [kind_selector]
					or    TYPE(type_name)
	 R503 attr_spec                     is    PARAMETER
					or    access_spec
					or    ALLOCABLE
					or    DIMENSION(array_spec)
					or    EXTERNAL
					or    INTENT(intent_spec)
					or    INTRINSIC
					or    OPTIONAL
					or    POINTER
					or    SAVE
					or    TARGET
	 R504 entity_decl                   is    object_name[(array_spec)][* char_length][=initialization_expr]
					or    function_name[(array_spec)][* char_length]
	 R505 kind_selector                 is    ([KIND=]scalar_int_initialization_expr)
	Constraint: identical attr_spec can not present more than once in a special 
		type_declaration_stmt 
	Constraint: function_name must be an external function name, internal function 
		name, function dummy procedure name, or statement function name
	Constraint: if statement include PARAMETER attribute, '= initialization_expr' 
		must present
	Constraint: if there is '= initialization_expr', '::' must present in front 
		of entity_decl_list
	Constraint: if object_name is a dummy, a function result, an object in a named 
		common block except that block is in the block data program unit 
		type declaration, an object in a blank common, allocable array, 
		pointer, external name, internal name, or automatic object, there 
		can not present '= initialization_expr'
	Constraint: only if the declaration type is CHARACTER, there can present char_length 
		option
	Constraint: only if it is an array declaration, and the array is not a dummy and 
		not a function result, there may be ALLOCATION attribute
	Constraint: if declared array has ALLOCATABLE attribute or POINTER attribute, 
		there must present array_spec and deferred_shape_spec_list
	Constraint: if a function result object_name doesn't have the POINTER  attribute, 
		its array_spec must be explicit_shape_spec_list
	Constraint: if POINTER attribute is declared, there can not declare TARGET, 
		INTENT, EXTERNAL or INTRINSIC attribute
	Constraint: if TARGET attribute is declared, there can not declare POINTER, 
		EXTERNAL,INTRINSIC or PARAMETER attribute
	Constraint: Can not use PARAMETER attribute to declare a dummy, pointer, allocatable 
		array, function, object in a common block
	Constraint: INTENT and OPTIONAL attributes can only descript a dummy
	Constraint: if a entity's type has PRIVATE attribute, it can not have PUBLIC 
		attribute
	Constraint: if it is an object in a common block, a dummy, a procedure, a function 
		result or automatic data object, it may not have SAVE attribute
	Constraint: if an entity's type has INTRINSIC attribute, it may not have 
		EXTERNAL attribute
	Constraint: if an entity in type_declaration_stmt is not a function, it may 
		not have EXTERNAL or INTRINSIC attribute
	Constraint: an array may not have ALLOCATABLE attribute and POINTER attribute 
		at the same time
	Constraint: in a scoping unit, an entity may not explicitly declare an identical 
		attribute
	Constraint: value of scalar_int_initialization_expr must be nonnegative, and 
		it must present an express method of that processor
 
2.2 type declarator
  
2.2.1 INTEGER
2.2.2 REAL
2.2.3 DOUBLE PRECISION
2.2.4 COMPLEX
2.2.5 CHARACTER 
	 
	 R506 char_selector                 is    length_selector
					or    (LEN=type_param_value,KIND=scalar_int_initialization_expr)
					or    (type_param_value,KIND=scalar_int_initialization_expr)
					or    (KIND=scalar_int_initialization_expr[,LEN=type_param_value])
	 R507 length_selector               is    ([LEN=]type_param_value)
					or    * char_length[,]
	 R508 char_length                   is    (type_param_value)
					or    scalar_int_literal_constant
	Constraint: the optional ',' in the length_selector can only present in 
		type_spec of type_declaration_stmt
	Constraint: only if there is not a seperator '::' in the type_declaration_stmt, 
		there may have the optional ',' in the length_selector
	Constraint: value of scalar_int_initialization_expr must be nonnegative, 
		and it must present an express method of that processor    
	Constraint: there may not include kind_param in the scalar_int _literal_constant
	 
	 R509 type_param_value              is    specification_expr
					or    *
	Constraint: if the function is a internal function, a module function, array 
		valued, pointer or recursive, this function may not declare a type_param_value with a '*'
	Constraint: a length type parameter value can be '*' , if:
	  (1)   it may use for declaring a dummy of a procedure, and when this procedure 
		is called, its length associate the length of actual argument
	  (2)   it may use for declaring a named constant, and its length is the 
		length of that constant
	  (3)   in external function, the function result may have a '*' length 
		type parameter value; and any scoping unit which call this function 
		must declare this function name do not have a '*' length type 
		parameter length or call this function by host association or use 
		association. 
	Constraint: the value of character valued statement function or character statement 
		function dummy must be a int constant expression
  
2.2.6 LOGICAL
2.2.7 derived type

2.3 attribute

2.3.1 PARAMETER

2.3.2 accessibility
	 
	 R510 access_spec                   is    PUBLIC 
					or    PRIVATE
	Constraint: the access_spec may only present in the module scoping unit

2.3.3 INTENT
	 
	 R511 intent_spec                   is    IN
					or    OUT       
					or    INOUT
	Constraint: INTENT may not descripte the dummy of a dummy procedure or a 
		dummy pointer
	Constraint: check the use of a variable with INTENT attribute

2.3.4 DIMENSION
	 
	 R512 array_spec                    is    explicit_shape_spec_list
					or    assumed_shape_spec_list
					or    deferred_shape_spec_list
					or    assumed_size_spec
	Constraint: the rank can not more than 7

2.3.4.1 explicit shape array
	 R513 explicit_shape_spec           is    [lower_bound:]upper_bound
	 R514 lower_bound                   is    specification_expr
	 R515 upper_bound                   is    specification_expr
	Constraint: if the bound of a explicit shape array depends the value of a 
		nonconstant expression
   
2.3.4.2 assumed shape array
	 R516 assumed_shape_array           is    [lower_bound]:

2.3.4.3 deferred shape array 
	 R517 deferred_shape_array          is    :

2.3.4.4 assumed size array
	 R518 assumed_size_spec             is    [explicit_shape_spec_list,][lower_bound:]*
	Constraint: the function name of a array valued function may not be declared 
		as assumed size array

2.3.5 SAVE
	
	Constraint: the SAVE attribute may not descripte objects in common block, 
		dummy, procedure, function result or automatic data object

2.3.6 OPTIONAL
	
	Constraint: the OPTIONAL attribute may only present in a subprogram or a 
		interface block scoping unit, and only descripte dummies

2.3.7 POINTER
2.3.8 TARGET
2.3.9 ALLOCATABLE
2.3.10 EXTERNAL
2.3.11 INTRINSIC

2.4 parameter declaration statement

2.4.1 INTENT statement
	 
	 R519 intent_stmt                   is    INTENT(intent_spec)[::]dummy_arg_name_list
	Constraint: intent_stmt may only present in the specification_part of a 
		subprogram or a interface body
	Constraint: dummy_arg_name may not be a name of a dummy procedure or a 
		dummy pointer

2.4.2 OPTIONAL statement
	 
	 R520 optional_stmt                 is    OPTIONAL[::]dummy_arg_name_list
	Constraint: optional_stmt may only present in a subprogram or a interface 
		body scoping unit

2.4.3 accessible statement
	 
	 R521 access_stmt                   is    access_spec[[::]access_id_list]
	 R522 access_id                     is    use_name
					or    generic_spec
	Constraint: access_stmt may only present in a module scoping unit. Only one 
		access statement omitting access_id_list is promised in a module 
		scoping unit
	Constraint: every use_name must be a name of a named variable, a procedure, 
		a derived type, a named constant or a name list
	Constraint: a module procedure which has a dummy or function result which has 
		PRIVATE accessible attribute must have PRIVATE accessible attribute, 
		and may not have a generic identifier with PUBLIC accessible.

2.4.4 SAVE statement
	 
	 R523 save_stmt                     is    SAVE[[::]saved_entity_list]
	 R524 saved_entity                  is    object_name
					or    /common_block_name/
	Constraint: object_name may not be a dummy name, a procedure name, a function 
		result name, an automatic object name, or the name of a entity 
		in a common block
	Constraint: if a SAVE statement which omits its saved entity list occur in 
		a scoping unit, and there is no other explicit SAVE attribute or 
		SAVE statement in the same scoping unit, this is promised

2.4.5 DIMENSION statement 
	 
	 R525 dimension_stmt                is    DIMENSION[::]array_name(array_spec)[,array_name(array_spec)]...

2.4.6 ALLOCATABLE statement
	 
	 R526 allocatable_stmt              is    ALLOCATABLE[::]array_name[(deferred_shape_spec_list)][,array_name[(deferred_shape_spec_list)]]...
	Constraint: array_name may not be a dummy or a function result
	Constraint: array_spec must be deferred_shape_spec_list unless the array_name 
		was declared with DIMENSION attribute at other point of the same 
		scoping unit

2.4.7 POINTER statement 
	 
	 R527 pointer_stmt                  is    POINTER[::]object_name[(deferred_shape_spec_list)][,object_name[(deferred_shape_spec_list)]]...
	Constraint: object_name may not have INTENT attribute
	Constraint: array_spec must be deferred_shape_spec_list unless the object_name 
		was declared with DIMENSION attribute at other point of the same 
		scoping unit  
	Constraint: object_name may not have PARAMETER attribute

2.4.8 TARGET statement 
	 
	 R528 target_stmt                   is    TARGET[::]object_name[(array_spec)][,object_name[(array_spec)]]...
	Constraint: object_name may not have PARAMETER attribute

2.4.9  DATA statement 
	 
	 R529 data_stmt                     is    DATA data_stmt_set[[,]data_stmt_set]...
	Constraint: a variable or a part of a variable may not be initialized more 
		than once in a excutable program
	 R530 data_stmt_set                 is    data_stmt_object_list/data_stmt_value_list/
	 R531 data_stmt_object              is    variable
					or    data_implied_do
	 R532 data_stmt_value               is    [data_stmt_repeat *]data_stmt_constant
	 R533 data_stmt_constant            is    scalar_constant
					or    signed_int_literal_constant
					or    signed_real_literal_constant
					or    structure_constructor_
					or    boz_literal_constant
	 R534 data_stmt_repeat              is    scalar_int_constant
	 R535 data_implied_do               is    (data_i_do_object_list,data_i_do_variable=scalar_int_expr,scalar_int_expr[,scalar_int_expr])
	 R536 data_i_do_object              is    array_element
					or    scalar_structure_component
					or    data_implied_do
	Constraint: array_element may not have a constant parent
	Constraint: scalar_structure_component may not have a constant parent
	 R537 data_i_do_variable            is    scalar_int_variable
	Constraint: data_i_do_variable must be a named constant
	Constraint: DATA statement repeater must be nonnegative. if DATA statement 
		repeater is a named constant, it must have been declared in the 
		scoping unit or it is accessible by use association or host association.
	Constraint: if data_stmt_constant is structure_constructor, every component 
		must be an initialization expression.
	Constraint: if a variable is in data_stmt_object, any subscript, section subscript, 
		start of a substring and end of a substring must be an initialization 
		expression.
	Constraint: if a variable's name or its designator is included in data_stmt_object_list 
		or data_i_do_object_list, it may not be a dummy, or any of function name,
		function result name, automatic object name, pointer, allocatable array which
		is accessible by host association or use association and occurs in a named 
		common block or blank common block that this block do not occur in a DATA 
		statement of a data block program unit
	Constraint: in array_element and scalar_structure_component of data_i_do_object,
		any subscript must be an expression and its initialization value
		is a constant, or DO variable which include data_implied_do, and 
		every calculation must be intrinsic
	Constraint: the initialization value ofscalar_int_expr of data_implied_do must 
		be a constant or a DO variable which include data_implied_do, and 
		every calculation must be intrinsic

2.4.10 PARAMETER statement
	 
	 R538 parameter_stmt                is    PARAMETER(named_constant_def_list)
	 R539 named_constant_def            is    named_constant=initialization_expr

2.5 IMPLICIT statement
	 
	 R540 implicit_stmt                 is    IMPLICIT implicit_spec_list
					or    IMPLICIT NONE     
	 R541 implicit_spec                 is    type_spec(letter_spec_list)
	 R542 letter_spec                   is    letter[_letter]
	Constraint: if IMPLICIT NONE is declared in a scoping unit, it must present before
		any PARAMETER statement, and there is no other IMPLICIT statement 
		in the same scoping unit
	Constraint: if '-' and the second letter occur, the second letter must after 
		the first letter in the alphabet

2.6 NAMELIST statement
	 
	 R543 namelist_stmt                 is    NAMELIST/namelist_group_name/ namelist_group_object_list[[,]/namelist_group_name/ namelist_group_object_list]
	 R544 namelist_group_object         is    variable_name
	Constraint: namelist_group_object may not be an array dummy with nonconstant 
		bound, a variable with nonconstant character length, automatic
		variable, pointer, a variable with pointer ultimate component or
		allocatable array
	Constraint: if namelist_group_name has PUBLIC attribute, every item in namelist_group_object_list
		may not have PRIVATE attribute

2.7 EQUIVALENCE 
	 
	 R545 equivalence_stmt              is    EQUIVALENCE equivalence_set_list
	 R546 equivalence_set               is    (equivalence_object,equivalence_object_list)
	 R547 equivalence_object            is    variable_name
					or    array_element
					or    substring
	Constraint: equivalence_object may not be a dummy, pointer, allocatable array,
		nonsequence derived type object, sequence derived type object with
		a pointer component in any level, automatic object, function name,
		entry name, result name, named constant, structure component, or 
		subobject of the earlier objects
	Constraint: in equivalence_object, every subscript or substring scoping expression
		must be a int initialization expression
	Constraint: if equivalence_object is default integer, default real, double 
		precision, default complex, default logical, numeric sequence 
		type, every object of the equivalence set must be the upper type
	Constraint: if equivalence_object is default character or sequence character,
		every object of the equivalence set must be the upper type
	Constraint: if equivalence_object is non numeric sequence or non character 
		sequence derived type, every object of the equivalence set must
		be the same type 
	Constraint: if equivalence_object is intrinsic type, and this intrinsic type
		is not default integer, default real, double precision, default
		complex, default logical, default character, then every object of 
		the equivalence set must be the same type with the same kind
		parameter value  
	Constraint: EQUIVALENCE statement may not make a single entity is distribute 
		on to two different storage unit
	Constraint: EQUIVALENCE statement may not make two different elements of one 
		array are distribute on to a same storage unit.
	Constraint: EQUIVALENCE statement may not separate a entity with continual storage  
		into uncontinual storage unit.

2.8 COMMON statement 
	 
	 R548 common_stmt                   is    COMMON[/[common_block_name]/]common_block_object_list[[,]/[common_block_name]/common_block_object_list]...
	 R549 common_block_stmt             is    variable_name[(explicit_shape_spec_list)]
	Constraint: in all common_block_object_list of a scoping unit, a special variable_name
		may only occur once.
	Constraint: common_block_object may not be a dummy, an allocatable array, an
		automatic object, a function name, an entry name, or a result name
	Constraint: every bound of explicit_shape_spec must be a constant declaration 
		expression
	Constraint: if common_block_object's type is a derived type, it must be a 
		sequence type
	Constraint: if a variable_name occurr with explicit_shape_spec_list, it may
		not have POINTER attribute
	Constraint: In a single common field, common entities may all be character type 
		or all be non-character type.

2.9 association of COMMON statement and EQUIVALENCE statement
	
	Constraint: a common block can expland at the end, but can not expland at
		the header.
	Constraint: An indirect distribution of common entities may not modify the
		direct distribution
	Constraint: Can not make different entities of a same common block or entities 
		of different common blocks to be equivalence.

2.10 storage and sequence association
	 
	 H701 sequence-directive            is    SEQUENCE[[::]association-name-list]
					or    NO SEQUENCE[[::]association-name-list]
	 H702 association-name              is    variable-name
					or    / common-block-name /
	Constraint: The result variable of an array-valued function that is not an intrinsic function
		is a nonsequential array. It may not appear in any HPF SEQUENCE directive.
	Constraint: A variable or COMMON block name may appear at most once in a sequence-directive 
		within ant scoping unit.

	Storage Association Rules
	 1. A sequence-directive with an empty association-name-list is treated as if it contained
	the name of all implicitly mapped variables and COMMON blocks in the scoping unit
	which cannot otherwise be determined to be sequential or nonsequential by their
	language context.
	 2. A sequential variable may not be explicitly mapped unless it is a scalar or rank-one
	array that is an aggregate cover. If there is more that one aggregate cover for an
	aggregate variable group, only one may be explicitly mapped.
	 3. No explicit mapping may be given for a component of a derived type having the
	Fortran 90 SEQUENCE attribute.
	 4. If a COMMON block is nonsequential, then all of the following must hold:
	(a) Every occurrence of the COMMON block has exactly the same number of components
		with each corresponding component having a storage sequence of exactly the
		same size;
	(b) If a component is a nonsequential variable in any occurrence of the COMMON block,
		then it must be nonsequential with identical type, shape, and mapping attributes
		in every occurrence of the COMMON block;
	(c) If a component is sequential and explicitly mapped (either a variable or an aggregate
		variable group with an explicitly mapped aggregate cover) in any occurrence
		of the COMMON block, then it must be sequential and explicitly mapped with identical
		mapping attributes in every occurrence of the COMMON block. In addition,
		the type and shape of the explicitly mapped variable must be identical in all
		occurrences; and
	(d) Every occurrence of the COMMON block must be nonsequential.

3. use data object
	 
	 R601 variable                      is    scalar_varible_name
					or    array_variable_name
					or    subobject
	Constraint: array_variable_name must be an array data object name
	Constraint: array_variable_name may not have PARAMETER attribute
	Constraint: scalar_variable_name may not have PARAMETER attribute
	Constraint: subobject must subobject designator whose parent is a constant
	 R602 subobject                     is    array-element
					or    array_section
					or    structure_component
					or    substring
	 R603 logical_variable              is    variable
	Constraint: logical_variable must be logical type
	 R604 default_logical_variable      is    variable
	Constraint: default_logical_variable must be default logical type
	 R605 char_variable                 is    variable
	Constraint: char_variable must be character type
	 R606 default_char_variable         is    variable
	Constraint: default_char_variable must be default character type
	 R607 int_variable                  is    variable
	Constraint: int_variable must be integer type
	 R608 default_int_variable          is    variable
	Constraint: default_int_variable must be default integer type

3.1 scalar
  
3.1.1 substring
	 
	 R609 substring                     is    parent_string(substring_range)
	 R610 parent_string                 is    scalar_variable_name
					or    array_element
					or    scalar_structure_component
					or    scalar_constant
	 R611 substring_range               is    [scalar_int_expr]:[scalar_int_expr]
	Constraint: parent_string must be character type

3.1.2 structure component 
	 
	 R612 data_ref                      is    part_ref[%part_ref]...
	 R613 part_ref                      is    part_name[(section_subscript_list)]
	Constraint: in data_ref, every part_name's type must be derived type except
		the rightist one
	Constraint: in data_ref, every part_name must be a component of last part_name's
		derived type except the leftist one
	Constraint: in part_ref with section_subscript_list, the number of section_subscripts
		must equal the rank of part_name
	Constraint: there may not be many part_ref with rank 0 in data_ref. part_name
		right to a part_ref whose rank is not 0 may not have POINTER attribute
	 R614 structure_component           is    data_ref
	Constraint: in stucture_component, there must be many part_ref, and the rightist
		one must be part_name

3.2 array
  
3.2.1 whole array
3.2.2 array element and array section
	 
	 R615 array_element                 is    data_ref
	Constraint: in array_element, every part_ref's rank must be 0 and the last part_ref
		must include a subscript_list
	 R616 array_section                 is    data_ref[(substring_range)]
	Constraint: in array_section, exactly one part_ref's rank must not be 0, and
		the end part_ref have a section_subscript_list whose rank is
		not 0 or another part_ref's rank is not 0
	Constraint: in array_section with substring_range, the rightist part_name must
		be character type
	 R617 subscript                     is    scalar_int_expr
	 R618 section_subscript             is    subscript
					or    subscript_triplet
					or    vector_subscript
	 R619 subscript_triplet             is    [subscript]:[subscript][:stride]
	 R620 stride                        is    scalar_int_expr
	 R621 vector_subscript              is    int_expr
	Constraint: vector_subscript must be a integer array expression with rank 1
	Constraint: the second subscript of the last subscript_triplet of a assumed
		size array must occurr

3.2.2.1 array element
3.2.2.2 order of array element
3.2.2.3 array section
3.2.2.3.1 subscript triplet
3.2.2.3.2 vector subscript
  
3.3 allocatable association

3.3.1 ALLOCATE statement
	 
	 R622 allocate_stmt                 is    ALLOCATE (allocation_list[,STAT=stat_variable])
	 R623 stat_variable                 is    scalar_int_variable
	 R624 allocation                    is    allocate_object[(allocate_shape_spec_list)]
	 R625 allocate_object               is    variable_name
					or    structure_component
	 R626 allocate_shape_spec           is    [allocate_lower_bound:]allocate_upper_bound
	 R627 allocate_lower_bound          is    scalar_int_expr
	 R628 allocate_upper_bound          is    scalar_int_expr
	Constraint: every allocate_object must be a pointer or an allocatable array
	Constraint: in allocate_shape_spec_list, the number of allocate_shspe_specs 
		must equal to the rank of pointer or allocatable array

3.3.1.1 allocation of allocatable array
3.3.1.2 allocation of pointer target

3.3.2 NULLIFY statement 
	 
	 R629 nullify_stmt                  is    NULLIFY(pointer_object_list)
	 R630 pointer_object                is    variable_name
					or    structure_component
	Constraint: every pointer_object must have POINTER attribute

3.3.3 DEALLOCATE statement
	 
	 R631 deallocate_stmt               is    DEALLOCATE(allocate_object_list[,STAT=stat_variable])
	Constraint: every allocate_object must be a pointer or an allocatable array

3.3.3.1 deallocation of allocatable array 
3.3.3.2 deallocation of pointer target  

Section 2   Expression and Assignment

1. Expression
	 (1) determine the type of the result of expressions.

	 (2) examine about the type constrains:
		   type of the operands must match  the type of operator.

	 (3) examine shape conformance for array operation.
		   i.e. the two operands must be the have same shape ,
		   or , one or two operand is scalar variable.

	 (4) determine the scope of name and label,
		   make sure there is no conflict about two identity variables.

	 (5) about constant expression :
	  *   examine constraints on  primary.
	  *   initialization expression.
	  *   restricted expression is a kind of initialization expression,
		  but every operation must be intrinsic.

2. Assignment :   variable = expr
	 (1) the left variable cannot be the assumed_size array type.

	 (2) the type of expr must match the type of variable.

	 (3) shape conformance :
		   i.e. if expr is an array , var must be array.

	 (4) about POINTER assignment :
			   pointer_object => target
	   . pointer_object must have pointer attributes.
	   . the variable must have TARGET or POINTER attribute, or is a 
		subobject of a TARGET variable.
	   . target must have the same type ,type parameter, rank as the
		pointer.
	   . target cannot be the section of an array with vector subscript.
	   . if the target is an expression , it must give a pointer result.

	 (5) WHERE assignment :
			WHERE (mask_expr) assignment_stmt
	   . assignment_stmt cannot be the defined assignment statement.
	   . the defining variable in assignment_stmt must be the same
		shape array as the mask_expr.

Section 3     Execution Control Part

1. constrains about block :
	 e.g. jumping from the outer block construct into inner is forbidden.

2. IF construct
		   if_then_stmt
				block
		   [else_if_stmt
				block] ...
		   [else_stmt
				block]
		   end_if_stmt
	 (1) examine the constrains about  if_construct_names of if_then_stmt
		and end_if_stmt ,such as :
	  . if the if_then_stmt  has been labeled by a if_construct_name ,
		 the correspond end_if_stmt must declare the same
		 if_construct_name.
	  . if if_then_stmt has no if_construct_name, the correspond
		 end_if_stmt must not declare any name.

	 (2) about  if_stmt
		if (scalar_logical_expr) action_stmt

	  . action_stmt cannot be if_stmt ,end_program_stmt ,end_function_stmt,
		  end_subroutine_stmt.

3. CASE construct
		 select_case_stmt
		 [case_stmt
			block]...
		 end_select_stmt

	 (1) examine the constrains about  case_construct_names of select_case_stmt
		and end_select_stmt ,such as :
	  . if the select_case_stmt has been labeled by a csae_construct_name ,
		 the correspond end_select_stmt must declare the same
		 case_construct_name.
	  . if select_case_stmt has no case_construct_name, the correspond
		 end_case_stmt must not declare any name.

	 (2) a case construct cannot have more than one DEFAULT.

	 (3) every case_value must has the same type as the case_exp

	 (4)  the case_expr must only match one case_selector.

4. DO construct

	 (1) examine the constrains about  do_construct_names of do_stmt
		and end_do ,such as :
	  . if the do_stmt has been labeled by a do_construct_name ,
		 the correspond end_do_stmt must declare the same
		 do_construct_name.
	  . if do_stmt has no do_construct_name, the correspond
		 end_do_stmt must not declare any name.

	 (2) about block do construct :
		  . do variable must be a scalar variable , only integer,default 
		  real ,double Precision real are allowed.
		  . the start ,end and step of do variable can only be integer,default
		  real ,double Precision real are allowed.
			  . if do_stmt has no label  ,end_do must be a end_do_stmt;
			  . if do_stmt has label ,   the correspond end_do must use
				   the same label.

	 (3) non_block construct :
			  . do_term_action_stmt cannot be :
					 continue_stmt ,goto_stmt, return_stmt, stop_stmt,
					 exit_stmt,cycle_stmt,end_function_stmt,
					 end_subroutine_stmt,end_program_stmt,
					 arithmatic_if_stmt or assigned_goto_stmt.
			  . do_term_action_stmt must be labeled.
			  . do_term_shared_stmt cannot be :
					 goto_stmt, return_stmt, stop_stmt,
					 exit_stmt,cycle_stmt,end_function_stmt,
					 end_subroutine_stmt,end_program_stmt,
					 arithmatic_if_stmt or assigned_goto_stmt.

5.  CYCLE  statement

	 (1) if cycle has do_construct_name , it must within the scope of
			correspond do_construct ,
		 else it must be within at least one do_construct.

6.  EXIT  statement

	 (1) if exit has do_construct_name , it must within the scope of
			correspond do_construct ,
		 else it must be within at least one do_construct.

7.  Branching statement

	 (1) GOTO statement
		  . label must occurs in the same scope as goto statement.

	 (2) Arithmetic GOTO statement
		  . label must occurs in the same scope as arithmetic goto statement.

	 (3) Assigned GOTO statement
			  ASSIGN label TO scalar_int_variable ;
			  GOTO   scalar_int_variable  , (label_list) .

		  . label must occurs in the same scope as assigned goto statement.
		  . scalar_int_variable must have name and can only be default
				  integer type.

Section 4   Input/Output, Program Unit, Procedure and Function

statement   the correct component, the place and sequence of the statement
			in the program.
			
			The place, e.g. ENTRY can't appear in main_program.
			The sequence, e.g. USE can only appear after program_Stmt
			function_stmt ... 

symbol:     unique, scope, access. Such as, program_name.
		
			But, unique is not always a necessary requirement for all 
			of symbols, e.g., generic_name can be non_unique, it can be 
			same with the procedure_name in the interface.
		
			The distinguish of symbol type : variable-name, generic-name,
			function-name, type-name, program-name....

variable    type, scope, access.
		
			Use and Define. General speaking, defining must before using, 
			emphasis on: pointer and allocatable-array, undefinition 
			generated by the association (equivalence and common).
		
			Parameter Match.

label       scope ,unique in a program unit.

/*
IO KEYWORD VALUE:
STATUS      OLD,NEW,SCRATCH,REPLACE,UNKNOWN.
ACCESS      SEQUENTIAL,DIRECT,ACCESS.
FORM        FORMATED,UNFORMATED.
BLANK       NULL,ZERO.
POSITION    ASIS,REWIND,APPEND.
ACTION      READ,WRITE,READWRITE.
DECLIM      APOSTROPHE,QUOTE,NONE.
PAD     YES,NO.
*/

	RULES               SEMANTIC WORK 
1. internal_file_unit   *not permit:array section with subscript.
						*if an allocatable array ,must be allocated.
						*if a pointer, must be associatable.

2. external_file_unit   *must be 0 or positive.

3. connect_spec_list    *only the first connec_spec can haven't keyword 
						 (imply UNIT ),
						*the others must have keyword.
						*keyword can't duplicate.
						*must have UNIT or the first connec_spec hasn't
						 keyword.

4.close_spec_list       *only the first close_spec can haven't keyword          
						 (imply UNIT),the others must have keyword.
						*keyword can't duplicate.
						*must have UNIT or the first  close_spec hasn't
						 keyword.

5. io_control_spec      *must have "io_unit".
						*keyword can't duplicate.
						*only the first,second can omit keyword
						 (first imply UNIT,second imply FMT or NML). 
						*format can't appear with name_list_group_name. 
						*if io_unit is an internal_file_unit, can't have
						 REC.
						*ERR or SIZE must appear with ADVANC.
						*if have REC ,can't have END and anmelist_group_name.
						*if have REC and format ,then format can't be *. 
						*the variable of IOSTAT and SIZE can't associate with
						 any entity in input_item ,output_item  ,namelist_group
						 or do_variable of io_implied_do

6.foramt                *if be label must in the same scope with the current  
						 statement and  must be the label of FORMAT statement.
						*if be a int_variable, it must be assigned to a label
						 which is the label of a FORMAT statement in the same 
						 scope.

7.input_item            *if be varible, it can't be assumed_shape.
						*input_item can't include do_variable, can't 
						 associate with do_variable.
						*item should not duplicate.
						*can't be constant or expression.

8.input_item 
  output_item
						*if be io_implied_do, the do_variable and every expr
						 of io_implied_do_control must be integer,
						 default_real_scalar or default_double_scalar. 
						*if be a point,must be associated with a definable 
						 target
						*if be a allocatable_array, it must beallocated 
						 currently.
						*if io_implied_do embedded ,then  insider 
						 do_variable can't duplicate or associate with 
						 the outsider one.
						*if  be a derived_type, then every element must
						 be accessed and can't be point.
	
9.read_stmt
  write_stmt            *if the file is an internal_file,the input_item
						 or output_item can only  include default_char
						 type.

10. write_stmt          *its io_contrl_spec can't has ERR,EOR,SIZE.
						*output_item_list can't appear with name_list_group
						 in its io_control_spec_list.

11.backspace_stmt,endfile_stmt,rewind_stmt
						*the operating file must be direct_access.
						*if the file is connected with ACTION=READ,
						 then can't processed in ENDFILE statement.
						*the label of ERR in position_spec must be
						 in the same scope with the current statement.
						*only hte first item can omit keyword UNIT.
						*must and only include a external_file_unit.

12.inquire_spec         *must include external_file_unit or file_name_expr
						 and can't include both.
						*only the first can be omitted(imply UNIT)

***********************
all of the expressions in io statement can't include function_call.

13.format_stmt          *must include a label.
			
14.format_item          *r,w,e,n,c  must be positive and can't have 
						 kind_parameter.
						*m,d,k must be 0 or positive and can't have
						 kind_parameter.
						*Iw.m... w>=m
						*Fw.d... w>=d
						*Ew.dEe..  w>=d+e

*******************Program Unit******************

1. executable_program   *must have a unique main_program.
						*only can have one no_named_blockdata.

2.executable_part       *can't include end_program_stmt,end_subroutine_stmt
						 end_funciton_stmt.

3.main_program          *its execution_part can't include RETURN,ENTRY
						 statement.
						*only if include program_Stmt,then end_program_stmt
						 can iclude the same program_name.
						*auto_object can't appear in spec_part.
						*program_name is unique symbol .
						*its spec_part can't include    optional,
						 intent,public,private statment.
						*can't be recurisive.
						*can't call main_program.
			
4.module                *end_module_Stmt can only include module_name
						 same with module_stmt.
						*its spec_part can't include stmr_function_stmt,
						 entry_stmt,format_stmt.
						*spec_part can't include auto_object.
						*module_name is unique symbol.
						*can't use itself directly or indirectly.

5.use_Stmt              *use_name or acccess_id must be the public
						 entity in the refered module.
						*use_name can't duplicate with the local_name of 
						 the current scope. ???
						*the local_name of use_stmt can't appear in the 
						 statement which will change the arrtribute of
						 the local_name except PUBLIC and PRIVATE,can't
						 appear in COMMON and EQUIVALECE.
			
6.block_data            *if end_block_data_stmt include blockdata_name,
						 it must be the same with the name in blockdata_stmt.
						*only can include :type_declaration_stmt, USE,
						 COMMON,DATA,DIMENSION,EQUIVALENCE,INTRINSIC,
						 POINTER,SAVE,TARGET.
						*its type_declaration_stmt can't include:
						 ALLOCATABLE,EXTERNAL,INTENT,OPTIONAL,PRIVATE,PUBLIC.
						*pointer in named_common can't have inital value.
						*different blockdata can't include same named_common.

*******************subprogram*****************
1.internal_subprogram   *can't include ENTRY.
						*its name can't  be argument asssociated  with
						 dummy_procedure. 

2.the condition of interface_block:
						*reference of subprogram the keyword with argument; 
						 is a generic_name;
						 is reloaded opertor,
						*the definition of subprogram
						 optional dummy_argument; the return value
						 function is array, point; the argument is 
						 assumed_array,point,target; 
				
 3.interface_block      *interface_body can't include   entry_Stmr,data_Stmt,
						 format_Stmt,stmt_funciton_stmt.
						*only if the interface_stmt has a generic_spec and 
						 its host is a module or can access a module, then 
						 can include MODULE PROCEDURE declaration and 
						 the procedure_name must be in the  module.
						*can't appear in blockdata.
						*if a subprogram has interface_block,the interface
						 can't declare the subprogram.
						*can't include internal_subprogram and ENTRY.
						*the identity of the interface must concord eith
						 the definition of the subptogram.
						*a subprogram can only have a explicit interface.
						*if the generic is OPERATOR: then the argument 
						 of the function mustn't be optional, must have
						 the attribute of INTENT(IN); the result of function
						 can't be assumed_char;  the number of argument
						 can only be 0 or 2;  the number of argument must 
						 concord with the intrinsic_operator if the operator 
						 is a intrinsic_operator.
						*if the generic_spec is ASSIGNMENT : then the 
						 subprogram must be binary_argument subroutine,
						 the argument can't be optional, the first has
						 the attribute of INTENT(OUT) or INTENT(INOUT),
						 the second has INTENT(IN).

4.external_stmt         *external_name must be external subprogram_name,
						 dummy(subprogram)_name, blocldata_name.
						*a external_name can't be declared external 
						 more than once.
						*if aexternal_subprogram or dummy_subprogram
						 is used as actual_argument, it must be declared
						 EXTERNAL and explicit declare its other attribute
						 or declared in the interface.

5.inteinsic_stmt        *intrinsic_name must be name of intrinsic_procedure
						*if a intrinsic_subprogram is used as actual_argument,
						 it must be declared INTRINSIC . 
						*a name can't be declared intrinsic more than once
						 and can't  be declared both EXTERNAL and INTRINSIC.

6.function_referce,call_stmt
						*reference must be concord with the interface
						 (explicit or implicit).
						*if subprogram interface is implicit,it can't
						 have the form "keyword=actual_arg"
						*every keyword must be the dummy_name in the 
						 explicit interface.
						*the actual_arg of function_reference can't be
						 have the form "*label".
						*if the actual_arg of call_stmt is label,the
						 label must be in the current scope.

7.parameter match:
						*the non_optional arg must have its actual_arg.
						*the actual_arg  can't be defined and impressed
						 in the called subprogram. ( especial array_ref)
						*if different actual_arg have partially 
						 overlapped, the overlapped part can't be defined 
						 or ubdefined  when the subprogram is running;
						 it is same with pointer.
						*if the dummy_arg is dummy_data_object,the 
						 correspondent actual_arg must have the same type
						 and the same kind parameter; 
						 if it isn't default 
						 char,it must  have the same len_para; 
						 if it is default char ,its len_para must less than 
						 or equal to the actual_arg; 
						 it is same with char_Array;
						*if it is a assumed_shape_array,they must have 
						 same rank; if the dummy is explicit_shape_array
						 or assumed_size_array,the rank of the actual must
						 be >= the rank of the dummy.
						*if the dummy is pointer, the actual must be point 
						 and they have same type,kind ,rank.
						*if the dummy is scalar,the actual must be scalar
						 or un_assumed_array_element or substring of a 
						 array_element.
						*if the dummy has the attribuute of OUT  or INOUT,
						 the actual must be definableand can't be array_section.
						*if the dummy is a assumed_shaped_array, the
						 actual mustn't be assumed_size array and can't 
						 be  scalar.

8.parameter match (dummy subprogram)
						*if the dummy is dummy_subprogram, the actual 
						 must be extrenal,module,dummy procedure or the 
						 assigned name of intrinsic_subprogram.
						*the dummy and actual must have same identity.
			
9.parameter match (aeter_return_spec)
						*if the dummy has th e form" * label",the
						 actual must be a label which defined in 
						 the current scope.

10.function_stmt        *if inculde RESULT ,then function can't be 
						 declared in the function body.
						*if include RESULT, then result_name must be
						 different from function_name.
						*internal_function can't include ENTRY, can't
						 include internal_subprogram.
						*the name in the end_function_stmt must be same
						 with the function_name in the function_stmt.
						*if the return value of function is an array or
						 point, this must be declared in the function body.
						*if the function  or the function defined by 
						 ENTRY is referred directly or indireclty,the 
						 function_stmt must include RECURSIVE.
						*if the return value of function is a pointer,
						 it must have been associated before return.
						*must include return_stmt.
						*dummy_arg_name can't be duplicated.

11.subroutine_subprogram
						*must include return_stmt.
						*internal_subroutine can't include ENTRY and
						 internal_subroutine.
						*the name of end_subroutine_stmt must be the same 
						 with the subroutine_name in subroutine_stmt.
						*if subroutine or the subroutine defined by ENTRY
						 is called itself directly or indirectly,then
						 subroutine_stmt must include RECURSIVE.
						*dummy_arg_name can't be duplicated.

12.entry_stmt           *if include RESULT ,entry_name can't be declared
						 in the subprogram.
						*entry only can appear in extrnal_program or 
						 module_subprogram.
						*only if entry_stmt is in a function,it can
						 include RESULT.
						*only if it is in subroutine ,its dummy_arg can
						 include "* label".
						*the result_name must be different from entruy_name.
						*the dummy of entry_stmt only can be used after
						 endtry_stmt except it is declared before.
						*if the summy only appeare in sntry_stmt, it
						 can't be used in expr of stmt_function_stmt.

13.return_stmt          *only in subroutine ,it can include a expr
						 and the valuemust be >=1 and <= the number of
						 the dummy "*".

14.contains_Stmt        *it must appear before the first internal_subprogram
						 or mosule_subprogram.
	
15.stmt_function_stmt   *if include a stmt_function,the used stmt_function
						 must be defined before in the current scope.
						*can't use itself.
						*function_name or dummy_name  must be declared
						 scalar explicitly or implicitly.
						*dummy_arg_name can't be duplicated.
						*it can't be used as subprogram argument.
						*if its expr iinclude function_referrence,
						 the function can't make th edummy redefined 
						 or undefined.

Section 5    HPF Extension

1.  Semantic error

The HPF Extension mainly consists of two parts: 
  
  the data distribution and alignment directives 
  data parallel statements and directives

1.1  Data distribution alignment directives 

For the syntax rules of these directives, please refer to 
"High Performance Fortran Language Specification" Annex B B.3.
In following parts of this document, this book will be referred to
as "HPF Spec" for short.

For these directives, the semantic routine should check the 
following aspects:

1.1.1  Type checking

For detail, please refer to the following constraints:
	"HPF Spec" P170, Ln16 - Ln18
	"HPF Spec" P171, Ln18 - Ln20

1.1.2  Array rank checking

These directives require strict array rank checking. In ALIGN,
the align-source-list must match alignee in rank. In DISTRIBUTE,
the dist-format-list, processor arrangement and distributee must
match in rank, etc. For detail, please refer to the following
constraints:
	"HPF Spec" P171, Ln3 - Ln11, Ln42 - Ln45
								 
1.1.3  Attribute checking

Many attributes are conflicting, a single piece of data can not
has these attributes at the same time. Semantic routine must
ensure these rules. For example, an distributee can not be an
alignee, and an alignee can not be a distributee too. Other
constraints including rules for dynamic data, reallocable data,
and TEMPLATE, etc. For detail, please refer to the following
constraints:
	"HPF Spec" P170, Ln13 - Ln15, Ln47 - Ln48
			   P171, Ln37 - Ln41
			   P172, Ln1 - Ln3
			   P173, Ln6 - Ln11
 
1.1.4  Boundary checking

HPF does not allow the distribution of data exceed the number
of processes in the target processor-arrangement. It also
forbid an alignee to "wrap around" or "extend past the edges"
of an align-target. For data associated with other data through
COMMON or EQUIVALENCE, HPF does not allow the data distribution
cause any scalar data object to be split across more than one 
process.

Semantic routine should check for these boundary violations,
but sometimes this can not be done at compile time. The data
may be dynamically allocated, the align-subscript and the
distribute-format many contain dummy arguments, under these
circumstance, the checking is impossible, but for where no
run-time information is needed, we will check for boundary
violations.

1.1.5  Miscellaneous

There are some other constraints:

Constraints through "HPF Spec" P172 Ln33 to Ln48 ensure that
each align-subscript expression may contain at most one align-
dummy variable and is a linear function of that variable.

Constraints at "HPF Spec" P171 Ln12 to Ln17 and constraints
at "HPF Spec" P172 Ln28 to Ln32 limit the use of "*" in these
directives.

1.2  Data parallel statements and directives

For the syntax rules of these directives, please refer to 
"HPF Spec" Annex B, B.4.

For these statements and directives, the semantic routine 
should check the following aspects:

1.2.1  Type checking

The index-name of FORALL must be a scalar integer variable.
	"HPF Spec" P173 Ln40

1.2.2  Attribute checking

INDEPENDENT directive impose some restriction on variables,
	"HPF Spec" P177 Ln10 - Ln15

1.2.3  Indetermination checking

FORALL must be used with care to ensure it dose not procedure
indeterminate result. The following constraints helps to
prevent indetermination:
	"HPF Spec" P173 Ln36 - Ln38, Ln42 - Ln 43, Ln47 - Ln 48
	"HPF Spec" P174 Ln13 - Ln17

By HPF semantics, a FORALL statement must not assign more 
than one value to any atomic data object. But this constraint
is very hard to check at compile time, since the index space
may be determined only at run-time.

1.2.4  Pure procedure checking

Pure procedure must obey many syntactic constraints to ensure
that it produces no side-effects, that is the only effect of
calling it is to return a result. The following constraints
ensure this rule:
	"HPF Spec" P174 Ln31 - P176 Ln48

However, many checking may have to be defered until the data
and control flow analysis has been performed.
	
2.  Semantic action

The semantic action for HPF extensions focuses on determine
the actual data mapping. Since much information can be obtained
only after the data and control flow analysis, and sometimes
the mapping is not determined until run-time, so here we just
try to do as much as possible, and leave the rest for later
processing.

Since communication analysis depends heavily on flow analysis,
we leave it for later processing.

2.1  Result of semantic action

The semantic action for this part should produce the following
result:

Whenever possible, we will try to determine which elements of
an array resides in which (virtual) processor, and we record 
the data mapping information on AST, so that it can be used to
	a. facilitate communication analysis and optimization
	b. provide a base for visualization of data distribution 

However, as mentioned earlier, this is not always possible.

2.2  Cases can/cannot be processed here

For explicit shaped arrays, if it is a distributee, and its 
distribute-format does not contain dummy argument, we can
determine its distribution at compile time; if it is an
alignee, the align-subscript does not contain dummy argument,
and we can determine the distribution of its align target,
then we determine its distribution too.

For an array defined in subroutine and inherent distribution
or alignment information from callee, sometimes we can 
determine the data distribution after flow analysis, sometimes
nothing can be determined until run-time.

For array allocated dynamically, we can not determine the data
distribution until run-time. And for the same reason, we also 
ignore REALIGN and REDISTRIBUTE now.  

****** end of the document ******