IBM Support

Dollar sign "$" usage with the IBM XL Fortran compiler

Question & Answer


Question

The following XL Fortran program does not perform as expected. Why is that? ----- testpg.f ---- [] program testpg call abc ($10,1) write (6,*) ' should not drop thru CALL ABC ($10,1)' stop 'testpg 1' end subroutine abc (*,in) if (in .eq. 0) then return else return 1 end if end [] ---end of testpg.f ---- > xlf testpg.f ** testpg === End of Compilation 1 === ** abc === End of Compilation 2 === 1501-510 Compilation successful for file testpg.f. > ./a.out should not drop thru CALL ABC ($10,1)

Answer

Some non-XL Fortran compilers interpret dollar ($) syntax as an alternate return specifier. XL Fortran interprets dollar syntax as part of a variable name, so that XL Fortran treats "$123" as a variable name. Both interpretations of dollar syntax are not standards compliant.

In the testcase testpg.f, the CALL statement is interpreted as passing the variable "$10" and the constant "1" to the subroutine "abc". However, the subroutine "abc" is expecting that the dummy arguments are an alternate return specifier and a variable of integer type.

On AIX, the -qextchk option can assist in diagnosing this problem through the "type mismatch" message at link-time.

> xlf -qextchk testpg.f
** testpg   === End of Compilation 1 ===
** abc   === End of Compilation 2 ===
1501-510  Compilation successful for file testpg.f.
ld: 0711-197 ERROR: Type mismatches for symbol: .abc
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

The -qlanglvl option can also help you identify non-standards compliant variables that begin with a dollar sign. For example:

>xlf -qlanglvl=90std testpg.f
"testpg.f", line 2.17: 1518-095 (L) $ is not permitted in a symbolic name in Fortran 95 or Fortran 90.

[{"Product":{"code":"SSB259","label":"XL Fortran Advanced Edition for Linux"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Component":"Compiler","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"}],"Version":"10.1;8.1.0;9.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
24 February 2022

UID

swg21187892