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

Home » Public Forums » archive » 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
IDL calling a Fortran routines [message #44186] Mon, 23 May 2005 07:41 Go to next message
jianguang.guo is currently offline  jianguang.guo
Messages: 5
Registered: May 2005
Junior Member
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 #44214 is a reply to message #44186] Sun, 29 May 2005 11:58 Go to previous message
ismxray@yahoo.com is currently offline  ismxray@yahoo.com
Messages: 13
Registered: January 2005
Junior Member
Probrem solved. there is an extra "_" for the subroutine names
compiled by f90.
Re: IDL calling a Fortran routines [message #44216 is a reply to message #44186] Sat, 28 May 2005 20:36 Go to previous message
ismxray@yahoo.com is currently offline  ismxray@yahoo.com
Messages: 13
Registered: January 2005
Junior Member
I can use intel fortran v8.1 compile the testing program but not g77.
However, when I try to call the subroutine in IDL, I got the following

error messages:
IDL>x=findgen(10)
IDL>sum=0.0
IDL>aa=call_external('example1.so', $
'SUM_ARRAY',x,n_elements(x),sum)

% CALL_EXTERNAL: Error loading sharable executable.
Symbol: SUM_ARRAY, File = example1.so

/home/tangsk/software/idl61/idl_6.1/bin/bin.linux.x86/libidl .so.6.1:
undefined symbol:
SUM_ARRAY

the command to compile is
f90 -c example1.f
f90 -shared -o example1.so example1.o

Did I missed some parameters while compiling? Thanks!


The fortran code is:
c-------------------------------------------------------
SUBROUTINE SUM_ARRAY(argc, argv) !Called by IDL
INTEGER*4 argc, argv(*) !Argc and Argv are integers

j = LOC(argc) !Obtains the number of arguments (argc)
!Because argc is passed by VALUE.

C Call subroutine SUM_ARRAY1, converting the IDL parameters
c to standard FORTRAN, passed by reference arguments:

CALL SUM_ARRAY1(%VAL(argv(1)), %VAL(argv(2)), %VAL(argv(3)))
RETURN
END

c This subroutine is called by SUM_ARRAY and has no
c IDL specific code.
c
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
Re: IDL calling a Fortran routines [message #44219 is a reply to message #44186] Fri, 27 May 2005 09:44 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
On unix you don't have to export anything.Everything should work without the
export statement. The nice thing is though that ivf under linux will still
compile and just ignore the dll_export staement. So one version of the code
compiles on both OS. gnu f should work too, but I don't use it.

Haje


<ismxray@yahoo.com> wrote in message
news:1117204688.370902.38980@g49g2000cwa.googlegroups.com...
> 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 #44224 is a reply to message #44186] Thu, 26 May 2005 05:37 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
I am glad I could help.


<jianguang.guo@gmail.com> wrote in message
news:1117076953.859993.84790@f14g2000cwb.googlegroups.com...
> 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: isurface transparency not showing lines and points
Next Topic: Re: printing IDLgrScene

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

Current Time: Wed Oct 08 15:26:57 PDT 2025

Total time taken to generate the page: 0.00524 seconds