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

Home » Public Forums » archive » intel fortran compiler question on windows.
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
intel fortran compiler question on windows. [message #92392] Mon, 07 December 2015 00:36 Go to next message
Dae-Kyu Shin is currently offline  Dae-Kyu Shin
Messages: 25
Registered: February 2015
Junior Member
Hi

These days i'm working using IDL with Fortran.

Here is the example code

---- fortran 77 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

END


--- C wrapper code ------------
#include <stdio.h>

void sum_array(int argc, void *argv[])

{
extern void sum_array1_();/* Fortran routine */
int *n;
float *s, *f;


f = (float *) argv[0]; /* Array pntr */
n = (int *) argv[1]; /* Get # of elements */
s = (float *) argv[2]; /* Pass back result a parameter */


sum_array1_(f, n, s); /* Compute sum */

}



On linux system i've compile like this using intel compiler

icc -fPIC -c c_code.c
ifort -fPIC -c f_code.f
ifort -shared *.o -o test.so

Next run idl.
x = findgen(10)
sum = 0.0
S = call_external('test.so', $
'sum_array', X, n_elements(X), sum)

it is working




But on windows system.

icl -c c_code.c
ifort -c f_code.f
ifort -dll *.obj -o test.dll

then compile error arise.
"c_code.obj : error LNK2019: sum_array1_~~~~"
"test.dll : fatal error LNK1120:~~~~"

So... what compile options i using for without compile error??


Thanks.
Re: intel fortran compiler question on windows. [message #92397 is a reply to message #92392] Tue, 08 December 2015 07:33 Go to previous message
Dae-Kyu Shin is currently offline  Dae-Kyu Shin
Messages: 25
Registered: February 2015
Junior Member
I found solution.
Corrected c_code
__declspec(dllexport) void sum_array(int argc, void *argv[])




2015년 12월 7일 월요일 오후 5시 36분 29초 UTC+9, Dae-Kyu Shin 님의 말:
> Hi
>
> These days i'm working using IDL with Fortran.
>
> Here is the example code
>
> ---- fortran 77 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
>
> END
>
>
> --- C wrapper code ------------
> #include <stdio.h>
>
> void sum_array(int argc, void *argv[])
>
> {
> extern void sum_array1_();/* Fortran routine */
> int *n;
> float *s, *f;
>
>
> f = (float *) argv[0]; /* Array pntr */
> n = (int *) argv[1]; /* Get # of elements */
> s = (float *) argv[2]; /* Pass back result a parameter */
>
>
> sum_array1_(f, n, s); /* Compute sum */
>
> }
>
>
>
> On linux system i've compile like this using intel compiler
>
> icc -fPIC -c c_code.c
> ifort -fPIC -c f_code.f
> ifort -shared *.o -o test.so
>
> Next run idl.
> x = findgen(10)
> sum = 0.0
> S = call_external('test.so', $
> 'sum_array', X, n_elements(X), sum)
>
> it is working
>
>
>
>
> But on windows system.
>
> icl -c c_code.c
> ifort -c f_code.f
> ifort -dll *.obj -o test.dll
>
> then compile error arise.
> "c_code.obj : error LNK2019: sum_array1_~~~~"
> "test.dll : fatal error LNK1120:~~~~"
>
> So... what compile options i using for without compile error??
>
>
> Thanks.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL_IDLBRIDGE undefined procedure problem
Next Topic: behavior of .CONTINUE executive command, in IDLWAVE

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

Current Time: Wed Oct 08 15:17:21 PDT 2025

Total time taken to generate the page: 0.15943 seconds