source ~/.bashrc
conda activate dqc

# Otherwise cdo is not found (for GRIB2)
export PATH="/shared/software/cdo/bin:$PATH"

cd /data/joan/c3s512-wp1-datachecker/dqc_wrapper
QAR_CONF_DIR="/data/joan/c3s512-wp1-datachecker/dqc_wrapper/QAR_dqc/conf"
QAR_RES_DIR="/shared/QAR_dqc/results"
TAG="seasonal*"

let i=1
for check_tests in `ls -1 $QAR_CONF_DIR/$TAG`
do
	zip=`basename $conf | sed s/.ini/.zip/g`

	# Avoid skipping + 8 threads
	if [ ! -f $QAR_RES_DIR/$zip ]; then
       		# Fork
        	cmd="python checker.py $conf"
        	$cmd &

        	# Wait for every 8 threads
        	if (( $i%8 == 0 ));
        	then
        	        wait
        	fi

        	# Increase counter
        	let i=i+1
	fi

done
