IDL calling a Fortran routines [message #44186] |
Mon, 23 May 2005 07:41  |
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 #44216 is a reply to message #44186] |
Sat, 28 May 2005 20:36  |
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  |
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  |
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
>
|
|
|