Changed Features [ HP FORTRAN 77/iX Migration Guide ] MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Migration Guide
Changed Features
Some features are implemented differently in HP FORTRAN 77/V and HP
FORTRAN 77/iX. These are explained below.
Word Size
The main difference affecting conversion from HP FORTRAN 77/V to HP
FORTRAN 77/iX is word size. The machine word size on computers running
the MPE V operating system is 16 bits, while that on computers running
MPE/iX is 32 bits. Because of the 32-bit word size, programs declaring
data items to be INTEGER*2 run slower on HP FORTRAN 77/iX than programs
declaring them to be INTEGER*4. (A feature that improves performance in
HP FORTRAN 77/V may decrease it in HP FORTRAN 77/iX.)
NOTE Data items declared as INTEGER default to 32 bits in both FORTRAN
77/V and HP FORTRAN 77/iX (unless the SHORT compiler directive is
used, which makes INTEGER data items 16 bits).
Floating-Point Data
HP FORTRAN 77/iX represents data items of types REAL, DOUBLE PRECISION,
COMPLEX, and DOUBLE COMPLEX with the IEEE floating-point standard. HP
FORTRAN 77/V uses a proprietary HP 3000 floating-point format for these
items.
Uninitialized Variables
The MPE/iX Link Editor does not initialize stack space for all variables
as the Segmenter does on MPE V. Therefore, uninitialized variables that
do not cause problems on MPE V may cause programs to abort on MPE/iX
based systems. To avoid this, ensure that all variables are properly
initialized.
Alignment
The default alignment of data items larger than 16 bits is different in
HP FORTRAN 77/iX and HP FORTRAN 77/V. The term alignment here refers to a
data item's position in memory relative to the adjacent word boundaries.
For example, in both versions of HP FORTRAN 77 an INTEGER*4 variable is
aligned by default on a word boundary in both versions of HP FORTRAN 77.
Therefore, the alignment is on a 16-bit boundary in HP FORTRAN 77/V and
on a 32-bit boundary in HP FORTRAN 77/iX (see Figure 8-1 ). The
compiler accomplishes the alignment by leaving "holes" (unallocated
memory locations) where necessary in the allocated memory space of a
program. Consider the following declarations:
INTEGER*4 i4
CHARACTER*5 ch5
INTEGER*2 i2
REAL*8 d8
Figure 8-1 compares how these data items might be allocated in memory
in HP FORTRAN 77/V and in HP FORTRAN 77/iX:
Figure 8-1. Data Alignment Comparison
In Figure 8-1 , both versions of HP FORTRAN 77 assign the first hole
in the same position after the character variable, because the following
data item, which is declared as an INTEGER*2, is 16-bit aligned in both.
HP FORTRAN 77/iX assigns a second hole to align the double precision
variable D8 on a double-word (64-bit) boundary. In HP FORTRAN 77/V, on
the other hand, double precision items need only be word (16-bit)
aligned. In the absence of an EQUIVALENCE statement, the compiler leaves
these holes and allocates memory to align each variable optimally.
An EQUIVALENCE statement can attempt to force illegal alignments. For
example:
CHARACTER ch(12)
INTEGER*4 i, j
EQUIVALENCE (ch(1), i), (ch(6), j)
is illegal in both FORTRAN 77/V and HP FORTRAN 77/iX, because it attempts
to align j on an 8-bit boundary (by forcing an equivalence between j and
the sixth element of ch).
However, the following:
CHARACTER ch(12)
INTEGER*4 i, j
EQUIVALENCE (ch(1), i), (ch(7), j)
is legal in HP FORTRAN 77/V, but not in HP FORTRAN 77/iX, because it
forces j to be aligned on a 16-bit boundary (by forcing an equivalence
between j and the seventh element of ch), instead of on the 32-bit
boundary dictated by HP FORTRAN 77/iX. The compiler responds to illegal
alignment requests with the error message
ILLEGAL OR INCONSISTENT EQUIVALENCE STATEMENT
However, HP FORTRAN 77/iX allows the above use of EQUIVALENCE if the
HP3000_16 ON or HP3000_16 ALIGNMENT compiler directive is used.
The change in alignment requirements affects items that are equivalenced
differently from MPE/iX defaults. The following table shows all nine
data types and their alignment requirements in HP FORTRAN 77/V and HP
FORTRAN 77/iX:
Table 8-1. Data Alignment on HP FORTRAN 77/V and HP FORTRAN 77/iX
-----------------------------------------------------------------------------
| | | |
| Data Type | HP FORTRAN 77/V | HP FORTRAN 77/iX |
| | | |
-----------------------------------------------------------------------------
| | | |
| REAL*8 | 16 bits | 64 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| COMPLEX*16 | 16 bits | 64 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| COMPLEX*8 | 16 bits | 32 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| REAL*4 | 16 bits | 32 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| INTEGER*4 | 16 bits | 32 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| LOGICAL*4 | 16 bits | 32 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| INTEGER*2 | 16 bits | 16 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| LOGICAL*2 | 16 bits | 16 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| Character | 8 bits | 8 bits |
| | | |
-----------------------------------------------------------------------------
| | | |
| Common | 16 bits | 64 bits |
| | | |
-----------------------------------------------------------------------------
Loading or storing data items that are not aligned on MPE/iX default
boundaries as shown in this table requires the compiler to generate
special code sequences to adjust for the differences in alignment. The
HP3000_16 ALIGNMENT directive turns on generation of these sequences and
allows equivalences that would otherwise be illegal in MPE/iX.
Common Blocks
Alignment also becomes an issue when common blocks are defined
differently between program units. The compiler is required to allocate
the items in a common block in the order of their occurrence in the
COMMON statement. Holes are inserted in the allocated common area to
align each variable according to its declared data type. If the type
declarations for the variables in a given common block vary between
program units, the holes may vary in size, according to the data types of
the surrounding variables. Therefore, what was a size match for two
definitions on MPE V may match a variable with a hole on MPE/iX. If the
type definitions vary between the program units of a common block, the
program may not be portable between machines with different alignment
rules. Fortunately, this is not a common practice.
Here is an example showing alignment differences for common block
variables in two program units. The declarations
SUBROUTINE sub1
COMMON /blk1/ch,int4
CHARACTER ch
INTEGER*4 int4
produce the allocations shown below on MPE V and MPE/iX:
The declarations
SUBROUTINE sub2
COMMON /blk1/ch,int2
CHARACTER ch
INTEGER*2 int2
produce the allocations shown below on MPE V and MPE/iX:
In the allocations above, note that for the common block blk1, int2
overlays int4 on MPE V but on MPE/iX int2 overlays two unallocated bytes.
Using the HP3000_16 ALIGNMENT option would resolve this alignment
problem.
SYSTEM INTRINSIC Statement
Programs using the SYSTEM INTRINSIC statement to call MPE/iX intrinsic
functions that are incompatible with their MPE V counterparts (MYCOMMAND,
CREATEPROCESS, etc.) must modify the calls to those intrinsics. The
changed intrinsics generally store procedure labels or addresses in
16-bit variables; these items are 32 bits in MPE/iX. Refer to the MPE/iX
Intrinsics Reference Manual and the Application Migration Guide when
using these intrinsics.
SEGMENT and LOCALITY Directives
The LOCALITY directive of FORTRAN 77/iX serves as a synonym for the
SEGMENT directive of FORTRAN 77/V. The SEGMENT directive is also retained
in FORTRAN 77/iX for compatibility with FORTRAN 77/V.
See "LOCALITY Directive" later in this chapter for more information.
SYSINTR Directive
The MPE V directive SPLINTR has been replaced in MPE/iX by SYSINTR.
Overlapping Character Substring Moves
FORTRAN 77/V allows overlapping character substring moves to have a
ripple effect; FORTRAN 77/iX does not allow this ripple effect. For
example, the following code has a different result on FORTRAN 77/V and
FORTRAN 77/iX:
character ch*10
ch(1:1) = '*'
ch(2:10) = ch(1:9)
On FORTRAN 77/V, the character string ch is filled with asterisks (*).
On FORTRAN 77/iX, the first and second positions contain asterisks and
the remainder of the string is undefined.
If your FORTRAN 77/V program takes advantage of the ripple effect of
overlapping character substring moves, use the STRING_MOVE option with
the HP3000_16 directive. (See the section "HP3000_16 Directive" later in
this chapter for more information.) If the STRING_MOVE option is used
and there are overlapping character substrings, the string is moved one
character at a time. If STRING_MOVE is not used, a fast move is done.
Therefore, to increase performance, do not use the STRING_MOVE option if
your program does not take advantage of the ripple effect of character
substring moves.
MPE/iX 5.0 Documentation