HP Fortran for OpenVMS
User Manual


Previous Contents Index

9.5.4 OPTIONS Statement /CONVERT=keyword Method

You can only specify one numeric file format for all unit numbers using this method, unless you also use the logical name or OPEN statement CONVERT specifier method.

You specify the numeric format at compile time and must compile all routines under the same OPTIONS statement CONVERT=keyword qualifier. You could use one source program and compile it using different FORTRAN commands to create multiple executable programs that each read a certain format.

The logical name or OPEN CONVERT specifier methods take precedence over this method. For instance, you might use the logical name or OPEN CONVERT specifier method to specify each unit number that will use a format other than that specified using the FORTRAN command qualifier method. This method takes precedence over the FORTRAN command /CONVERT qualifier method.

You can use OPTIONS statements to specify the appropriate floating-point formats (in memory and in unformatted files) instead of using the corresponding FORTRAN command qualifiers. For example, to use G_float as both the memory format and as the unformatted file format, specify the following OPTIONS statements:


OPTIONS /FLOAT=G_FLOAT 
OPTIONS /CONVERT=NATIVE 

Because this method affects all unit numbers, you cannot read data in one format and write it in another format using the FORTRAN/CONVERT=keyword method alone, unless you use it in combination with the logical name method or the OPEN statement CONVERT keyword method to specify a different format for a particular unit number.

For More Information:

On the OPTIONS statement, see the HP Fortran for OpenVMS Language Reference Manual.

9.5.5 FORTRAN Command /CONVERT=keyword Qualifier Method

You can specify only one numeric format for all unit numbers by using the FORTRAN command qualifier method, unless you also use the logical name method or CONVERT specifier method. You specify the numeric format at compile time and must compile all routines under the same /CONVERT=keyword qualifier (or the equivalent OPTIONS statement). If needed, you can use one source program and compile it using different FORTRAN commands to create multiple executable programs that each read a certain format.

The other methods take precedence over this method. For instance, you might use the logical name or OPEN CONVERT specifier method to specify each unit number that will use a format other than that specified using the FORTRAN command qualifier method.

For example, the following DCL commands compile program FILE.F90 to use VAX D_float and F_float data. Data is converted between the file format and the little endian memory format (little endian integers, S_float and T_float little endian IEEE floating-point format). The created file, VAXD_CONVERT.EXE, is then run:


$ FORTRAN/FLOAT=IEEE_FLOAT /CONVERT=VAXD/OBJECT=VAXD_CONVERT.OBJ FILE.F90
$ LINK VAXD_CONVERT
$ RUN VAXD_CONVERT

Because this method affects all unit numbers, you cannot read or write data in different formats if you only use the FORTRAN /CONVERT=keyword method. To specify a different format for a particular unit number, use the FORTRAN /CONVERT=keyword method in combination with the logical name method or the OPEN statement CONVERT specifier method.

9.6 Additional Information on Nonnative Data

The following notes apply to porting nonnative data:

For More Information:

Note

1 American National Standard Fortran 90, ANSI X3.198-1991, and International Standards Organization standard ISO/IEC 1539:1991


Chapter 10
Using HP Fortran in the Common Language Environment

This chapter describes:

10.1 Overview

HP Fortran provides you with a variety of mechanisms for gaining access to procedures and system services external to your HP Fortran programs. By including CALL statements or function references in your source program, you can use procedures such as mathematical functions, OpenVMS system services, and routines written in such languages as Compaq Fortran 77 and HP C.

The HP Fortran compiler operates within the OpenVMS common language environment, which defines certain calling procedures and guidelines. These guidelines allow you to use HP Fortran to call OpenVMS system or library routines and routines written in different languages (usually called mixed-language programming).

This chapter provides information on the OpenVMS procedure-calling standard and how to access OpenVMS system services.

For More Information:

About calling and using the RMS (Record Management Services) system services, see Chapter 11.

10.2 HP Fortran Procedures and Argument Passing

The bounds of the main program are usually defined by using PROGRAM and END or END PROGRAM statements. Within the main program, you can define entities related to calling a function or subroutine, including modules and interface blocks.

A function or subroutine is considered a subprogram. A subprogram can accept one or more data values passed from the calling routine; the values are called arguments.

There are two types of arguments:

The following methods define the interface between procedures:

For More Information:

On the HP Fortran language, including statement functions and defined assignment statements not described in this manual, see the HP Fortran for OpenVMS Language Reference Manual.

10.2.1 Explicit and Implicit Interfaces

An explicit interface occurs when the properties of the subprogram interface are known within the scope of the function or subroutine reference. For example, the function reference or CALL statement occurs at a point where the function or subroutine definition is known through host or use association. Intrinsic procedures also have an explicit interface.

An implicit interface occurs when the properties of the subprogram interface are not known within the scope of the function or subroutine reference. In this case, the procedure data interface is unknown to the compiler. For example, external routines (EXTERNAL statement) that have not been defined in an interface block have an implicit interface.

In most cases, you can use a procedure interface block to make an implicit interface an explicit one. An explicit interface provides the following advantages over an implicit interface:

For More Information:

On HP Fortran array descriptors, see Section 10.2.7.

10.2.2 Types of HP Fortran Subprograms

There are three major types of subprograms:

10.2.3 Using Procedure Interface Blocks

Procedure interface blocks allow you to specify an explicit interface for a subprogram as well as to define generic procedure names. This section limits discussion to those interface blocks used to provide an explicit subprogram interface. For complete information on interface blocks, see the HP Fortran for OpenVMS Language Reference Manual.

The components of a procedure interface block follow:

For an example of a module that contains a procedure interface block, see Section 1.4.

10.2.4 Passing Arguments and Function Return Values

HP Fortran uses the same argument-passing conventions as Compaq Fortran 77 on OpenVMS Alpha systems for non-pointer scalar variables and explicit-shape and assumed-size arrays.

When calling HP Fortran subprograms, be aware that HP Fortran expects to receive arguments the same way it passes them.

The main points about argument passing and function return values are as follows:

The arguments passed from a calling routine must match the dummy arguments declared in the called function or subroutine (or other procedure), as follows:

For More Information:

10.2.5 Passing Arrays as Arguments

Certain arguments or function return values require the use of an explicit interface, including assumed-shape dummy arguments, pointer dummy arguments, and function return values that are arrays. This is discussed in the HP Fortran for OpenVMS Language Reference Manual.

When passing arrays as arguments, the rank and the extents (number of elements in a dimension) should agree, so the arrays have the same shape and are conformable. If you use an assumed-shape array, the rank is specified and extents of the dummy array argument are taken from the actual array argument.

If the rank and extent (shape) do not agree, the arrays are not conformable. The assignment of elements from the actual array to the noncomformable (assumed-size or explicit-shape) dummy array is done by using array element sequence association.

Certain combinations of actual and dummy array arguments are disallowed.

For More Information:

Note

1 For compatibility with older Compaq Fortran 77 OpenVMS VAX programs, character constant actual arguments (string literals) can be passed by reference if the HP Fortran program was compiled with the /BY_REF_CALL qualifier (see Section 2.3.9).


Previous Next Contents Index