HP 3000 Manuals

SYSTEM INTRINSIC Statement (Nonexecutable) [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

SYSTEM INTRINSIC Statement (Nonexecutable) 

The MPE/iX file SYSINTR.PUB.SYS contains information about the attributes
of subprograms.  These subprograms are usually user-callable system
subprograms, such as FOPEN. All intrinsics mentioned in the MPE/iX
manuals must be accessed through this facility.  The information about a
particular subprogram includes such items as the number and type of
parameters, whether parameters are called by ANYVAR, READONLY, reference,
UNCHECKABLE_ANYVAR, or value, and whether the subprogram parameters have
the options DEFAULT_PARMS, EXTENSIBLE, or both.  See the subsequent
sections for an explanation of the preceding terms.  Note that these
terms relate to the way parameters are declared in HP Pascal/iX
subprograms found in SYSINTR.PUB.SYS. FORTRAN reads the SYSINTR file for
specially designated subprograms and generates the indicated code
sequences.

You can designate that the SYSINTR file is to be searched for a
particular subprogram by using the SYSTEM INTRINSIC statement.

Syntax 

[]
------------------------------------------------------------------------------------ | | | | | Item | Description/Default | Restrictions | | | | | ------------------------------------------------------------------------------------ | | | | | IntrinsicName | The name of the subprogram in | If the name cannot be | | | the SYSINTR file. | found in the SYSINTR | | | | file, an error message | | | | is issued. | | | | | ------------------------------------------------------------------------------------ This facility provides these advantages over the usual way of accessing external subprograms: * Convenient access to routines written in any language is provided. For each such subprogram, the list of actual parameters does not have to be complete. Missing parameters (which must be specified as DEFAULT_PARMS in the intrinsic file) are indicated by commas or a right parenthesis. The occurrence of a right parenthesis before the formal parameter list is exhausted implies the rest of the parameters are missing (which means they are DEFAULT_PARMS or EXTENSIBLE, as specified in the intrinsic file). * The VALUE, REFERENCE, ANYVAR, UNCHECKABLE_ANYVAR, or READONLY attribute of a formal parameter is recognized and the appropriate code for the actual parameter is automatically generated for the call. (An ALIAS compiler directive might otherwise be necessary to indicate how parameters should be passed or the routine might not even be callable because of the parameter type.) Parameter checking is performed at the highest level (level 3 of CHECK_ACTUAL_PARM) at compile time. * Automatic typing of SYSINTR file functions is provided. Thus, the intrinsic mechanism automatically types the function return type for you. For example, the statement SYSTEM INTRINSIC FOPEN, BINARY results in FOPEN being typed INTEGER*2 and BINARY being typed LOGICAL*2. You can also specify that a Pascal intrinsic file other than SYSINTR.PUB.SYS be searched for the subprogram name. This can be done by using the SYSINTR compiler directive. See "SYSINTR Directive" . For information on building Pascal intrinsic files, refer to the HP Pascal Reference Manual. For more information about system intrinsics, see the SYSINTR Compiler Directive. The SYSTEM INTRINSIC statement must appear before any executable statement in the program. The SYSTEM INTRINSIC compiler directive functions exactly the same as the SYSTEM INTRINSIC statement, except that the directive has a global effect. A Value Parameter This is a parameter that is passed by value; that is, a copy of the value of the actual parameter is passed to a routine and assigned to the formal parameter of that routine. If the routine changes the value of the formal parameter, it does not change the value of the actual parameter. An actual value parameter can be a constant, an expression, a variable, or a function result. The need for passing a FORTRAN 77/iX parameter by value arises when you have a system intrinsic that requires a certain parameter be passed by value. For example, the following program calls the system intrinsic HPCICOMMAND, which requires its fourth parameter (0) to be passed by value, and executes the MPE/iX system DATE command. For more information on HPCICOMMAND, read the MPE/iX Intrinsic Reference Manual. Example. $STANDARD_LEVEL SYSTEM ! Display no warnings PROGRAM excommand SYSTEM INTRINSIC HPCICOMMAND CHARACTER*10 command INTEGER*2 cmderror, parmnum command = "DATE"//char(13) CALL HPCICOMMAND(command, cmderror, parmnum, 0) END The program excommand uses the system intrinsic HPCICOMMAND to execute the MPE/iX DATE command. The results from executing the program look similar to this: THU, JAN 16, 1992, 8:41 AM Note that the above example will be referenced in the sections "A Reference Parameter" and "The ANYVAR Parameter and UNCHECKABLE_ANYVAR Option." A Reference Parameter This is a parameter that is passed by reference; that is, the address of the actual parameter is passed to the routine and associated with the formal parameter. If the routine changes the value of the formal parameter, it changes the value of the actual parameter. An actual reference parameter must be a variable name. In FORTRAN 77/iX, all variables are passed by reference except when interfacing with other programming languages and accessing FORTRAN 77/iX system intrinsics. An example of passing parameters by reference can the seen in the section "A Value Parameter." In this example, the parameters cmderror and parmnum are passed by reference back to the calling program. The ANYVAR Parameter and UNCHECKABLE_ANYVAR Option When a parameter in the formal parameter list of an HP Pascal/iX procedure declaration is denoted ANYVAR, it means that a variable of any type can be passed to it as the actual parameter. The address of the actual parameter will be passed and the code in the procedure will access it as the type specified for the formal parameter in the procedure declaration. In this way, intrinsic procedures can be created with the HP Pascal/iX language that accept any type of variable as their actual parameters (assuming data alignment requirements are met). For ANYVAR parameters, the length of the actual parameter must be passed as a "hidden parameter" in the parameter list. Hidden parameters are parameters that do not appear in formal or actual parameter lists, but are nevertheless passed to routines (they are always integers). UNCHECKABLE_ANYVAR is an HP Pascal/iX procedure option that specifies that ANYVAR hidden parameters will not be created for a routine. This allows its parameter list to be compatible with the parameter list of a rountine written in a language other than HP Pascal/iX. An example of an ANYVAR parameter being declared as uncheckable can be found in the section "A Value Parameter." In this example, the ANYVAR parameter command has been declared uncheckable by the HP Pascal/iX UNCHECKABLE_ANYVAR option and no hidden parameters are passed for the ANYVAR parameter. An EXTENSIBLE Parameter EXTENSIBLE is an HP Pascal/iX procedure option that identifies a procedure that has an extensible parameter list. An extensible parameter list has a fixed number of nonextension parameters and a variable number of extension parameters. The integer n after the keyword EXTENSIBLE specifies that the first n parameters in the formal parameter list are nonextension parameters (n can be zero). Any other parameters are extension parameters. A nonextension parameter is required. Every call to the routine must provide an actual parameter for it. An extension parameter is optional. A call to the routine can omit its actual parameter from the actual parameter list. However, if the actual parameter list contains an actual parameter for the xth extension parameter, it must contain actual parameters for those before it. The number of extension parameters in an extensible parameter list is flexible: you can add new ones later, and you need not recompile programs that call the routine. Example. The program in this section uses the intrinsic HPFOPEN to open a file named testfile for reading and displays the file name, number and status. For more information on HPFOPEN, read the MPE/iX Intrinsic Reference Manual. The MPE/iX intrinsic HPFOPEN is extensible and provides default parameters. The extensible parameters in HPFOPEN are: status, itemnum1, item1, itemnum2, and item2. These parameters can be omitted. HPFOPEN's nonextensible parameter is filenum and it cannot be omitted from the actual parameter list unless it has a default value assigned to it (see the section "A DEFAULT_PARMS Parameter"). Note that the parameters itemnum1 and item1 and itemnum2 and item2 must appear in pairs in the actual parameter list of the HPFOPEN intrinsic. Compiling and executing the following program: $STANDARD_LEVEL SYSTEM ! Display no warnings PROGRAM openfile SYSTEM INTRINSIC HPFOPEN INTEGER*4 filenum, status, itemnum1, itemnum2, item2 CHARACTER*20 item1 PARAMETER( itemnum1 = 2, itemnum2 = 11 ) item1 = 'testfile' ! The file name is "testfile" item2 = 0 ! The file "testfile" has READ access CALL HPFOPEN(filenum, status, itemnum1, item1, itemnum2, item2) PRINT '(" File Name : " A20)',item1 PRINT '(" File Number: " I6)',filenum PRINT '(" File Status: " I6)',status PRINT *,CHAR(13) END produces these results: File Name : testfile File Number: 9 File Status: 0 Note that the example in this section is referenced in the section "A DEFAULT_PARMS Parameter." A DEFAULT_PARMS Parameter DEFAULT_PARMS is an HP Pascal/iX procedure option that specifies default values to be assigned to formal parameters when actual parameters are not passed to them. For example, the HPFOPEN intrinsic used in the program in the section "An EXTENSIBLE Parameter" could have the status variable omitted from the parameter list and it would still work. If you replaced the program line: CALL HPFOPEN(filenum, status, itemnum1, item1, itemnum2, item2) with this program line: CALL HPFOPEN(filenum,, itemnum1, item1, itemnum2, item2) you would get the following results: File Name : testfile File Number: 9 File Status: 0 If a nonextension parameter has a default value, its actual parameter can be left out of the actual parameter list, and its default value is assigned to the formal parameter. A default value must be a constant expression that is assignment compatible with its parameter. The value nil is the only legal default for reference, ANYVAR, function or procedure parameters. A READONLY Parameter READONLY is an HP Pascal/iX parameter that protects the actual parameter from modification within an MPE/iX intrinsic procedure that is called from a FORTRAN 77/iX program.


MPE/iX 5.0 Documentation