Converting Data Files from MPE V/E to MPE/iX [ Getting Started as an MPE/iX Programmer Programmer's Guide ] MPE/iX 5.0 Documentation
Getting Started as an MPE/iX Programmer Programmer's Guide
Converting Data Files from MPE V/E to MPE/iX
When converting files from MPE V/E to MPE/iX, you must consider several
differences in data storage, including:
* Floating point differences
* Floating point, single precision differences
* Floating point, double precision differences
* Floating point conversion intrinsic
* HP FORTRAN 77/iX native alignment
* HP Pascal/iX allocation alignment of independent variables
* COBOL II/XL native alignment
MPE/iX has many data type differences from MPE V/E, in terms of concepts
of data storage, differences in data storage techniques, and implications
for the programmer in handling them. For an overview of data conversion,
refer to Introduction to MPE/iX for MPE V Programmers (30367-90005). For
detailed information on MPE/iX data types, refer to Data Types Conversion
Programmer's Guide (32650-90015). It describes the utilities for
converting MPE V/E binary data files to MPE/iX native mode format.
Differences integral to the conversion of MPE V/E data files to MPE/iX
are:
* MPE V/E and MPE/iX data variables and data structures are
different. MPE V/E has a 16-bit native word length and MPE/iX has
a 32-bit word length.
* MPE V/E and MPE/iX floating point formats differ.
MPE/iX is the same as MPE V/E for most data conversions, except for
floating-point decimal numbers. An intrinsic called HPFPCONVERT,
included in MPE/iX, converts floating-point decimal number formats.
Data alignment and real number storage formats differ in MPE/iX from
their MPE V/E implementations.
Data Alignment Differences
MPE V/E and MPE/iX each have a different word size; MPE/iX has a 32-bit
word size, and MPE V/E has a 16-bit word size. Therefore, applications
to be compiled on MPE/iX to run in Native Mode using MPE V/E-compatible
data files, may have to select the HP3000_16 compiler directive that is
provided with Native Mode compilers. This option causes the compiler to:
* Align data in records on 16-bit boundaries (as in MPE V/E),
instead of 32-bit boundaries.
* Selects the MPE V/E representation mode for real numbers.
Many data structures that are aligned on 16-bit boundaries on MPE V/E are
aligned on 32-bit boundaries on MPE/iX. On MPE/iX, 32-bit data types are
aligned on 32-bit boundaries, by default, to improve performance. Figure
1-11 shows the differences in data alignment between MPE V/E and
MPE/iX with an HP FORTRAN 77/iX example.
Figure 1-11. HP FORTRAN 77/iX COMMON Block Data Alignment Example
Native alignment for some HP Pascal/iX, COBOL II/XL, and HP FORTRAN 77/iX
data types is different than that used by languages running on MPE V/E.
For tables comparing alignment by data type, refer to Introduction to
MPE/iX for MPE V Programmers (30367-90005).
If an application uses both native aligned data files and MPE V/E aligned
data files, an alignment directive should be specified in the program
record definitions to force MPE/iX or MPE V/E-aligned records on a
structure-by-structure basis. MPE/iX compilers offer two directives to
specify MPE/iX or MPE V/E alignment, HP3000_32 and HP3000_16. For more
information on these directives, refer to the programmer's guide for the
appropriate language in the Language Series.
NOTE The HP3000_16 compiler directive maintains data alignment and
format compatibility with MPE V/E and impacts the ability to use
Native Mode (NM) data structures. Unless specified otherwise, all
data elements are in the mode of the program or as specified by the
compiler options in effect.
For example, to maintain Compatibility Mode (CM) data alignment and
format and create NM data structures, you should explicitly define
the individual structures to be in NM format as HP3000_32 while
operating under the HP3000_16 compiler directive. The other
alternative is to create a program that will read data in one mode
and write it in the other.
Native Mode (NM) words and integers are different from Compatibility Mode
(CM) words. Table 1-1 shows the proper conversions. In this manual,
NM words are implied, unless a CM prefix is added to a term.
Table 1-1. Word and Integer Conversions
-----------------------------------------------------------------------------------------------
| | | |
| Bits | Native Mode (NM) | Compatibility Mode (CM) |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 16 | 1 halfword or shortint | 1 CM word or integer |
| | | |
- -
| | | |
| 32 | 1 word or integer | 2 CM words, double integers, or |
| | | double words |
| | | |
- -
| | | |
| 64 | 2 words | 4 CM words |
| | | |
-----------------------------------------------------------------------------------------------
Integers in MPE/iX can be 16 or 32 bits long, signed, or unsigned.
Signed integers are in twos complement form. Halfword integers (16-bit)
are stored in memory at even byte addresses, and word integers (32-bit)
at addresses divisible by four.
Real numbers in MPE/iX are stored in one of two floating-point formats.
The two methods of storing floating-point numbers in the MPE/iX
environment are: HP 3000 format, and according to IEEE Task P854. The
default MPE/iX Native Mode (NM) real number representation conforms to
IEEE Task P854. This standard specifies a storage format different than
that used in MPE V/E-based HP 3000 systems. The real number format for a
particular application can be forced to the HP 3000 representation by
specifying the HP3000_16 compiler directive. Since this compiler
directive selects both MPE V/E alignment and real number format, native
aligned data must then be aligned on a per record basis.
A single source module can use only one real number format, but the
HPFPCONVERT intrinsic converts real numbers between the various formats.
Separate (external) procedures may use different formats. The formats
have different precisions and ranges for both single-precision and
double-precision real numbers.
Because of accuracy differences between IEEE and HP 3000 double real
numbers, the least significant digit may be lost in 16-digit real
numbers. Since the HP 3000 double precision range is smaller than the
IEEE double real range, conversion from a very large or small one in IEEE
to one in HP 3000 may cause an overflow or underflow.
For a comparison of the real number representation on MPE V/E and MPE/iX,
refer to Introduction to MPE/iX for MPE V Programmers (30367-90005).
Figure 1-12 and Figure 1-13 show the internal representation for
floating-point numbers on MPE/iX.
Figure 1-12. IEEE Single-precision Real Number Format
Figure 1-13. IEEE Double-precision Real Number Format
Conversion from HP 3000 format to IEEE format for a single-precision real
number can present a range problem, because the IEEE range is smaller.
Thus, overflow can occur in performing either of the following
conversions:
* From an HP 3000 single-precision real number to an IEEE
single-precision real number.
* From an IEEE double-precision real number to an IEEE
single-precision real number.
You may have to develop new error handling code to prevent overflow.
The mantissa of an HP 3000 double-precision real number provides enough
bits for 16 digits of accuracy. The mantissa of an IEEE double-precision
real number provides for 15.9 digits of accuracy. Thus, converting
double-precision real numbers from HP 3000 to IEEE format can incur an
extremely small loss of numeric precision. However, if the requirements
of an application depend on the ASCII representation of floating-point
results, the effect of this accuracy difference can be important.
For example, if a program assumes 16-digit accuracy and requests 16
digits for formatting output, with trailing zero suppression, the number
64.4 appears as 64.4 when the system is running in Compatibility Mode
(CM) and 64.40000000000001 when the system is running in Native Mode
(NM).
Rounding is frequently necessary when formatting output. In HP 3000
format, a number equidistant from two adjacent integers rounds to the
integer of greater magnitude. For example, 1.5 rounds to 2, and 2.5
rounds to 3. In IEEE format, a number equidistant from two adjacent
integers rounds to the integer that has a least significant bit of zero
(in other words, the even integer). For example, 1.5 rounds to 2, and
2.5 also rounds to 2.
Converting Files
General procedures for converting data files from MPE V/E to MPE/iX are
described below. For detailed information on conversion, refer to
Introduction to MPE/iX for MPE V Programmers (30367-90005) or the
appropriate language manual in the Migration Series.
The procedure for converting HP FORTRAN 77 binary files from MPE V/E to
MPE/iX format is as follows:
1. Read data from file in a subroutine with $HP3000_16 ON.
2. Pass the data to a subroutine that has $HP3000_16 OFF.
3. Call the intrinsic HPFPCONVERT to convert REALs from MPE V/E to
MPE/iX floating point format.
4. Write the data out to a new file.
NOTE A subroutine that has $HP3000_16 ON cannot call the HPFPCONVERT
intrinsic.
Pascal on MPE V/E and MPE/iX has the following incompatibilities due to
data alignment:
* MPE V/E and IEEE floating point format
* Data alignment of simple variables and record elements
* String format
* Pointers
COBOL II on MPE V/E and MPE/iX has incompatible indexed and synchronized
data items.
MPE/iX 5.0 Documentation