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

Common Block and static library



I have a question about COMMON block and enclosing the code in static library. The problem is as follows: 

I need to combine in static library some subroutines which uses common block data (code is not written by me). When I call the subroutine from the compiled library (in c++) the matrices defined in common block data have all values equal 0 (values displayed in Fortran subroutine enclosed in library) 

The common block data are used internally inside library. Since I do not want to have access to this block data in C/C++ (but use it internally inside fortran library) should I somehow force compiler to initialize this matrices first? 







0 Kudos
1 Reply
Black Belt Retired Employee

You can use a BLOCK DATA subprogram that initializes the COMMON block. You must then give the name of the BLOCK DATA subprogram in an EXTERNAL statement in each procedure that uses the COMMON. The compiled BLOCK DATA subprogram must also be inserted into the library - it will get pulled in by ld because of the EXTERNALs.

I assume that you don't want zeroes for the initial values.


0 Kudos