- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have something like this:
Class A
{
{
public:
void CalculateSolution();
void UpdateSolution(int newSolution);
private:
int solution;
}
where CalculateSolution calls a very time-intensive Fortran function. Is there a way the Fortran function can callback to UpdateSolution(int) every once in a while, while it is running? I've read through the mixed language topics, but that only addresses global functions.
If not, I guess I can just create a global function with a pointer to my instance of Class A to do the update?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran can't call C member functions directly - even if you can get the external name, you don't know how to pass the context it wants. Create a regular C++ wrapper function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you mean to switch the C/C++ ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I mean write an "extern" C++ function, callable from Fortran, that calls the member function.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page