Search code examples
fortrangfortransuppress-warningsfortran95

How to get rid of a specific gfortran warning?


I have a warning message which is appearing very frequently in my build log. The warning message is:

Named COMMON block ‘<BLOCK_NAME>’ at (1) shall be of the same size as elsewhere ( <SIZE_1> vs <SIZE_2> bytes)

Is there a flag which will suppress this message? I have tried -Wno-align-commons.


Note: I want to suppress the warning so I can more easily spot new warning messages. Harder to do when you have thousands.


Solution

  • I know that the "question" is about a compiler flag and not an actual fix, but it happens that I just fixed that warning in some legacy code I'm cleaning up, so just to help someone else in the same situation.

    That warning warns you that a common shared memory area has different sizes in different places of your code Like in:

    REAL FUNCTION SAMPLE_TASK(VAR)
    REAL S1, S2
    COMMON /C1/ S1, S2
    ....
    ....
    REAL FUNCTION OTHER_TASK(VAR)
    REAL S1, S2
    COMMON /C1/ S1
    

    So the easiest way to fix it is just to either get rid of useless variables or add the missing ones like this.

    COMMON /C1/ S1, **S1**
    

    Hope it helps :)