External types are used when the dimension of the Fortran variable is unknown when calling the Fortran subroutine and when its memory size is allocated in this subroutine. This dimension must be an output of the Fortran subroutine. In fact, this will typically happen when we want to interface a C function in which memory is dynamically allocated.
Existing external types:
In fact, the name of an external type corresponds to the name of a C function. This C function has three arguments: the dimension of the variable, an input pointer and an output pointer.
For instance, below is the code for external type cintf:
#include "../machine.h" /* ip is a pointer to a Fortran variable coming from SCILAB which is itself a pointer to an array of n integers typically coming from a C function cintf converts this integer array into a double array in op moreover, pointer ip is freed */ void C2F(cintf)(n,ip,op) int *n; int *ip[]; double *op; { int i; for (i = 0; i < *n; i++) op[i]=(double)(*ip)[i]; free((char *)(*ip)); }
For the meaning of #include "../machine.h"
and C2F see 6.3.1.
Then, the user can create its own external types by creating its own C functions with the same arguments. Intersci will generate the call of the function.