Download SIMSCRIPT II.5 User`s Manual
Transcript
SIMSCRIPT II.5 User’s Guide let RESULT = FUNC(IN.ARG) write RESULT as "The function result is ", I 10, / It is very important that the SIMSCRIPT II.5 mode of each argument and function matches its FORTRAN type. Here is a list of FORTRAN types and the corresponding SIMSCRIPT II.5 modes: integer*2 integer logical real double precision signed integer2 integer integer real double Calling a FORTRAN routine that returns a real or uses real arguments results in a special case. Unlike SIMSCRIPT II.5 and C, which interpret real/float function results and assignments as 64-bit values, FORTRAN uses a 32-bit value. To obtain this value within a SIMSCRIPT II.5 program, it is necessary to declare the function not as real but as integer and then “equivalence” an integer and real array to interpret the value as real. For example, suppose we wish to call a function named RFUNC, which is written in FORTRAN and has one argument: real function rfunc(inarg) real inarg Declare the function in the preamble as follows: define RFUNC as an integer fortran function To call the function: define IRESULT as a 1-dim integer array define RRESULT as a 1-dim real array write as "Enter the input value:", / read IN.ARG reserve IRESULT(*) as 1 let IRESULT(1) = RFUNC(IN.ARG) let RRESULT(*) = IRESULT(*) write RRESULT(1) as "The function result is", D(10,3),/ 48