strange linking problem



Hello,

the problem I have is a little complicated to describe, well, I wil
give it a try. I wrote a module in f90 (MAC OS X 10.3, IBM XLF
compiler) which defines a character array and assigns a literal string
to it. In another file I use this array. I build my program such that I
make an object file out of the module and link that into the program. I
tried this two ways, first by linking the module by listing the object
file directly on the compiler command line, and second by using a
static library and linking it that way. In the first case, everything
works as I expect it, in the second case the array is empty. Here are
the files:


in file Parameters.F90:

MODULE Parameters
IMPLICIT NONE
Character (len=100) :: test = "This is a test"
END MODULE


in file Main.F90:

PROGRAM Main
USE Parameters
IMPLICIT NONE

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

END PROGRAM Main


The Makefile which produces both versions of the program is

..PHONY : all
all : Main1 Main2

Main1 : Main.o libtest.a
xlf95 -o $@ $< -L. -ltest

Main2 : Main.o Parameters.o
xlf95 -o $@ $^

libtest.a : Parameters.o
ar -rcv libtest.a $^
ranlib libtest.a

Main.o : Parameters.o

%.o : %.F90
xlf95 -qsuffix=f=F90 -o $@ -c $^


Could someone shed some light on this strange problem? Is that
something that is to be expected?

Thanks already, nick

.



Relevant Pages

  • Re: Idea for ECMA/C# Standard - compile time hash for performance
    ... I agree with you the chance of a compiler change is slim, ... and then delegating to the standard hash for fields accessed less frequently. ... or the array lookup which would require the ... > 64-bit architecture) for each enum value that doesn't map to anything. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: will this create additional instance of array?
    ... > implicit none ... This depends on the compiler. ... reference; this can mean either passing by reference, ... the size of array is large and I would like to avoid ...
    (comp.lang.fortran)
  • Re: Q: Checking the size of a non-allocated array?
    ... an actual argument is already invalid ... First note that you don't have an unallocated array in the subroutine. ... it is comparable to disassociated or undefined pointers. ... Obviously the compiler has ...
    (comp.lang.fortran)
  • Re: Windows array allocation problem
    ... array reference has to have a 64-bit index or array subscript triplet? ... to fit in one. ... That assumes, of course, that your compiler ... limits on just about anything. ...
    (comp.lang.fortran)
  • Re: Error handling library
    ... which lets the compiler catch out-of-range usage. ... and assuming that a higher int means "more dangerous error" ... with a comment warning that one is used as an index into the array ... languages while running (an array of languages, ...
    (comp.lang.c)