The following code (named test_common_block1.for) uses a common block; the 64 bit executable created from test_common_block1.for via ftn95 8.10 produces strange results at runtime and strange behaviour when debugging.
Both the strange results and behaviour do **not **occur if compiling a 32 bit executable (with ftn95 8.10) or if deactivating/commenting the common block statement for the 64 bit executable.
Code of progamme test_common_block1.for:
LOGICAL*2 LOGLLT,LOGHSP
COMMON /COMIW2/ LOGLLT
LOGLLT=.FALSE.
LOGHSP=.FALSE.
write(*,*) 'LOGLLT=',LOGLLT,', LOGHSP=',LOGHSP
IF(LOGLLT .OR. LOGHSP) THEN
write(*,*) 'In if: LOGLLT=',LOGLLT,', LOGHSP=',LOGHSP
ENDIF
END
Problem: the 64 bit executable executes the write statement within the second if clause although both LOGLLT and LOGHSP are set to .FALSE.
Moreover when debugging (using sdbg64), line 9 which is 'IF(LOGLLT .OR. LOGHSP) THEN' is not marked with a dot at the leftmost position shown in the debugger.
Now, if I comment out the line with the common block (resulting in file test_common_block2.for), the second print statement is not executed (as I would expect) and the line mentioned above is marked properly with a dot within the debugger.
Code of progamme test_common_block2.for:
LOGICAL*2 LOGLLT,LOGHSP
C COMMON /COMIW2/ LOGLLT
LOGLLT=.FALSE.
LOGHSP=.FALSE.
write(*,*) 'LOGLLT=',LOGLLT,', LOGHSP=',LOGHSP
IF(LOGLLT .OR. LOGHSP) THEN
write(*,*) 'In if: LOGLLT=',LOGLLT,', LOGHSP=',LOGHSP
ENDIF
END
Moreover, if I change the if clause in test_common_block1.for in line 9 from 'IF(LOGLLT .OR. LOGHSP) THEN' to 'IF(LOGLLT) THEN' , resulting in file test_common_block3.for, then the second write statement is not excuted for the 64 bit executable created; however, the debugger sdbg64 does not mark the if clause with a dot. LOGICAL*2 LOGLLT,LOGHSP
COMMON /COMIW2/ LOGLLT
LOGLLT=.FALSE.
LOGHSP=.FALSE.
write(*,*) 'LOGLLT=',LOGLLT,', LOGHSP=',LOGHSP
IF(LOGLLT) THEN
write(*,*) 'In if: LOGLLT=',LOGLLT,', LOGHSP=',LOGHSP
ENDIF
END
Compile statements for file test_common_block1.for: ftn95 /64 test_common_block1.for /debug /link ftn95 test_common_block1.for /debug /link
ftn95 version information: (ftn95 -Vers) Version: 8.10.0 Built: Sat Feb 11 12:23:39 2017
Regards, Dietmar