Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29305 Discussions

Linking C++ .NET with Visual Fortran Code...

gummioc3
Beginner
475 Views
Can someone please help me! I am trying to create a small application that will allow FORTRAN code to call C++.NET code. I know FORTRAN and C++ interact, and I have code that will do it, it is very simple, but I want to port that code to C++.NET.
I have found using simple gnu commands how to compile both the C++ and the FORTRAN, and then link them.
My main question is, HOW do I complie/link Visual Fortran code and integrate it into the C++ code?
How do you link the two together in the Visual Enviroments?

Thanks.
0 Kudos
1 Reply
gummioc3
Beginner
475 Views

Here is even simple code that I would like to be able to build in Visual Studio .NET 2003...

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;// strncpy is probably nicer here
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

Any and all help would be appriecated. Thanks so much......

0 Kudos
Reply