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

BLOCK DATA in static library

rocketdata
Beginner
1,867 Views
I created a Static Library with a bunch of Fortran routines, and it contains some BLOCK DATA subprograms. When I link the library with my Main program, the BLOCK DATAs don't seem to get included properly (and my program dies). Is there a way of forcing the BLOCK DATAs to be included in the Static Library so that when the main program is created, the BLOCK DATA information gets included properly?
0 Kudos
13 Replies
james1
Beginner
1,867 Views
Try indicating that the block data is external in your code with "external block_dataname" to ensure that the linker knows to go looking for it.

James
0 Kudos
rocketdata
Beginner
1,867 Views
Thanks, that worked! I don't know why I didn't think of that - thanks again...
0 Kudos
douglas_a_pouk
Beginner
1,867 Views

I have the same problem - a BLOCK_DATA (called ATMOS) defined in a static library with another SUBROUTINE that externs it like this

EXTERN

0 Kudos
douglas_a_pouk
Beginner
1,867 Views

I have the same problem - a BLOCK_DATA (called ATMOS) defined in a FORTRAN source compiled into static library with another SUBROUTINE that externs it like this:

EXTERNAL ATMOS

I also tried:

EXTERNAL BLOCK DATA ATMOS

When I run my program the common block initialized by the ATMOS block data unit is empty. All data is ZERO.

The EXTERN statement does not seem to be helping here - are there more details I might be missing? I am linking these FORTRAN libraries from a Win32 Console Application - not a FORTRAN console application - maybe that is the problem?

Thanks if anyone can help :)
Doug
0 Kudos
Steven_L_Intel1
Employee
1,867 Views
EXTERNAL ATMOS is what you want. However, there has been a bug in Intel Visual Fortran 8 where this doesn't work - I'm not sure if it's fixed yet.
0 Kudos
douglas_a_pouk
Beginner
1,867 Views

Thanks Steve -I don't have the latest patches installed - I'll give that a try. I cannot get it to link any which waywith IVF 8.0 out of the box - so hopefully it is fixed in a patch. I'll post a message when I get the patch installed.

cheers

0 Kudos
douglas_a_pouk
Beginner
1,867 Views
Same result with the latest compiler - the BLOCK DATA object contained in a static library does not get found by the linker.
This behaviour worked perfectly with the Compaq Visual Fortran 6.6. So far I am a little disappointed with my testing of IVF8.0 after using CVF6.6 with great success for a year.
I will report this problem to Intel if I can figure out how.
0 Kudos
Steven_L_Intel1
Employee
1,867 Views
The bug isn't fixed yet.
A workaround is this. Select Project..Properties..Link..Input. Under "Force Symbol References", give the name of your BLOCK DATA in uppercase and withtwo preceding underscores, for example, __ATMOS.
I had not realized until I looked at this again that the symbol for the BLOCK DATA has two underscores. I think that is wrong and will report it.
0 Kudos
hansr
Beginner
1,867 Views
Is this bug fixed now with IF 8.21?
In one program of me it seems to work totally without
"Force Symbol References" an double-Underline-Blockdataname.
Hans
0 Kudos
aliho
Beginner
1,867 Views
I remember that this problem occured in Microsoft Fortran Powerstation 1 and was resolved by adding a void subroutine (ATMOS _BLOCK_DATA_INIT for example) in the source file containing the block data and call it from main.
0 Kudos
richman32
Beginner
1,867 Views
Has this issue been fixed? I've having a similar problem with a static library I am trying to compile using Intel Fortran 9.1 in the Visual Studio .NET 2003 IDE. The data initialized in the block data unit does not seem to be available when the library routines are called. How should this work?
0 Kudos
Steven_L_Intel1
Employee
1,867 Views
Yes, it was fixed. Do you have an EXTERNAL in the main program that names the BLOCK DATA subprogram name?
0 Kudos
richman32
Beginner
1,867 Views
I have tried it with the EXTERNAL and it has not seemed to make any difference. I don't really have a main program, just a set of library subroutines. I've tried adding the BLOCK DATA subprogram name to an EXTERNAL statement in the subroutine where I need to reference the common data, but it doesn't seem to initialize.
0 Kudos
Reply