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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: IDL calling a Fortran routines [message #44160] Tue, 24 May 2005 07:58 Go to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Link is part of Visual Studio, but dumpbin works fine too. It seems like the
export is there and its all in capitalized letters. You need to capitalize
'SUM_ARRAY' in your call, its case sensitive.

Haje


<jianguang.guo@gmail.com> wrote in message
news:1116943337.260117.148300@g43g2000cwa.googlegroups.com.. .
> sorry there's no such command as "link/dump/exports new.dll" on my
> platform(win2000+compaq VF),but i think you really want to know this:
>
> F:\FORTRAN\new>dumpbin/exports new.dll
> Microsoft (R) COFF Binary File Dumper Version 6.00.8447
> Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
>
>
> Dump of file new.dll
>
> File Type: DLL
>
> Section contains the following exports for new.dll
>
> 0 characteristics
> 42932E57 time date stamp Tue May 24 21:38:31 2005
> 0.00 version
> 1 ordinal base
> 2 number of functions
> 2 number of names
>
> ordinal hint RVA name
>
> 1 0 00001000 SUM_ARRAY
> 2 1 00001000 _SUM_ARRAY@8
>
> Summary
>
> 1000 .data
> 1000 .rdata
> 1000 .reloc
> 1000 .text
>
> Best regards,
> Jianguang Guo
> Haje Korth wrote:
>> 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"?
>>
>
Re: IDL calling a Fortran routines [message #44161 is a reply to message #44160] Tue, 24 May 2005 07:02 Go to previous messageGo to next message
jianguang.guo is currently offline  jianguang.guo
Messages: 5
Registered: May 2005
Junior Member
sorry there's no such command as "link/dump/exports new.dll" on my
platform(win2000+compaq VF),but i think you really want to know this:

F:\FORTRAN\new>dumpbin/exports new.dll
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Dump of file new.dll

File Type: DLL

Section contains the following exports for new.dll

0 characteristics
42932E57 time date stamp Tue May 24 21:38:31 2005
0.00 version
1 ordinal base
2 number of functions
2 number of names

ordinal hint RVA name

1 0 00001000 SUM_ARRAY
2 1 00001000 _SUM_ARRAY@8

Summary

1000 .data
1000 .rdata
1000 .reloc
1000 .text

Best regards,
Jianguang Guo
Haje Korth wrote:
> 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"?
>
Re: IDL calling a Fortran routines [message #44164 is a reply to message #44161] Tue, 24 May 2005 05:26 Go to previous messageGo to next message
Haje Korth is currently offline  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
>
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 next 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
Re: IDL calling a Fortran routines [message #44176 is a reply to message #44167] Mon, 23 May 2005 11:11 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
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

<jianguang.guo@gmail.com> wrote in message
news:1116859283.041232.74090@o13g2000cwo.googlegroups.com...
> Hi,I'm a new guy for IDL.I want to call a fortran routine from idl.The
> guide of the IDL tell me that the easy way is by using call_external.
> It seems that most examples are under unix or other OS. When I call
> fortran code via C wrapper,I does not know how to get the
> "example.dll"(I try to run the 'example_c2f.c' from the external
> development guide,but fail). I use IDL6.0 under win2000. I hope to get
> some detailed examples on win.Thanks
>
Re: IDL calling a Fortran routines [message #44220 is a reply to message #44176] Fri, 27 May 2005 07:38 Go to previous message
ismxray@yahoo.com is currently offline  ismxray@yahoo.com
Messages: 13
Registered: January 2005
Junior Member
Can we do the same thing on Linux using intel Fortran 8.1 or even gnu
Fortran?
I tried but it cannot recognize the "dll_export".
Re: IDL calling a Fortran routines [message #44228 is a reply to message #44160] Wed, 25 May 2005 20:09 Go to previous message
jianguang.guo is currently offline  jianguang.guo
Messages: 5
Registered: May 2005
Junior Member
bingo,you're right. I get the desired result,thank you very much

cheers,

Jianguang Guo

Haje Korth wrote:
> Link is part of Visual Studio, but dumpbin works fine too. It seems like the
> export is there and its all in capitalized letters. You need to capitalize
> 'SUM_ARRAY' in your call, its case sensitive.
>
> Haje
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Thu Oct 09 06:52:28 PDT 2025

Total time taken to generate the page: 0.96111 seconds