HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 5 USING KSAM FILES IN FORTRAN PROGRAMS

CALLING FILE SYSTEM INTRINSICS

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

To the FORTRAN user, some of the file system intrinsics are treated as functions and others as subroutines. A function is called implicitly by being referenced in a FORTRAN statement. A subroutine is called explicitly with the FORTRAN CALL statement. A further distinction is that a function can return a value to the calling program as a functional return, whereas a subroutine can return values only through the parameters (arguments) specified in the call.

To illustrate, the FOPEN intrinsic is called as a function:

 

   FILNUM=FOPEN(FILENAME,%4004L,%101L,-72,DEVICE,KSAMPARAM,,10,,100J) 

When this statement is executed, a value is returned to the integer variable FILNUM. Note that the word CALL is not used. On the other hand, the FWRITE intrinsic is a subroutine that must be called with the CALL statement:

 

   CALL FWRITE(FILNUM,OUTPUT,-72,%OL) 

In order to determine quickly which is which, look up the intrinsic definition in section III; if it has a functional return it should be called as a function, if not it should be called as a subroutine.

MPE/3000 system intrinsics differ from FORTRAN/3000 language procedures: System intrinsics can have optional parameters (arguments) whereas all parameters must be specified in a call to a FORTRAN procedure. Another difference is that parameters can be passed by value to a system intrinsic but they must be passed by reference to a FORTRAN procedure. To pass a parameter by value, use the literal value as a parameter (the parameter -72 in the FOPEN call above); to pass by reference, the value is assigned to a parameter specified as a variable or array name (FILENAME in the FOPEN call).

In order to take advantage of the capabilities of the system intrinsics, you should declare the names of any intrinsics you plan to use in a SYSTEM INTRINSIC statement. This statement must appear as one of the declaration statements that precede executable statements in a FORTRAN/3000 program. For example, if you plan to call FOPEN, FCLOSE, FWRITE, and FCHECK then these intrinsics should be declared in the statement:

 

   SYSTEM INTRINSIC FOPEN,FCLOSE,FWRITE,FCHECK 

Declared in this way, you can then omit optional parameters from the call and pass parameters by value. If you do not declare the intrinsics in a SYSTEM INTRINSIC call, then a function call such as that illustrated above for FOPEN would generate an error because it omits some parameters and passes others by value.

Feedback to webmaster