- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've recently converted two projects from Visual Studio 6 / Compaq Fortran to Visual Studio 2005 / Intel Fortran 9.1.
The first project isjust fortran with a main program, and it compiles and links to produce a console application executable.
The second project uses the same fortran (without the main program), but has a C++ wrapper, and it compiles and links to produce a COM dll.
Now in the fortran, there are some block data routines, consisting of common blocks with data statements.
When I run the .exe project in debug, I can see that the block data has set numbers in the common blocks. However, when I run the COM dll in debug, the numbers are not in the common blocks. The block data has been ignored.
I got around the problem by simply changing the block data routines into subroutines, and calling the subroutine at the beginning of the calculationi.e calling subroutines with just common blocks and data statements.
I'd really like to understand what's going on though with the block data, and whether there is a better solution.
Thanks in advance.
Andrew
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
Yes, all thefortran source including the block data is in a .lib, with the C++ being the main part of the project. I'll try adding EXTERNALin one of theroutines.
Thanks.
- 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
It worked. By referencing the block data with EXTERNAL in another subroutine, the block data object module got linked into the library.
I understand that block data is not recommeded nowadays, but is this a linker problem? Or is it forcing good practice in making you declaresubprograms that you can't explicitly call?
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So yes, it is good practice to name BLOCK DATA in an EXTERNAL. By the way, I know of no reason that BLOCK DATA should be considered "not recommended", though COMMON is frowned upon by modern language purists who would rather you use module variables. They have a point - if you're writing new code.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page