HP Fortran Programmer's Reference (September 2007)

BLAS and libU77 libraries
Calling libU77 and BLAS routines
Chapter 12644
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