On Mon, 21 Jul 2008, David Berry wrote:
>>> And also, the Intel thread checker threw up reports about potential data
>>> races within deuler.f.
>>
>> Looks like that would only be true if some SAVEing is enabled. Wonder what
>> the default in g95 is.
>
> Compiling the following using g95 and no additional options, suggests
> that locals are static:
>
>
> program testf
> call a( 1 )
> call a( 2 )
> end
>
> subroutine a( i )
> if( i .eq. 1 ) fred = 1.234
> write(*,*) fred
> end
>
> In that fred retains it's value of 1.234 on the second call to "a".
That's not a very good test, the memory is probably accessed in the same
way for each call. Try:
program testf
call a( 1 )
call b( 1 )
call a( 2 )
end
subroutine a( i )
if( i .eq. 1 ) fred = 1.234
print *,'a = ', fred
end
subroutine b( i )
if( i .eq. 1 ) fred = 4.321
print *,'b = ', fred
end
That shows:
> ./testf
a = 1.23399997
b = 4.3210001
a = 4.3210001
for me with g77, and also:
> ./testf
a = 1.234
b = 4.321
a = 4.321
for g95. The flag needed for g95 is -fstatic:
> ./testf
a = 1.234
b = 4.321
a = 1.234
Tried some simple array initialisations and they seemed to follow the
correct pattern, so I remain confused about that report from checker.
Just a thought in passing. I wonder if declaring Fortran routines to be
RECURSIVE is actually the right thing to do, that must certainly guarantee
that multiple instances of the same function can work concurrently.
Peter.
|