Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Migration to 64-bit compiler

ocean
Beginner
636 Views
I'm migrating a C++/fortran application from the 32- to 64-bit compiler, and I'm looking for information addressing migration issues. I am especially concerned with interface calls from Fortran to C++ (and vice verse)and the use of data structures/common blocks to share data between the two languages.

I'm using IVF 10.0 and VS 2005 on Windows XP (64).

Thanks
0 Kudos
9 Replies
carlls
Beginner
636 Views


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

0 Kudos
TimP
Honored Contributor III
636 Views
Quoting - carlls
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.
Current Fortran iso_c_binding includes data types c_ptr and c_intptr_t, so the compiler knows the storage layout used by the companion C compiler.
0 Kudos
Steven_L_Intel1
Employee
636 Views
The Intel compiler also supports an intrinsic (extension) INT_PTR_KIND() that returns the KIND value of an address-sized integer on the current platform. In addition, if you use the Win32 API modules, there are a variety of definitions in module IFWINTY which provide the correct kind.

I would recommend using ISO_C_BINDING for a portable method.
0 Kudos
jimdempseyatthecove
Honored Contributor III
636 Views

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
0 Kudos
ocean
Beginner
636 Views
The Intel compiler also supports an intrinsic (extension) INT_PTR_KIND() that returns the KIND value of an address-sized integer on the current platform. In addition, if you use the Win32 API modules, there are a variety of definitions in module IFWINTY which provide the correct kind.

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,
0 Kudos
jimdempseyatthecove
Honored Contributor III
636 Views

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
0 Kudos
Steven_L_Intel1
Employee
636 Views
I strongly recommend using "interoperable" types and objects on the Fortran side - declared with BIND(C). This will guarantee that alignment/padding matches that of the C compiler. This will also free you from worrying about name decoration.
0 Kudos
ocean
Beginner
636 Views
I strongly recommend using "interoperable" types and objects on the Fortran side - declared with BIND(C). This will guarantee that alignment/padding matches that of the C compiler. This will also free you from worrying about name decoration.

Thanks to all for the expert advise.
0 Kudos
Reply