#!/bin/bash set -euo pipefail # Define a function to handle Ctrl+C function handle_ctrl_c() { echo "Ctrl+C pressed; terminating..." # Add cleanup code if needed exit 1 } # Set up a trap to catch Ctrl+C and call the handler function (because of timeout) trap handle_ctrl_c INT # Define the new scenario value new_scenario="something_else" # Define the file containing the configuration config_file=../examples/tandem/2d/bp1_sym.toml config_file_new=../examples/tandem/2d/bp1_sym_new.toml # Use sed to replace the value of the 'scenario' variable # Define a function to handle the timeout error handle_timeout_error() { echo "The command timed out" } function run_tandem() { outputfolder=output_${ncpu}_${mode}_$time_out echo $outputfolder mkdir -p $outputfolder if [ "$mode" = "QDGreen" ]; then echo "gf_checkpoint_prefix = \"gfcp\"" > $config_file_new echo "gf_checkpoint_every_nmins=0.1" >> $config_file_new else echo " " > $config_file_new fi sed "s/fltst_/"$outputfolder"\/fltst_/" $config_file >> $config_file_new echo "done generating " $config_file_new timeout $time_out mpiexec -n $ncpu ./app/tandem $config_file_new --mode $mode --petsc -options_file ../examples/options/lu_mumps.cfg -options_file ../examples/options/rk45.cfg -ts_monitor || handle_timeout_error } rm -rf output* time_out=1000000s ncpus="1 10" ## Mode 1 for ncpu in $ncpus do rm -rf gfcp echo $ncpu mode=QDGreen run_tandem mode=QD run_tandem python ../compare_receivers_tandem.py output_${ncpu}_QDGreen_$time_out output_${ncpu}_QD_$time_out done ## Mode 1 ncpu=4 mode=QDGreen rm -rf gfcp time_out=10s run_tandem ncpu=6 run_tandem ncpu=3 time_out=20s run_tandem ## Mode 2 ncpu=10 time_out=100s run_tandem python ../compare_receivers_tandem.py output_${ncpu}_QDGreen_$time_out output_1_QD_1000000s ## Mode 3 ncpu=5 run_tandem python ../compare_receivers_tandem.py output_${ncpu}_QDGreen_$time_out output_1_QD_1000000s ncpu=2 run_tandem python ../compare_receivers_tandem.py output_${ncpu}_QDGreen_$time_out output_1_QD_1000000s