scalar_function

Format:
sca*lar_function([float_expr [,float_expr...]]]]])
scalar_function_1([float_expr [,float_expr...]]]]])
scalar_function_2([float_expr [,float_expr...]]]]])
scalar_function_3([float_expr [,float_expr...]]]]])
scalar_function_4([float_expr [,float_expr...]]]]])
Result:
Number
Description:
The user may supply his own program code - written in any language - as a user function, which returns a vector, or as a scalar function which returns a number. The user code has to be linked as a shared image and a logical name definition has to be made before SPECTRA can call it. A scalar function can have at most 5 arguments. The arguments are decoded as floating point numbers. The example below shows a command file which creates a scalar function, compiles it, links it and makes the logical name definition.

Example

 $ 
 $ File: gra_examples:gra_scalar_example.com (VXDESY) 
 $ 
 $ set ver 
 $ create test_function.for 
 c.. 
 c..  n       number of arguments 
 c..  a1..a5  arguments 
 c..   
    function gra_scalar_function( n, a1, a2, a3, a4, a5) 
  
    implicit none 
    real gra_scalar_function 
    integer*4 n 
    real a1, a2, a3, a4, a5 
  
    type *,' gra_scalar_function: n= ', n 
    type *,' waiting 3 seconds...' 
    call lib$wait(3.) 

    gra_scalar_function = n 
    return 
    end 
 $ 
 $ fort test_function 
 $ 
 $ link /shareable=my_dir:test_function test_function,- 
    sys$input/opt 
    cluster=dummy,,,gra_library:gra_tscalar 
    gsmatch=always,0,0 
 $ 
 $  
 $ def gra_scalar_function my_dir:test_function 
 $ set nover 
 $ 
 
 SPECTRA> * = scalar_function(1, 2, 3) 
            -> 3