C++ and C functions that do not write to global variables or use local variables declared "static" are typically reentrant. Fortran subroutines can present more problems. Some advice:
Variables that appear in a SAVE
statement or are initialized in a DATA
statement are always allocated statically and will corrupt the threaded version.
Make sure no values are assigned to COMMON
block variables in the
subroutines called by fxn
.
If you call Fortran subroutines in fxn
make sure that all local
variables are put on the run-time stack by using the corresponding
compiler option, typically -automatic
. The default behavior is very
likely static allocation. (The GNU Fortran compiler is an exception
to the rule, with automatic allocation being the default. It has an
option -fno-automatic
.)
Note: Static variables (default, -static) are always initialized to
default (or DATA
statement) values before the subroutine is executed.
Variables put on the run-time stack (-automatic
) are NOT initialized
automatically before the subroutine is executed and thus don't have
a well-defined value until they get a value assigned when an assignment
statement is executed. Using uninitialized variables in expressions
(e.g. on the right side of an assignment statement) triggers
floating exception signals in threads.
The following sections contain platform specific notes about writing code and creating excetables with the parallel dVegas libraries. Please report any problems (and solutions) you find when using these libraries, so that we can address them. See section 1.6 for details.
For documented platforms you might want to run make test
and look at the
test programs for the parallel libraries and check out how they are compiled.
-lpthread
.
-pthread
option for all Compaq compilers when compiling or linking.
Use -automatic
when compiling or linking with the Compaq Fortran compiler.