Fortran labeled COMMON can be emulated in C by using a global struct.
Table 11–16 Emulating Labeled COMMON
Fortran COMMON Definition |
C "COMMON" Definition |
||
---|---|---|---|
|
|
Note that the external name established by the C routine must end in an underscore to link with the block created by the Fortran program. Note also that the C directive #pragma pack may be needed to get the same padding as with Fortran.
f95 aligns data in common blocks to at most 4-byte boundaries by default. To obtain the natural alignment for all data elements inside a common block and match the default structure alignment, use -aligncommon=16 when compiling the Fortran routines.