- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- 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
- 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
- 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
These instruction are for mixing C/C++ with F77. I have never used F90 so I don't know anything about it.
What I didn't see anyone post yet was some specific details on how to accomplish this. Now my case is the inverse, C/C++ calling F77, but I would expect it to be the same calling problems.
First, there are multiple calling conventions to choose from plus external name naming conventions. My projects are specifying that the external names are all uppercase. Another thing to look out for is passing of CHARACTER datatype. That is passed as 2 arguments, instead of one, the 2nd one being hidden, so I tell the compilier to put the hidden arguments AFTER the other arguments.
My F77 debug switches for IVF 9.0 are (yes, you asked about IVF 8.1, but I'm at 9.0, so I'm showing what I know):
Intel Visual Fortran 9.0 /nologo /Zi /Od /include:"." /include:".." /include:"...." /f77rtl /intconstant /warn:ignore_loc /warn:truncated_source /Qsave /assume:dummy_aliases /Qzero /names:uppercase /iface:cref /module:"./" /object:"./" /traceback /check:none /libs:static /threads /debug:full /dbglibs /c Microsoft C++ .NET 2003 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_SIMSYS_" /D "_ATL_STATIC_REGISTRY" /D "_MBCS" /FD /EHsc /MTd /GS /GR /Fp".Debug/codeMMSim.pch" /Fo".Debug/" /Fd".Debug/" /FR".Debug/" /W3 /nologo /c /Z7 /D WINVER="0x0400" Linker /OUT:"Debug/myprogram.exe" /INCREMENTAL /NOLOGO /NODEFAULTLIB:"msvcrtd.lib" /NODEFAULTLIB:"msvcprtd.lib" /DELAYLOAD:"OleAcc.dll" /DEBUG /PDB:".Debug/myprogram.pdb" /SUBSYSTEM:WINDOWS /MACHINE:X86 nafxcwd.lib myprogram.lib DelayImp.lib DelayImp.lib
Now your library and include paths will probably differ (I removed mine from this example as you won't have my libraries)
You may also have other switches different from me. For example, I am using /Qsave and /Qzero to initialize all my local variables to zero and make them static as if there was a SAVE statement in each routine.
Don't forget, FORTRAN likes to pass values other than CHARACTER by reference and array subscripts are reversed.
If you are calling FORTRAN fromC++ instead of C, then the header file defining the call needs to be wrapped in the following constructs:
#ifdef __cplusplus extern "C" { #endif . . . your function declarations preceeded with extern #ifdef __cplusplus } #endif
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
void func_name(char* string1, char* string2);
how would i write the interface for it? I was trying something like this
INTERFACE
SUBROUTINE func_name(string1, string2)
!DEC$ ATTRIBUTES C :: func_name
CHARACTER STRING1(*)
CHARACTER STRING2(*)
END SUBROUTINE
END INTERFACE
But it doesn't like this. I realise it's the string length which is the problem but I don't know what the solution is.
Thanks in advance,
Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SUBROUTINE func_name(string1, string2)
!DEC$ ATTRIBUTES C :: func_name
CHARACTER (*) STRING1
CHARACTER (*) STRING2
END SUBROUTINE
END INTERFACE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page