qdyn.testing module¶
Auxilliary routines for testing either the QDYN python package or the QDYN Fortran library
Summary¶
Functions:
Proto-fixture responsible for searching a folder with the same name as a test module and, if available, moving all contents to a temporary directory so tests can use them freely. |
|
Return the name of the MPI implementation that QDYN was configured with (e.g. |
|
Return the name the Fortran compiler that QDYN was compiled with |
|
Generate a proto-fixture to wrap around the tiven util. |
|
Return a modified cmd that runs the given cmd (list) using MPI. |
|
Check whether QDYN was configured with the given feature (e.g. |
Reference¶
-
qdyn.testing.
qdyn_feature
(configure_log, feature)[source]¶ Check whether QDYN was configured with the given feature (e.g. ‘use_mpi’, ‘no-parallel-oct’, ect), given the path to configure.log
-
qdyn.testing.
get_mpi_implementation
(configure_log)[source]¶ Return the name of the MPI implementation that QDYN was configured with (e.g. ‘openmpi’, or None if QDYN was compiled without MPI support
-
qdyn.testing.
get_qdyn_compiler
(configure_log)[source]¶ Return the name the Fortran compiler that QDYN was compiled with
-
qdyn.testing.
mpirun
(cmd, procs=1, implementation='openmpi', hostfile=None)[source]¶ Return a modified cmd that runs the given cmd (list) using MPI.
If hostfile is given, it will be overwritten and used in such a manner as to force the use of the given number of processes.
- Parameters
cmd (list) – list of command args, cf. subprocess.run
procs (int) – Number of MPI processes that should be used
implementation (str) – name of MPI implementation
hostfile (str) – Path to file that should be used as a “hostfile”, forcing MPI to use the specified number of processes even if the MPI environment would not ordinarily allow for it.
-
qdyn.testing.
datadir
(tmpdir, request)[source]¶ Proto-fixture responsible for searching a folder with the same name as a test module and, if available, moving all contents to a temporary directory so tests can use them freely.
-
qdyn.testing.
make_qdyn_utility
(util='qdyn_prop_traj', procs=1, threads=1)[source]¶ Generate a proto-fixture to wrap around the tiven util.
Returns a callable that takes any numer of positional args and any number of kwargs, such that calling it is equivalent to
subprocess.run([cmd, *args], **kwargs)
where
cmd
is the absolute path of the compiled QDYN utility (in theutils
subfolder of the project root, found by traversing up from the directory in which the test is defined).If procs > 1 and QDYN was compiled with MPI support, then
cmd
will bempirun
(or an equivalent suitable MPI runner based on how QDYN was compiled), to run procs simultaneous copies of the util. If threads is > 1, the program will run with multiple OpenMP threads, by setting theOMP_NUM_THREADS
environment variable.The util will also use the development units file by setting
QDYN_UNITS
to theunits_file
folder in the project root.