Re: IDL calling a Fortran routines [message #44164 is a reply to message #44161] |
Tue, 24 May 2005 05:26   |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Well, let's see. Nothing looks terribly wrong, but it seems the symbol can't
be located within the dll. What do you get if you you type "link /dump
/exports new.dll"?
Haje
<jianguang.guo@gmail.com> wrote in message
news:1116918889.279489.172390@f14g2000cwb.googlegroups.com.. .
> Thank you for your help.I just do by this way,but get the result as
> follow:
> IDL> shlib='F:\RSI\IDL60\DEV\projects\test\new.dll'
> IDL> s=call_external(shlib,'sum_array',x,n_elements(x),sum)
> % CALL_EXTERNAL: Error loading sharable executable.
> Symbol: sum_array, File =
> F:\RSI\IDL60\DEV\projects\test\new.dll
> ERROR_PROC_NOT_FOUND
> % Execution halted at: $MAIN$
>
> The fortran code like this:
> SUBROUTINE SUM_ARRAY(ARGC, ARGV)
>
> !DEC$ ATTRIBUTES DLLEXPORT :: SUM_ARRAY
>
> INTEGER*4 ARGC, ARGV(*)
>
>
> J=LOC(ARGC)
>
>
> CALL SUM_ARRAY1(%VAL(ARGV(1)),%VAL(ARGV(2)),%VAL(ARGV(3)))
>
> RETURN
>
> END
> ! This subroutine is called by SUM_ARRAY and has no
> ! IDL specific code.
>
> SUBROUTINE SUM_ARRAY1(array, n, sum)
>
>
> INTEGER*4 n
> REAL*4 array(n), sum
>
> sum=0.0
> DO i=1,n
> sum = sum + array(i)
> ENDDO
> RETURN
> END
>
> I use IDL6.0 under win2000 with Compaq Visual Fortran 6. There is no
> problem when I compile the fortran code. And I get the new.dll by this
> way:
>
> In the visual development environment, after you open a workspace:
>> From the Project menu, click Settings to display the project settings
> dialog box Click the Fortran tab Select the Library category In the Use
> Fortran Run-Time Libraries box, select DLL.
>
> I do not what happen to my code ,the dll or the fortran code?
>
> Best regards
>
> Jianguang Guo
> Haje Korth wrote:
>> I don't think you even need the c wrapper. I havedone this in the
> past using
>> wrappers in fortran similar to the one below, which works on Lahey
> Fortran.
>> This work on IVF and CVF too, only the DLL_EXPORT statement varies
> between
>> the compilers. Don't forget to tell youe fortran compiler to create a
> dll
>> insted of lib.
>>
>> Cheers, Haje.
>>
>>
>>
>> REAL*4 FUNCTION SUM_ARRAY(ARGC, ARGV)
>>
>> DLL_EXPORT SUM_ARRAY
>>
>> INTEGER*4 ARGC, ARGV(*)
>>
>>
>> J=LOC(ARGC)
>>
>>
>> CALL SUM_ARRAY1(%VAL(ARGV(1)),%VAL(ARGV(2)),%VAL(ARGV(3)))
>>
>>
>> SUM_ARRAY=9.9
>>
>>
>> RETURN
>>
>> END
>
|
|
|