- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using IVF 10.0 and VS 2005 on Windows XP (64).
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am doing the very same thing for a relatively large code base. If you are just using a relatively standard interface where you just talk about pasing parameters via subroutines, the Intel doc does a pretty good job of explaining it. (search for Mixed-Language in the help area)
However if your legacy code "cheated/lied" and used the trick of passing back integers to FORTRAN that were really C pointers you are in fro a treat.
I have solved this two ways:
1) Put the burden back on the C folks and instead of passing back a C ptr let the C library manage an array of pointers (C knows the size) and pass back an offest into that array of C pointers. (Granted we can only pass back a maximum value of a 32 bit int but that seems to be enough)
2) Using the FPP option in the ifort compiler to write code something like
#if PTR64 ! Where PTR64 is a command line define of -DPTR64 for 64bit ptrs
#if F2003
INTEGER (KIND=8) iai1! FORTRAN 2003 standard ( I need to update this but just got Intel FORTRAN
! 11.0 yesterday
#else
INTEGER (KIND=8) iai1 ! Intel 9.1 and lower
#endif
#else
INTEGER (KIND=4) iai1 ! The old style cheat C Ptr is equivilent to a FORTRAN int
#endif
Good luck.
Regards
Carl
- 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
I would recommend using ISO_C_BINDING for a portable method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another potential problem and work around is when compiling C++ on Windows there is an option to enable potential compatibility issues with pointers. You may need to turn this option off in the C++ files that interface with Fortran.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would recommend using ISO_C_BINDING for a portable method.
Thanks to all for your responses.
Are there any issues when it comes to sharing data through data structures (on the c++ side) that map tocommon blocks (on the Fortran side). The 64-bit C++ compiler uses padding to align data structure fields; are there any alignment issues with common block statementson the Fortran side.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may be required to specify the packing and/or alignment such that they are consistent between languages. On the Fortran side this may require the use of SEQUENCE, on the C++ side the use of pack(1), etc...
Another potential problem is the 64-bit platforms tend to want no leading underscore, and 32-bit platforms want leading underscore so there may be a little bit of fixup needed in that area.
Jim Dempsey
- 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
Thanks to all for the expert advise.
- 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