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.

SUBROUTINE without_decl<br />

PRINT *, TTYNAM(6) ! implicit typing is in effect<br />

END SUBROUTINE without_decl<br />

SUBROUTINE with_decl<br />

! declare the return type of TTYNAM<br />

CHARACTER(LEN=80), EXTERNAL :: TTYNAM<br />

PRINT *, TTYNAM(6)<br />

END SUBROUTINE with_decl<br />

BLAS and libU77 libraries<br />

Calling libU77 and BLAS routines<br />

Here are the command lines to compile and execute the program, along with the output from<br />

asamplerun:<br />

$ f90 +U77 call_ttynam.f90<br />

$ a.out<br />

0.0<br />

/dev/pts/0<br />

For information about explicit interface, see “Procedure interface” on page 149. See “Implicit<br />

typing” on page 31 for the rules of implicit typing.<br />

Declaring library routines as EXTERNAL<br />

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

The routine name is passed to a procedure as an actual argument<br />

The routine name is the same as an intrinsic name<br />

The first case applies to both libU77 and BLAS routines. The second applies only to libU77<br />

routines; as shown in Table 12-1, several of the names of libU77 routinesarealsothoseof<br />

intrinsics. Unless you declare these routines with the EXTERNAL attribute, the compiler will<br />

map the call to the intrinsic library.<br />

Table 12-1 libU77 naming conflicts<br />

FLUSH FREE GETARG<br />

GETENV IARGC IDATE<br />

LOC MALLOC SYSTEM<br />

TIME<br />

For example, if a program unit makes a call to FLUSH, the compiler will make a call to the<br />

intrinsic, unless the program unit includes the following statement:<br />

Chapter 12 609

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

Saved successfully!

Ooh no, something went wrong!