INHERIT Directive Up: Data Alignment and Previous: PROCESSORS Directive

TEMPLATE Directive

The TEMPLATE directive declares one or more templates, specifying for each the name, the rank (number of dimensions), and the extent in each dimension. It must appear in the specification-part of a scoping unit.

In the language of section 14.1.2 of the Fortran 90 standard, templates are local entities of class (1); therefore a template may not have the same name as a variable, named constant, internal procedure, etc., in the same scoping unit. Template names obey the rules for host and use association as other names in the list in section of the Fortran 90 standard.

A template is simply an abstract space of indexed positions; it can be considered as an ``array of nothings'' (as compared to an ``array of integers,'' say). A template may be used as an abstract align-target that may then be distributed. XBNF template-directive -to -rule to to is TEMPLATE template-decl-list

template-decl -to -rule to to is template-name [ ( explicit-shape-spec-list ) ]

template-name -to -rule to to is object-name XBNF Examples: !HPF$ TEMPLATE B(N,N), C(N,2*N) !HPF$ TEMPLATE, DISTRIBUTE(BLOCK,*) :: & !HPF$ TEMPLATE, DIMENSION(91,91) :: BORED,WHEEZY,PERKY Templates are useful in the particular situation where one must align several arrays relative to one another but there is no need to declare a single array that spans the entire index space of interest. For example, one might want four arrays aligned to the four corners of a template of size : !HPF$ ALIGN NW(I,J) WITH EARTH( I , J ) !HPF$ ALIGN SW(I,J) WITH EARTH(I+1, J ) !HPF$ ALIGN SE(I,J) WITH EARTH(I+1,J+1) Templates may also be useful in making assertions about the mapping of dummy arguments (see Section ).

Unlike arrays, templates cannot be in COMMON. So two templates declared in different scoping units will always be distinct, even if they are given the same name. The only way for two program units to refer to the same template is to declare the template in a module that is then used by the two program units.

Templates are not passed through the subprogram argument interface. The template to which a dummy argument is aligned is always distinct from the template to which the actual argument is aligned, though it may be a copy (see Section ). On exit from a subprogram, an HPF implementation arranges that the actual argument is aligned with the same template with which it was aligned before the call.

Returning from a subprogram causes all templates declared local to that subprogram to become undefined. It is not HPF-conforming for any variable to be aligned to a template at the time the template becomes undefined unless at least one of two conditions holds:

The variable itself becomes undefined at the same time by virtue of returning from the subprogram.

Whenever the subprogram is called, the template is always locally defined in the same way, with identical lower bounds, identical upper bounds, and identical distribution information (if any) onto identically defined processor arrangements (see Section ).

    Rationale. (Note that this second condition is slightly less stringent than requiring all expressions to be constant. This allows calls to NUMBER_OF_PROCESSORS or PROCESSORS_SHAPE to appear without violating the condition.) (End of rationale.)

Variables in COMMON or having the SAVE attribute may be mapped to a locally declared template, but because the first condition cannot hold for such variable (they don't become undefined), the second condition must be observed.

INHERIT Directive Up: Data Alignment and Previous: PROCESSORS Directive
Thu Dec 8 16:17:11 CST 1994