|
Re: Guide: how to call Fortran from IDL in a portable and stardard F 2003 way [message #87818 is a reply to message #87809] |
Thu, 27 February 2014 09:34   |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Thursday, February 27, 2014 5:51:08 PM UTC+1, negri...@gmail.com wrote:
> Recently, I felt the necessity (in IDL) of a subroutine that was coded extremely well in Fortran, with a skilled use of nested do loops over some matrices. I though that the time was come to interface IDL and Fortran.
Nowadays I use /AUTO_GLUE in CALL_EXTERNAL. Here is a Fortran 77 example (I used Fortran 30 years ago :-):
test.f:
subroutine test(array, n,m)
integer*4 n, m
real*8 array(n,m)
write(*,*) array
end
gfortran -c -fPIC test.f
gfortran -shared -o test.so test.o
test.pro:
pro test
n=3l
m=4l
array=dindgen(m,n)
trash=call_external('test.so', 'test_', array, n, m, /auto_glue)
end
IDL> test
% Compiled module: TEST.
0.0000000000000000 1.0000000000000000 2.0000000000000000 3.0000000000000000 4.000000000000000
0 5.0000000000000000 6.0000000000000000 7.0000000000000000 8.0000000000000000 9.000000000
0000000 10.000000000000000 11.000000000000000
regards,
Lajos
|
|
|
|