comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL calling a Fortran routines
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL calling a Fortran routines [message #44167 is a reply to message #44164] Tue, 24 May 2005 00:14 Go to previous messageGo to previous message
jianguang.guo is currently offline  jianguang.guo
Messages: 5
Registered: May 2005
Junior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: help: window content erased after resize
Next Topic: Re: isurface transparency not showing lines and points

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 08:43:11 PDT 2025

Total time taken to generate the page: 0.80464 seconds