[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to call fortran subroution?

web wrote:
Thank you very much. I use IDL under windows.

I have generated vecadd.dll from visual fortran. Then I use

result = call_external('f:\fortran\vecadd.dll','f:\fortran\vecadd ',  a,
n_elements(a), x, n_elements(x), b)

to call the dll. The error message is as following:

% CALL_EXTERNAL: Error loading sharable executable.
                 Symbol: f:\fortran\vecadd, File = f:\fortran\vecadd.dll
But I have dll file under f:\fortran. How to do then? May be I have set
wrong parameter.
This is explanation of call_external:

Result = CALL_EXTERNAL(Image, Entry [, P0, ..., PN-1])

Entry:A string containing the name of the symbol in the library which is the
entry point of the routine to be called.

I donot know how to set entry.

Where can I find The IDL External Development Guide?


"Liam Gumley" <Liam.Gumley@ssec.wisc.edu> wrote in message

For windows with Compaq (Digital) Fortran add the export line to your wrapper subroutine:
      subroutine wvecadd (argc, argv)
      integer argc, argv(*)
      call vecadd(%val(argv(1)), %val(argv(2)), %val(argv(3)), %val(argv(4)))

When you call:
junk = call_external('f:\fortran\vecadd.dll', '_WVECADD@8', p1, p2, p3, p4)

Note the @8 refers to the fact that two pointers are passed to wvecadd for a total of 8 bytes.  The syntax of Call_External makes this suffix true for all Call_external calls on windows.

Note on HP and Sun unix the entries are 'wvecadd' and 'wvecadd_', respectively. You will need to branch if you are writing these routines form multiple platforms.

Good luck.

L. Paul Mix
Distinguished Member of the Technical Staff
Electromagnetics and Plasma Physics Analysis

Sandia National Laboratories
MS 1152, P.O. Box 5800
Albuquerque, NM 87185-1152
E-mail: lpmix@sandia.gov
Phone: (505) 845-7493
FAX: (505) 284-6078