diff --git a/test/mpi.jl b/test/mpi.jl index cb30fc91..34bebd41 100644 --- a/test/mpi.jl +++ b/test/mpi.jl @@ -6,18 +6,33 @@ FFTW.set_num_threads(1) # Initialise MPI MPI.Init() +# Define a convenience method to easily replace some parametres +function (p::TDAC.tdac_params)(; kwargs...) + # Extract parameters of the input instance + fields = Dict(name => getfield(p, name) for name in fieldnames(typeof(p))) + for (k, v) in kwargs + # Replace the fields with the new values + fields[k] = v + end + # Return the new instance + return TDAC.tdac_params(; fields...) +end + # Get the number or ranks, so that we can set a number of particle as an integer # multiple of them. my_size = MPI.Comm_size(MPI.COMM_WORLD) +params = TDAC.tdac_params(; nprt = my_size, nobs = 4, padding = 0, enable_timers = true, + verbose = true, n_time_step = 5, nx = 20, ny = 20) + # Warmup rm("tdac.h5"; force = true) -tdac(TDAC.tdac_params(; nprt = my_size, nobs = 4, padding = 0, enable_timers = true, verbose = true)) +tdac(params) # Flush a newline println() # Run the command rm("tdac.h5"; force = true) -tdac(TDAC.tdac_params(; nprt = 2 * my_size, nobs = 36, padding = 0, enable_timers = true, verbose = true)) +tdac(params(; nprt = 2 * my_size, nobs = 36)) # Flush a newline println() diff --git a/test/runtests.jl b/test/runtests.jl index f43e974b..65e18ae3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -200,7 +200,18 @@ end mktempdir() do dir cd(dir) do mpiexec() do cmd - @test success(`$(cmd) -n 2 $(Base.julia_cmd()) $(script)`) + run(`$(cmd) -n 2 $(Base.julia_cmd()) $(script)`) + # This is a dummy test. If `run` exitsts successfully, this + # testset will be successful as well, if `run` errors out this + # testset will error out as well, and the next `@test` will not + # be executed. The advantage over doing something like + # @test success(`...`) + # is that with + # run(`...`) + # @test true + # we can directly see the output of the spawned command, which + # would be suppressed if using `success`. + @test true end end end