Re: strange linking problem





nicolasbock@xxxxxxxxx wrote:
To make this even stranger, I found that the following modifications to
Parameters.F90 and Main.F90 make both version of the program work


in file Parameters.F90:

MODULE Parameters
   IMPLICIT NONE
   Character (len=100) :: test = "This is a test"
CONTAINS
   subroutine nop ()
     return
   end subroutine nop
END MODULE


in file Main.F90:

PROGRAM Main
  USE Parameters
  IMPLICIT NONE

  write (*, *) "printing test: ", test

END PROGRAM Main

subroutine nopMain ()

  use Parameters
  implicit none

  call nop ()
  return

end subroutine nopMain


No executable code in the module results in no reference from the program to the module object file, so the linker does not bring it in. The "problem" has been known for decades by some who couldn't get their block data to be linked into the program.

.