02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BLAS and libU77 libraries<br />

Calling libU77 and BLAS routines<br />

Year-2000 compatibility<br />

Two new libU77 routines (DATEY2K and IDATEY2K, both described in this chapter) are<br />

provided in the <strong>Fortran</strong> 90 compiler to handle<br />

Year-2000 (Y2K) date-related issues on <strong>HP</strong>-UX 10.x and <strong>HP</strong>-UX 11.x. The +U77 flag must be<br />

used with both of these routines.<br />

Although both are provided for Y2K compliance, it is recommended that the standard<br />

DATE_AND_TIME intrinsic be used instead of these functions, when possible.<br />

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

608<br />

In code where date is referenced, replace DATE with DATEY2K. Also,makesurethat<br />

DATEY2K's argument is at least 11 characters in length.<br />

In code where the idate intrinsic (not the libU77 idate routine) is used, replace IDATE<br />

with IDATEY2K.<br />

Declaring library functions<br />

Unlike intrinsics, library routines do not have an explicit interface within your program. This<br />

means (among other things) that, if the routine is a function, the compiler applies the implicit<br />

typing rules to the return value. When these rules are in effect, the return value is likely to be<br />

meaningless if the type implied by the function name does not agree with the type of the<br />

returned value or if the return type is not explicitly declared within the program unit that<br />

calls the routine.<br />

Consider the following program, call_ttynam.f90. The program consists of two subroutines,<br />

both of which call the libU77 function TTYNAM. This function returns a character value—the<br />

path name of a terminal device associated. But the return type is declared in only one of the<br />

subroutines; in the other subroutine, the type is undeclared, and the compiler therefore<br />

assumes—applying the rules of implicit typing—that the return value is of type real. The<br />

consequences of this assumption are illustrated in the output, below.<br />

Example 12-1 call_ttynam.f90<br />

PROGRAM main<br />

! illustrates the consequences of failure to declare<br />

! the return type of a library function. Both<br />

! subroutines do the same thing--invoke the libU77<br />

! function TTYNAM. But only the second subroutine<br />

! declares the return type of the function.<br />

! This program must be compiled with the +U77 option.<br />

CALL without_decl<br />

CALL with_decl<br />

END PROGRAM main<br />

Chapter 12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!