Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 12 BLAS and libU77 libraries

Calling libU77 and BLAS routines

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

This section discusses considerations pertinent to writing and compiling programs that call libU77 and BLAS routines, including:

  • The compile-line options that make libU77 and BLAS routines available to your programs

  • Declaring the type of return type of library functions

  • Declaring library functions with the EXTERNAL attribute

  • BLAS and libU77 man pages

Compile-line options

The following sections describe the compile-line options to use to access routines from the libU77 and BLAS libraries.

+U77 option

To access libU77 routines, compile with the +U77 option. The entry-point name of each libU77 routine has an appended underscore, which must also be added to the external name of any libU77 routine that your program calls. The +U77 option does this. For example, if your program contains the following call:

CALL FLUSH(unit_no)

compiling with +U77 causes the compiler to generate the external name access_. The +ppu and +uppercase options have no effect on libU77 external names.

-lblas option

To access BLAS routines, compile with the -lblas option. Unlike most compile-line options, the -l option must appear at the end of the command line, following any source files that call BLAS routines. Here is an example command line for compiling do_math.f90 to access BLAS routines:

$ f90 do_math.f90 -lblas

Year-2000 compatibility

Two new libU77 routines (DATEY2K and IDATEY2K, both described in this chapter) are provided in the Fortran 90 compiler to handle
Year-2000 (Y2K) date-related issues on HP-UX 10.x and HP-UX 11.x. The +U77 flag must be used with both of these routines.

Although both are provided for Y2K compliance, it is recommended that the standard DATE_AND_TIME intrinsic be used instead of these functions, when possible.

The guidelines for changing code which uses the date or idate libU77 routines are as follows:

  • In code where date is referenced, replace DATE with DATEY2K. Also, make sure that DATEY2K's argument is at least 11 characters in length.

  • In code where the idate intrinsic (not the libU77 idate routine) is used, replace IDATE with IDATEY2K.

Declaring library functions

Unlike intrinsics, library routines do not have an explicit interface within your program. This means (among other things) that, if the routine is a function, the compiler applies the implicit typing rules to the return value. When these rules are in effect, the return value is likely to be meaningless if the type implied by the function name does not agree with the type of the returned value or if the return type is not explicitly declared within the program unit that calls the routine.

Consider the following program, call_ttynam.f90. The program consists of two subroutines, both of which call the libU77 function TTYNAM. This function returns a character value—the path name of a terminal device associated. But the return type is declared in only one of the subroutines; in the other subroutine, the type is undeclared, and the compiler therefore assumes—applying the rules of implicit typing—that the return value is of type real. The consequences of this assumption are illustrated in the output, below.

Example 12-1 call_ttynam.f90

PROGRAM main
! illustrates the consequences of failure to declare
! the return type of a library function. Both
! subroutines do the same thing--invoke the libU77
! function TTYNAM. But only the second subroutine
! declares the return type of the function.
! This program must be compiled with the +U77 option.

CALL without_decl
CALL with_decl
END PROGRAM main

SUBROUTINE without_decl
PRINT *, TTYNAM(6) ! implicit typing is in effect
END SUBROUTINE without_decl

SUBROUTINE with_decl
! declare the return type of TTYNAM
CHARACTER(LEN=80), EXTERNAL :: TTYNAM

PRINT *, TTYNAM(6)
END SUBROUTINE with_decl

Here are the command lines to compile and execute the program, along with the output from a sample run:

$ f90 +U77 call_ttynam.f90
$ a.out
0.0
/dev/pts/0

For information about explicit interface, see “Procedure interface”. See “Implicit typing” for the rules of implicit typing.

Declaring library routines as EXTERNAL

There are two cases when you should declare a library routine with the EXTERNAL attribute:

  • The routine name is passed to a procedure as an actual argument

  • The routine name is the same as an intrinsic name

The first case applies to both libU77 and BLAS routines. The second applies only to libU77 routines; as shown in Table 12-1 “libU77 naming conflicts”, several of the names of libU77 routines are also those of intrinsics. Unless you declare these routines with the EXTERNAL attribute, the compiler will map the call to the intrinsic library.

Table 12-1 libU77 naming conflicts

FLUSH

FREE

GETARG

GETENV

IARGC

IDATE

LOC

MALLOC

SYSTEM

TIME

 

For example, if a program unit makes a call to FLUSH, the compiler will make a call to the intrinsic, unless the program unit includes the following statement:

EXTERNAL FLUSH

See EXTERNAL (statement and attribute)” for a description of the EXTERNAL statement and attribute. As noted in the description, the attribute form of EXTERNAL cannot be used with subroutines, which must therefore be specified in the statement form.

Man pages

You can get detailed, online information for any libU77 or BLAS routine by using the man command to display an online reference page for that routine. The command-line syntax for the man command is:

man section_number routine_name

where section_number is either 3f (for libU77) man pages or 3x (for BLAS); and routine_name is the name of the libU77 or BLAS routine. For example, to display the man page for the libU77 routine FLUSH, give the command:

$ man 3f flush

To display the man page for the BLAS routine SAXPY, give the command:

$ man 3x saxpy

Two of the BLAS man pages provide general information about the BLAS routines: blas1(3x) describes basic vector operations, and blas2(3x) describes basic matrix operations.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.