[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

B.12.3 References to Record Fields

References to record fields must correspond to the kind of field being referenced. Aggregate field references refer to composite structures (and substructures). Scalar field references refer to singular data items, such as variables.

An operation on a record can involve one or more fields.

Record field references take one of the following forms:

Aggregate Field Reference


  • record-name [.aggregate-field-name]...

Scalar Field Reference


  • record-name [.aggregate-field-name]... .scalar-field-name

record-name

Is the name used in a RECORD statement to identify a record.

aggregate-field-name

Is the name of a field that is a substructure (a record or a nested structure declaration) within the record structure identified by the record name.

scalar-field-name

Is the name of a data item (having a data type) defined within a structure declaration.

Rules and Behavior

Records and record fields cannot be used in DATA statements, but individual fields can be initialized in the STRUCTURE definition.

An automatic array cannot be a record field.

A scalar field reference consists of the name of a record (as specified in a RECORD statement) and zero or more levels of aggregate field names followed by the name of a scalar field. A scalar field reference refers to a single data item (having a data type) and can be treated like a normal reference to a Fortran variable or array element.

You can use scalar field references in statement functions and in executable statements. However, they cannot be used in COMMON, SAVE, NAMELIST, or EQUIVALENCE statements, or as the control variable in an indexed DO-loop.

Type conversion rules for scalar field references are the same as those for variables and array elements.

An aggregate field reference consists of the name of a record (as specified in a RECORD statement) and zero or more levels of aggregate field names.

You can only assign an aggregate field to another aggregate field (record = record) if the records have the same structure. HP Fortran supports no other operations (such as arithmetic or comparison) on aggregate fields.

HP Fortran requires qualification on all levels. While some languages allow omission of aggregate field names when there is no ambiguity as to which field is intended, HP Fortran requires all aggregate field names to be included in references.

You can use aggregate field references in unformatted I/O statements; one I/O record is written no matter how many aggregate and array name references appear in the I/O list. You cannot use aggregate field references in formatted, namelist, and list-directed I/O statements.

You can use aggregate field references as actual arguments and record dummy arguments. The declaration of the dummy record in the subprogram must match the form of the aggregate field reference passed by the calling program unit; each structure must have the same number and types of fields in the same order. The order of map fields within a union declaration is irrelevant.

Records are passed by reference. Aggregate field references are treated like normal variables. You can use adjustable arrays in RECORD statements that are used as dummy arguments.

Note

Because periods are used in record references to separate fields, you should not use relational operators (.EQ., .XOR.), logical constants (.TRUE., .FALSE.), and logical expressions (.AND., .NOT., .OR.) as field names in structure declarations.

Examples

The following examples show record and field references. Consider the following structure declarations:

Structure DATE:


STRUCTURE /DATE/
  INTEGER*1  DAY, MONTH
  INTEGER*2  YEAR
END STRUCTURE

Structure APPOINTMENT:


STRUCTURE /APPOINTMENT/
  RECORD /DATE/     APP_DATE
  STRUCTURE /TIME/  APP_TIME(2)
    INTEGER*1       HOUR, MINUTE
  END STRUCTURE
  CHARACTER*20      APP_MEMO(4)
  LOGICAL*1         APP_FLAG
END STRUCTURE

The following RECORD statement creates a variable named NEXT_APP and a 10-element array named APP_LIST. Both the variable and each element of the array take the form of the structure APPOINTMENT.


RECORD /APPOINTMENT/ NEXT_APP,APP_LIST(10)

Each of the following examples of record and field references are derived from the previous structure declarations and RECORD statement:

Aggregate Field References

  • The record NEXT_APP:


    NEXT_APP
    
  • The field APP_DATE, a 4-byte array field in the record array APP_LIST(3):


    APP_LIST(3).APP_DATE
    

Scalar Field References

  • The field APP_FLAG, a LOGICAL field of the record NEXT_APP:


    NEXT_APP.APP_FLAG
    
  • The first character of APP_MEMO(1), a CHARACTER*20 field of the record NEXT_APP:


    NEXT_APP.APP_MEMO(1)(1:1)
    

For More Information:

B.12.4 Aggregate Assignment

For aggregate assignment statements, the variable and expression must have the same structure as the aggregate they reference.

The aggregate assignment statement assigns the value of each field of the aggregate on the right of an equal sign to the corresponding field of the aggregate on the left. Both aggregates must be declared with the same structure.

Examples

The following example shows valid aggregate assignments:


STRUCTURE /DATE/
  INTEGER*1 DAY, MONTH
  INTEGER*2 YEAR
END STRUCTURE

RECORD /DATE/ TODAY, THIS_WEEK(7)
STRUCTURE /APPOINTMENT/
  ...
  RECORD /DATE/ APP_DATE
END STRUCTURE

RECORD /APPOINTMENT/ MEETING

DO I = 1,7
  CALL GET_DATE (TODAY)
  THIS_WEEK(I) = TODAY
  THIS_WEEK(I).DAY = TODAY.DAY + 1
END DO
MEETING.APP_DATE = TODAY


Appendix C
ASCII and DEC Multinational Character Sets

This appendix describes the ASCII and DEC Multinational character sets that are available on OpenVMS systems.

For details on the Fortran 95/90 character set, see Section 2.2.

C.1 ASCII Character Set

Figure C-1 represents the ASCII character set (characters with decimal values 0 through 127). The first half of each of the numbered columns identifies the character as you would enter it on a terminal or as you would see it on a printer. Except for SP and HT, the characters with names are nonprintable. In Figure C-1, the characters with names are defined as follows:

NUL Null DC1 Device Control 1 (XON)
SOH Start of Heading DC2 Device Control 2
STX Start of Text DC3 Device Control 3 (XOFF)
ETX End of Text DC4 Device Control 4
EOT End of Transmission NAK Negative Acknowledge
ENQ Enquiry SYN Synchronous Idle
ACK Acknowledge ETB End of Transmission Block
BEL Bell CAN Cancel
BS Backspace EM End of Medium
HT Horizontal Tab SUB Substitute
LF Line Feed ESC Escape
VT Vertical Tab FS File Separator
FF Form Feed GS Group Separator
CR Carriage Return RS Record Separator
SO Shift Out US Unit Separator
SI Shift In SP Space
DLE Data Link Escape DEL Delete

The remaining half of each column identifies the character by the binary value of the byte; the value is stated in three radixes---octal, decimal, and hexadecimal. For example, the uppercase letter A has, under ASCII conventions, a storage value of hexadecimal 41 (a bit configuration of 01000001), equivalent to 101 in octal notation and 65 in decimal notation.

Figure C-1 Graphic Representation of the ASCII Character Set


C.2 DEC Multinational Character Set

The ASCII character set comprises the first half of the DEC Multinational Character Set. Figure C-2 represents the second half of the DEC Multinational Character Set (characters with decimal values 128 through 255). The first half of each of the numbered columns identifies the character as you would see it on a terminal or printer (these characters cannot be output on some older terminals and printers). The characters with names are nonprintable. In Figure C-2, the characters with names are defined as follows:

IND Index PU1 Private Use 1
NEL Next Line PU2 Private Use 2
SSA Start of Selected Area STS Set Transmit State
ESA End of Selected Area CCH Cancel Character
HTS Horizontal Tab Set MW Message Waiting
HTJ Horizontal Tab Set with Justification SPA Start of Protected Area
VTS Vertical Tab Set EPA End of Protected Area
PLD Partial Line Down CSI Control Sequence Introducer
PLU Partial Line Up ST String Terminator
RI Reverse Index OSC Operating System Command
SS2 Single Shift 2 PM Privacy Message
SS3 Single Shift 3 APC Application
DCS Device Control String    

The shaded boxes in Figure C-2 indicate positions that are not part of the character set.

Figure C-2 Graphic Representation of the DEC Multinational Extension to the ASCII Character Set



Appendix D
Data Representation Models

Several of the numeric intrinsic functions are defined by a model set for integers (for each integer kind used) and reals (for each real kind used). The bit functions are defined by a model set for bits (binary digits). This appendix describes these models.

For more information on the range of values for each data type (and kind), see the HP Fortran for OpenVMS User Manual.

D.1 Model for Integer Data

In general, the model set for integers is defined as follows:
i = s x <sum symbol><limits symbol>k=1q w_k x rk-1

The following values apply to this model set:

  • i is the integer value.
  • s is the sign (either +1 or --1).
  • q is the number of digits (a positive integer).
  • r is the radix (an integer greater than 1).
  • wk is a nonnegative number less than r.

The model for INTEGER(4) is as follows:
i = s x <sum symbol><limits symbol>k=131 w_k x 2k-1

The following example shows the general integer model for i = --20 using a base (r) of 2:

i = (-1) x (0 x 20 + 0 x 21 + 1 x 22 + 0 x 23 + 1 x 24)
i = (-1) x (4 + 16)
i = -1 x 20
i = -20

D.2 Model for Real Data

The model set for reals, in general, is defined as one of the following:
x = 0

x = s x be x <sum symbol><limits symbol>k=1p f_k x b-k
The following values apply to this model set:

  • x is the real value.
  • s is the sign (either +1 or --1).
  • b is the base (real radix; an integer greater than 1).

  • p is the number of mantissa digits (an integer greater than 1). The number of digits differs depending on the real format, as follows:
    IEEE S_floating 24
    VAX F_floating 24
    IEEE T_floating 53
    VAX D_floating 53 1
    VAX G_floating 53

    1The memory format for VAX D_floating format is 56 mantissa digits, but computationally it is 53 digits. It is considered to have 53 digits by HP Fortran.

  • e is an integer in the range emin to emax, inclusive. This range differs depending on the real format, as follows:
      emin emax
    IEEE S_floating --125 128
    VAX F_floating --127 127
    IEEE T_floating --1021 1024
    VAX D_floating --127 127
    VAX G_floating --1023 1023
  • fk is a nonnegative number less than b (f1 is also nonzero).

For x = 0 , its exponent e and digits fk are defined to be zero.

The model set for single-precision real (REAL(4)) is defined as one of the following:
x = 0


x = s x 2e x <left symbol><sum symbol><limits symbol>k=224 f_k x 2-k<right symbol> -125 <= e <= 128

The following example shows the general real model for x = 20.0 using a base (b) of 2:

x = 1 x 25 x (1 x 2-1 + 0 x 2-2 + 1 x 2-3)
x = 1 x 32 x (.5 + .125)
x = 32 x (.625)
x = 20.0

D.3 Model for Bit Data

The model set for bits (binary digits) interprets a nonnegative scalar data object of type integer as a sequence, as follows:
j = <sum symbol><limits symbol>k=0s-1 w_k x 2k
The following values apply to this model set:

  • j is the integer value.
  • s is the number of bits.
  • wk is a bit value of 0 or 1.

The bits are numbered from right to left beginning with 0.

The following example shows the bit model for j = 1001 (integer 9) using a bit number (s) of 4:

1 0 0 1
<swarrow symbol> <downarrow symbol> <downarrow symbol> <searrow symbol>
w_3 w_2 w_1 w_0
j = (w_0 x 20) + (w_1 x 21) + (w_2 x 22) + (w_3 x 23)
j = 1 + 0 + 0 + 8
j = 9


Previous Next Contents Index