Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
11 Views

Corba / C++ Interface

Hi there,
we want to get one of our projects work with Corba. A colleague wrote a C++ lib where he wrote some methods to connect to a name service daemon, start / stop a process and so on. Hedefined some .idlfiles as well to handle the data exchange.

Now I want (my boss told me that I want to do that) to write an interface, so that a fortran program should be a server from which other clients get their data.

I got the fortran serverconnected to the name service and I can start and stop it from another process (in my case a C# GUI). But when it comes to the data exchange, the fortran server crashs.

My problem is (I think) the interface of the routines that handle the data exchange. The following happens on the C++ side:

[bash]/*!
SolverDataSingleValue handler functions
*/
extern "C" typedef int (*ccbl_set_single_value_handler)(double *val);
extern "C" typedef int (*ccbl_get_single_value_handler)(double *val);

/*!
Registers a callback function which is invoked on set/get access of a
SolverDataSingleValue object with a specific key. NULL ptrs for handlers are permitted.
*/
extern "C" int ccbl_on_single_value(char *keyname,ccbl_set_single_value_handler hset,ccbl_get_single_value_handler hget);[/bash]
Now I have to write an interface for themethod"ccbl_on_single_value". Those two handler types are type(c_funptr), arent they?

[bash]integer(C_INT) function ccbl_on_single_value(keyname, hset, hget) bind(C)
use,intrinsic :: ISO_C_BINDING
CHARACTER(KIND=C_CHAR),DIMENSION(*) :: keyname
type(c_funptr) hset, hget
end function ccbl_on_single_value[/bash]
Then I wrote two functions that set / get a double value:

[bash]integer(C_INT) function set_single_value(val) bind(C)
    use,intrinsic :: ISO_C_BINDING
    use globMem
    real(C_DOUBLE) val
        
    print *, 'Set the test value'
    g_test_value = val
    set_single_value = 0
end function set_single_value

integer(C_INT) function get_single_value(val) bind(C)
    use,intrinsic :: ISO_C_BINDING
    use globMem
    real(C_DOUBLE) val
        
    print *, 'Get the test value'
    val = g_test_value
    get_single_value = 0
end function get_single_value [/bash]
g_test_value is defined in the module globMem. In the main program I have an interface for those two functions, then I get the functions addresses and register this single value in the corba system:

[bash]set_test_value = c_funloc(set_single_value)
get_test_value = c_funloc(get_single_value)
    
!   Register Handler
i = ccbl_on_single_value('Testvalue'C, set_test_value, get_test_value)[/bash]
From my C# client I can see, that there is a "Testvalue" available. So this cant be all wrong :-)
But when I want to set or get the value my fortran program crashes without a message.

Im using VS2010 with the latest XE Update 8 compiler on Win7 64.
Ive found this thread, but it didnt helped me (http://software.intel.com/en-us/forums/showthread.php?t=70235&o=a&s=lr)

Thanks in advance,
Markus
0 Kudos
2 Replies
Highlighted
New Contributor II
11 Views

Why was that thread moved to the C++ Forum? Maybe my description was not clear enough :-)

I have a problem to get a C++ lib working with Fortran. I dont know if the C++ experts can help me with that...

Markus
0 Kudos
Highlighted
11 Views

Sorry, I misunderstood the question. Since you reposted in the Fortran forum we'll leave this one alone.
Retired 12/31/2016
0 Kudos