HP FORTRAN 77/iX Programmer's Guide MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Programmer's Guide
Table of Contents
HP FORTRAN 77/iX Programmer's Guide
HP FORTRAN 77/iX Programmer's Guide : COPYRIGHT NOTICE
Ch 1. Data Storage
Variable Type
Addressing Mode
The EQUIVALENCE Statement
Equivalence of Array Elements
Equivalence and Multi-Dimensioned Arrays
Equivalence Between Arrays of Different Dimensions
Equivalence of Character Variables
Equivalence in Common Blocks
Equivalence and Data Alignment
HP FORTRAN 77/iX Storage Assignment
Memory Areas
Code Area
Stack Area
Data Area
Memory Area Assignment
Local Variables
Saved Variables
Common Blocks
Summary of the Memory Area Assignment
Ch 2. Formatted Input/Output
List-Directed Statements
List-Directed Input
List-Directed Output
Formatted Statements
Formatted Input
Formatted Output
Variable Format Descriptors
Summary of the Descriptors
Format Specifications
Integer Format Descriptors: I, O, K, @, Z
The Input Field
The Output Field
Real Format Descriptors: F, D, E, G
The Input Field
The Output Field
Character Format Descriptors: A, R
The Input Field
The Output Field
Logical Format Descriptor: L
The Input Field
The Output Field
Repeating Specifications
Correspondence Between the I/O List and Format Descriptors
Monetary Format Descriptor: M
The Input Field
The Output Field
Numeration Format Descriptor: N
The Input Field
The Output Field
Processing New Lines
The / Descriptor
The NL, NN, or $ Descriptor
Format Specifications (continued)
Handling Character Positions
The X Descriptor
The T Descriptor
The TL Descriptor
The TR Descriptor
Handling Literal Data
The ' and " Descriptors
The H Descriptor
Using Scale Factors: The P Descriptor
Printing Plus Signs: The S, SP, and SS Descriptors
Returning the Number of Bytes: The Q Descriptor
Terminating Format Control: The Colon Descriptor
Handling Blanks in the Input Field
The BN Descriptor
The BZ Descriptor
Alternative Methods of Specifying Input/Output
Using the Implied DO Loop
Ch 3. File Handling
Disk Files
Default File Properties
ACCESS='SEQUENTIAL'
FORM='FORMATTED'
STATUS='UNKNOWN'
Reporting File Handling Errors
The STATUS Specifier
The ERR Specifier
The IOSTAT Specifier
Creating a New File Using STATUS='NEW'
Reading From an Existing File Using STATUS='OLD'
Appending to a File
File Access
Sequential Access Files
Direct Access Files
Indexed Sequential Access Files
Unformatted I/O
Unformatted Input
Unformatted Output
Using Formatted and Unformatted Files
Using the INQUIRE Statement
Positioning the File Pointer
The BACKSPACE Statement
The REWIND Statement
The ENDFILE Statement
Example of Using the File Positioning Statements
File Handling Examples
Computing the Mean of Data in a Sequential File
Inserting Data Into a Sorted Sequential File
Internal Files
Reading From an Internal File
Writing to an Internal File
Ch 4. HP FORTRAN 77/iX File Operations
The OPEN Statement Processor
Predefined Units and Files
FTN05
FTN06
FTN01 Through FTN99 (Excluding FTN05 and FTN06)
Creating Files with the OPEN Statement
STATUS='NEW'
STATUS='OLD'
STATUS='SCRATCH'
STATUS='UNKNOWN'
FORM='UNFORMATTED' and FORM='FORMATTED'
ACCESS='SEQUENTIAL'
ACCESS='DIRECT'
Closing Files
Executing the CLOSE Statement
Terminating a Program
Carriage Control Files
Terminals and Line Printers
Disk Files
FILE Equation
Using Magnetic Tapes
Using the File Handling Procedures
FSET Procedure
FNUM Procedure
UNITCONTROL Procedure
Ch 5. Subprograms
Subroutines
Structure of a Subroutine
Invoking Subroutines
Alternate Returns From Subroutines
Functions
Function Subprograms
Statement Functions
Arguments to Subprograms
Passing Constants
Passing Expressions
Passing Character Data
Passing Arrays
Adjustable Dimensions
Assumed-Size Arrays
Multiple Entries into Subprograms
Common Blocks
Blank Common Blocks
Labeled Common Blocks
Block Data Subprograms
Using the SAVE Statement
Ch 6. Writing Efficient Programs
Compile-Time Efficiency
Run-Time Efficiency
Declare Integer and Logical Variables Efficiently
Avoid Using Arrays
Use Efficient Data Types
Avoid Mixed-Mode Expressions
Eliminate Slow Arithmetic Operators
Use Statement Functions
Reduce External References
Combine DO Loops
Eliminate Short DO Loops
Eliminate Common Operations in Loops
Use Efficient IF Statements
Avoid Formatted I/O
Specify the Array Name for I/O
Avoid Using Range Checking
Use Your System Language
Minimize Segment Faults
MPE/iX Run-Time Efficiency Topics
Code Space Efficiency
Use Function Subroutines
Avoid Formatted I/O
Use Character Substrings
Data Space Efficiency
Eliminate Redundant or Unused Variables
Avoid Common Variables
Use INTEGER*2 and LOGICAL*2 Data
Performance Tuning
Grouping Related Routines
Shifting Data from the Data Area to the Stack Area
Integer Overflow Checking
Using the Optimizer
Introduction to the Optimizer
When to Use the Optimizer
Invoking the Optimizer on MPE/iX
Level One Optimization Modules
Branch Optimization Module
Dead Code Elimination Module
Faster Register Allocation Module
Instruction Scheduler Module
Peephole Optimization Module
Level Two Optimization Modules
Advanced Register Allocation Module
Strength Reduction
Common Subexpression Elimination
Constant Folding Module
Loop Invariant Code Motion Module
Store/Copy Optimization Module
Unused Definition Elimination Module
Optimizer Guidelines
HP FORTRAN 77 Optimizer Assumptions
OPTIMIZE Compiler Directive
Flagging Uninitialized Variables
Example
Loop Unrolling
Limits on Use
Example
What to Do If the Optimized Program Fails
Ch 7. Programming for Portability
Restricting Programs to theHP FORTRAN 77 Standard
Using Consistent Data Storage
Use the LONG and SHORT Compiler Directives
Use Length Specifications in All Type Statements
Declare All Variables
Avoid Using the EQUIVALENCE Statement
Declare Common Blocks the Same in Every Program Unit
Initialize Data Before the Algorithm Begins
Avoid Accessing the Representation of Logical Values
Maintain Parameter Type and Length Consistency
Writing Programs That Can Be Easily Modified
Avoiding Unstructured FORTRAN 77 Features
Identifying Nonstandard Features
Avoiding Data Storage Inconsistencies
Using Comments
Using Conditional Compilation Directives
Resolving Incompatibilities between MPE V and MPE/iX: the HP3000_16
The ON Option
The OFF Option
The ALIGNMENT Option
The REALS Option
The STRING_MOVE Option
Ch 8. Interfacing with Other Languages
HP Pascal/iX
Calling HP Pascal/iX from HP FORTRAN 77/iX
Calling HP FORTRAN 77/iX from HP Pascal/iX
HP COBOL II/iX
Calling HP COBOL II/iX from HP FORTRAN 77/iX
Calling HP FORTRAN 77/iX from HP COBOL II/iX
HP C/iX
Notes on HP FORTRAN 77/iX and HP C/iX Types
Files and I/O
Parameter Passing between HP FORTRAN 77 and HP C
Using System Intrinsics
Defining System Intrinsics
Matching Actual and Formal Parameters
Ch 9. Debugging FORTRAN 77 Programs
Using xdb
The Strategy
Program Requirement
Linker and Debugger Interaction
Invoking the Debugger
Exiting the Debugger
Executing Your Program
Viewing the Execution Stack
Viewing the Source File
The View Command
The Window Command
The Move Command
The Search Commands
Viewing Program Data
Listing the Variables
Finding a Variable's Value
Execution Control
Breakpoints
Setting Breakpoints
Recovering from Breakpoints
Deleting Breakpoints
Using Breakpoints for Execution Tracing
Single Step Commands
Additional Debugger Capabilities
Removing Debugging Information
Using HP Toolset/iX
Compiling Programs for HP Toolset/iX
Invoking HP Toolset/iX
Setting Up for Symbolic Debug
When to Use HP Toolset/iX
Running a Program
Setting Breakpoints
Tracing Names
Clearing Breakpoints
Displaying Variables
Modifying Variables
Redoing a Command
Restarting Your Program
Displaying Breakpoints
Using the Trace Facilities
Accessing MPE/iX Debug
Ending Execution of a Program Prematurely
Exiting HP Toolset/iX
INDEX
Index
MPE/iX 5.0 Documentation