- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C++:
#include
extern "C" /* this line should be omitted in C */
{
void hello_(long *integ, char *in_str, int in_str_length) {
// must take care of the string since fortran does not provide a
// at the end of the string.
char* str=new char[in_str_length+1];// C++ memory allocation
for (unsigned int i=0; i
str[in_str_length]='';
// normal C/C++ programming here
std::cout << "Hello
";
std::cout << "You passed the following to me:
";
std::cout << "long integer: " << *integ << '
';
std::cout << "string: " << str << '
';
std::cout << "string length: " << in_str_length << "
";
delete[] str;// C++ memory cleanup
}
}
/* Need a small wrapper for the fortran main program, since fortran
code should not be used as the main program, see information
elsewhere */
extern "C" int mymain_();
int main()
{
return mymain_();
}
FORTRAN:
SUBROUTINE MYMAIN
CHARACTER*11 NAME
INTEG=42
NAME='HELLO WORLD'
CALL HELLO(INTEG,NAME)
RETURN
END
Thanks so much for all replys!!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following changes are required to combine a C++ project (.exe) and Fortran library:
* add yourlib.libto C++ linker settings
* add libifcore.lib and ifconsole.lib to C++ linker settings*
* add directories of yourlib and Intel libraries (by default C:Program FilesIntelCompilerFortran9.0IA32Lib) to "Additional Library Directories"**
* specify that project yourexe depends on project yourlib (Project/Dependencies...)
Further, in your current code, you used lowercase on C++ side, but IVF treats external symbols as uppercase by default. So, do one of:
* uppercase "hello" and "mymain" on C++ side
* specify "Lower case" for yourlib in Project/Properties/Fortran/External procedures
* use DEFAULT, ALIAS attributes to lowercase "hello" and "mymain" on Fortran side
Also, get rid of underscores -- they're appended by default.
HTH
Jugoslav
* Actually, you should match C++ run-time library setting and IVF run-time library you're using. See "Intel Fortran/C Mixed-Language Programs Overview" in Mixed-Language chapter of IVF documentation.
** Best, add IVF Lib directory to Tools/Options/Projects/C++ Directories/Library files. That will save you the need to add it in every new project.
Message Edited by JugoslavDujic on 10-14-2005 10:24 AM
Message Edited by JugoslavDujic on 10-14-2005 02:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav
P.S. Post-editing Forum messages with my Mozilla Firefox sometimes leads to unexpected results. Although it's been raised, the Forum does not support the editing tab in Firefox. I still think that Lithium Forum used by Intel is not an optimal solution, as it's the quirkiest one of all forum softwares I've used; too late to change it, but maybe Intel should bitch at the vendor a bit more.
Message Edited by JugoslavDujic on 10-14-2005 02:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mozilla http://www.mozilla.org/releases/mozilla1.7.12/ is the only browser I have used on linux which posts replies successfully on these forums. It even follows hidden links. Linux firefox doesn't work well at all.
Given that the forums are supposed to support linux users, it does seem that more support should be given to standard browsers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav

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