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

Blockdata problems and workrounds in converted CVF project

chris-sn
Beginner
597 Views
I have converted a patricularproject from CVF to VS2008/Intel 11.1.060 using the conversion tool. The result is a C++ wrapper DLL referencing a Fortran static library. (This all being within some larger solution mostly C++ code, which uses the dll and thence the fortran)

When the DLL is entered it transpires that data which used to be initialised by a BLOCKDATA statement in one of the fortran files is no longer initialised correctly. After scanning this forum I found a workround, which is to put the blockdata name preceded by an underscore as en entry in the "Force symbol references" section of the linker input (of the C++ project that is, not the fortran one).

This does indeed solve the problem, but smells like a workround not the correct approach. There was another reference that perhaps the blockdata name should be declared as external. So I tried this - inserting EXTERNAL inside one of the subroutine entry points into the Fortran static library - and this works too.

I'm somewhat confused by what is going on though - I suppose it because the linker is now operating on the C++ project not the FORTRAN one? Is the external declaration the right approach anmd and if so what is the "right" place(s) to insert the external statements. Any advice anyone?
0 Kudos
1 Solution
Steven_L_Intel1
Employee
597 Views
In CVF, the BLOCKDATA object was always explicitly linked in because all the sources were in one project. Now that it is in a library, an external reference is needed to make sure it gets pulled in. Adding EXTERNAL to any of the routines in the Fortran code that is referenced by the C++ code is a good solution.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
598 Views
In CVF, the BLOCKDATA object was always explicitly linked in because all the sources were in one project. Now that it is in a library, an external reference is needed to make sure it gets pulled in. Adding EXTERNAL to any of the routines in the Fortran code that is referenced by the C++ code is a good solution.
0 Kudos
chris-sn
Beginner
597 Views
Understood, thanks.
0 Kudos
Reply