| United States-English |
|
|
|
![]() |
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 12 BLAS
and libU77 librariesCalling libU77 and BLAS routines |
|
This section discusses considerations pertinent to writing and compiling programs that call libU77 and BLAS routines, including:
The following sections describe the compile-line options to use to access routines from the libU77 and BLAS libraries. 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:
compiling with +U77 causes the compiler to generate the external name access_. The +ppu and +uppercase options have no effect on libU77 external names. 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:
Two new libU77 routines (DATEY2K and IDATEY2K, both described in this chapter) are provided
in the Fortran 90 compiler to handle 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:
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
Here are the command lines to compile and execute the program, along with the output from a sample run:
For information about explicit interface, see “Procedure interface”. See “Implicit typing” for the rules of implicit typing. There are two cases when you should declare a library routine with the EXTERNAL attribute:
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.
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:
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. 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:
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:
To display the man page for the BLAS routine SAXPY, give the command:
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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||