- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a program that I am converting from CVF to IVF. This is a C program that calls a FORTRAN function. In addition, the FORTRAN function calls a couple of C functions. On one of these, the return value from the C function being called by FORTRAN does not have the same value as when this was done with CVF. I declae the C function as int _stdcall xxx_()
I'm not sure what settings have changed.
Any ideas.
Thx,
Wes
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this a Visual Studio project that was converted from CVF using the "Extract Compaq Visual Fortran Project Items" tool? On the project property page Fortran..External Procedures, what is the calling convention?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is a project that was "extracted". The calling convention is CVF.
W
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nothing comes to mind right away. When you run it in the debugger and step through the Fortran code, is the return value set to what you expect? Could it be that your program relies on an uninitialized variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The return code is being set properly in the C function, but once it gets to FORTRAN it is not set properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Make sure that the C function's name is declared properly in the caller (with the right type.)
If you can't solve the problem, send a test case to Intel Premier Support.
If you can't solve the problem, send a test case to Intel Premier Support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've been reading about declaring the functions, etc. Do I need to declare things as "C" ?? I saw that in one of the help files.
Is there a document that explains the differences between CVF and IVF when using mixed languages??
Thx,
W
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're compiling with the calling convention set to CVF, there are no differences. You'll want to read Migrating from CVF to Intel Visual Fortran.
As with CVF, you would need to declare the C functions with the C attribute - unless they were defined as __stdcall in the C code. (If you were not using /iface:cvf, you could omit that in some cases.) When I mentioned declaring, I meant datatype, though your problem does sound like a symptom of mismatched calling conventions.
You should also read the chapter on mixed-language programming in the Building Applications manual, though it is really much the same as for CVF.
As with CVF, you would need to declare the C functions with the C attribute - unless they were defined as __stdcall in the C code. (If you were not using /iface:cvf, you could omit that in some cases.) When I mentioned declaring, I meant datatype, though your problem does sound like a symptom of mismatched calling conventions.
You should also read the chapter on mixed-language programming in the Building Applications manual, though it is really much the same as for CVF.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
When we did the transition CVF -> IVF we manually rewrote the interfaces between C and Fortran to enable usage of the new default settings. That is we used __cdecl on theC-side and used the new defaultcref on the Fortran side. The reason we did this is that we think that it is convenient to have exactly the same number of function/subroutine arguments on both sides. This was not the case peviously where strings passed resulted an extra integer on the C-side - the length of the string.
In the long run this approach may be the best as it thus clearly reduces the probability of bugs related to mixed language issues.
Lars Petter

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