Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Scalar passing ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 5554 of 5919
Post > Topic >>

Scalar passing with call_external

by Brian Larsen <balarsen@[EMAIL PROTECTED] > Mar 20, 2008 at 12:48 PM

All,

I am having a heck of a time with something here.  I am trying to
understand the behavior of a C routine that I am trying to call from
IDL.

Given this C code: (ctest.c)
void ctest ( float a, float b, float *c, float v[3] )
{
   float tmp;
   tmp = a*b;
   v[0] = tmp;
   v[1] = a-b;
   v[2] = a+b;
   *c = 66;
}

And this IDL code: (ctest.pro)
make_dll, 'ctest', 'ctest', 'ctest', compile_directory = '.'
a = 5.
b = 3.
c = [7.]
v = fltarr(3)
ans = call_external('ctest.so', 'ctest', a, b, c, v, /auto_glue, value
= [1, 1, 0, 0])
print, ans, a, b, c, v
end

I expect the output to be:
<undetermined>     5.0     3.0     66.0
     15.0       2.0    8.0

But instead I get:
IDL>  .run ctest
 -1073774376      5.00000      3.00000      7.00000
      15.0000      2.00000      8.00000

So the root of the question is how do I pass scalar information back
out of the C routine to the IDL?  As that looks to be failing.  Anyone
have any useful tips here?

Cheers,

Brian

--------------------------------------------------------------------------
Brian Larsen
Boston University
Center for Space Physics
 




 4 Posts in Topic:
Scalar passing with call_external
Brian Larsen <balarsen  2008-03-20 12:48:29 
Re: Scalar passing with call_external
Allan Whiteford <allan  2008-03-25 09:30:18 
Re: Scalar passing with call_external
Brian Larsen <balarsen  2008-03-25 05:56:14 
Re: Scalar passing with call_external
Trae <traewinter@[EMAI  2008-03-26 07:47:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 5 14:33:55 CDT 2008.