Making and using a DLL consists of three major steps
Let us consider a simple Fortran 77 program
vecsum.f
which sums up a vector:
C2345.7890123456789012345678901234567890123456789012345678901234567890 C C function sum(x, nn, s) double precision nn,s double precision x(nn) integer i,n,sum n=int(nn) s=0.0 do 10 i=0, n s=s+x(i) 10 continue sum=0 return end
The function SUN Solaris/GNU Fortran 77 can be compiled to a
shared library for instance with the GNU Fortran-Compiler
g77 -G -o vecsum.so vecsum.f
from the Unix shell prompt.
To use the DLL in XploRe requires the following simple steps.
x
and initialize the result s
x=1:10 s=0
h=
dlopen
("vecsum.so")
Note that XploRe needs to be able to find this library. From
XploRe you can set the path for DLLs by
setenv
("xpl4dll","/your_absolute_path_to_the_dll")
Alternatively you can give the absolute path within the
dlopen
command.
sum
from the DLL for x
dlcall
("sum_",x, rows(x),s)
As a result you should find s
having the value 55 which
is the sum for the numbers 1 to 10.