Passing Scalar Arguments by Value

A Fortran program compiled with the Intel® Fortran Compiler can pass scalar arguments to a C function by value using the nonstandard built-in function %VAL. The following example shows the Fortran code for passing a scalar argument to C and the corresponding C code.

Example of Passing Scalar Arguments from Fortran to C

Fortran Call
integer i
double precision f, result, argbyvalue
result= argbyvalue(%VAL(I),%VAL(F))
END

C Called Function
double argbyvalue_ (int i,double f)
{
...program text...
return g;
}

In this case, the pointers are not used in C. This method is often more convenient, particularly to call a C function that you cannot modify, but such programs are not always portable.

Note
Arrays, records, complex data, and character data cannot be passed by value.