And Marco Lombardi writes:
- Second, I would like to propose a workaround for all guys that (like me)
cannot or do not want to recompile the whole library. The solution, in this
case, is to create two thread-safe versions of the {S,D}LAMCH
functions [...]
A third workaround is to create a LAPACK_INIT() subroutine that must
be called by a single thread before any other LAPACK routines are called
by any thread. An example routine in modern Fortran:
subroutine lapack_init ()
interface
real(kind(0.0)) function slamch (cmach)
character, intent(in):: cmach
end function slamch
real(kind(0.0d0)) function dlamch (cmach)
character, intent(in):: cmach
end function dlamch
end interface
slamch('E')
dlamch('E')
end subroutine lapack_init
The calls to slamch and dlamch initialize the internal SAVE variables
that cause problems.
It is fairly common to have a library initialization routine that must
be called my the "master" before any other thread accesses the library.
Some libraries on some platforms employ linker tricks to insert a call
to the initialization routine at library load time, but that's not at
all portable.
Jason
|