next up previous index
Next: COMIS source files and Up: No Title Previous: Input/Output unit numbers


Obtaining the values of actual arguments

A group of routines to handle actual arguments is provided by COMIS. These routines allow the user These routines can be used at the COMIS level or at the Fortran one, if the user's routine was called from the COMIS level.

The number of actual arguments, NPAR, can be obtained with:

NPAR = CSNPAR(DUMMY)

The type and mode of the K-th argument can be obtained by:

IT=CSKPAR(K,MODE)

where   IT=0    unknown              MODE=0   unknown
     1    integer                   1   expression
     2    real                      2   constant
     3    character                 3   variable
     4    logical                   4   array element
     5    double precision          5   function call
     6    Hollerith                 6   array name
                                    7   external
                                    8   [sequence of statements]
                                    9   omitted (empty) argument

The value of the Kth argument or the execution of its code is obtained by:

CALL CSCPAR (K)
In fact this subroutine fills the system COMMON block CSWPAR, whose definition is described below:

 DOUBLE PRECISION DVPAR
 COMMON/CSWPAR/LORN,IREP,NPAR,ITPAR,MDPAR,JRESP,JCHPAR,NCHPAR,IVPAR,RVPAR,DVPAR,JCHVP,NCHVP
where

LORN
is set by the user. It specifies the manner of argument processing:
0
ordinary Fortran-like processing, i.e. the value of the argument is taken immediately using the argument address.
1
ALGOL-like processing ``by name'': the argument is re-evaluated as if it was in the routine's text at that point.
IREP
the reply word: 1 - o.k.; less or equal 0 - error.
NPAR
the number of actual arguments.
ITPAR
the type of the argument.
MDPAR
the mode of the argument .
JRESP
the address of the argument's value.
JCHPAR
the 'character' address
NCHPAR
the length of the argument's text.
IVPAR
the integer value of the argument.
RVPAR
the real value of the argument.
DVPAR
the double precision value of the argument.
JCHVP
the 'character' address
NCHVP
the length of the character type argument.
To obtain the value of the integer type argument the next integer function may be used:

I=CSIPAR(K)

To obtain the value of the real type argument the next function may be used:

R=CSRPAR(K)
These two latter functions call subroutine CSCPAR internally.

Examples:

Using an Algol-like manner of argument processing.

  FUNCTION SUM(P1,I,N)
  SUM=0.
  DO I=1,N  SUM=SUM+CSRPAR(1) OD
  END
The COMIS main program   .....
  LORN=1  I=1  S=SUM(A(I),I,N) END  produces  S=A(1)+A(2)+ ... +A(N)

while the program
  .....
  LORN=1  K=1  S=SUM(A(I,K)*B(K,J),K,M) END produces the (I,J)th inner product of A and B.

The length of the K-th argument's text can be obtained by

L=CSLPAR(K)

The K-th argument's text can be moved into a variable of character type by

CALL CSTPAR (K,CHARVAR)

The code of the K-th argument with the mode "sequence of statements" can be stored in the COMIS internal buffer as the COMIS routine with given name NAME by

CALL CSSPAR CSSPAR(K,'NAME',IADP)
where output parameter IADP is the address of the COMIS routine.


next up previous index
Next: COMIS source files and Up: No Title Previous: Input/Output unit numbers
Back to CERN | IT | ASD | CERN Program Library Home
MG (last mod. 1998-08-19)