PDA

View Full Version : Calling CSAPI from Fortran


Solomon
11-29-2007, 08:10 PM
Hello

Is it possible to call CSAPI from Fortran ?
It looks to be incomputable since there is nothing that tells me how big the handle returned by CSAPI_new() should be as a Fortran derived type, nor any easy way to cope with the call by value

Is ClearSpeed going to provide a Fortran binding one day, or should I write my own ?

Solomon

clear-cut
12-03-2007, 09:06 PM
I'm not aware of any current activity by ClearSpeed to produce a Fortran callable version of CSAPI. I would expect it to be fairly straight forward to create an API that meets your particular needs. I'm also under the impression that a recent version of the Fortran standard has added a C calling mechanism.

Solomon
12-03-2007, 09:55 PM
Ok.

I am well aware of the Fortran 2003 standard and the extensions to aid Fortran to call C and vice versa - including the bind(c) attribute for functions and structs and the c_associated() function for checking C null pointers.
CSAPI uses structs for some arguments - I guess I need to find out how big these are so I can create objetcs of sufficent size in Fortran.

Tanner
08-19-2008, 02:02 PM
If an application requires access to the members of a CSAPI structure then the structure is declared in csapi.h. For example: CSAPIVersion, CSAPIStatus, CSAPITransferParam and the CSAPI event structures in csapi_events.h

If an application does not require access to the members of a CSAPI structure then the application only needs to use a pointer to the CSAPI structure. For example: CSAPIState, CSAPIProcess and CSAPISemaphore. It is possible to handle these pointers in Fortran without knowing the size of the structure pointed to.

TwelveMonkeys
08-20-2008, 11:05 AM
It might be simpler (and more useful?) to write a Fortran interface to CSPX. Perhaps based on the C interface, rather than the C++ one. CSPX is open source (although the source is not currently part of the SDK package).