#!/bin/bash

# tet-file needs both .node and .ele files generated by Tetgen. No file extension is needed
# mag-file: magnetization vectors. format1: <filename> format2: (<magz-x>,<magz-y>,<magz-z>)
# mag-file: line format: <magz-x> <magz-y> <magz-z>
# site-file format: 1. <filename> 2. <xmin>/<xmax>/<ymin>/<ymax>/<z>/<xnum>/<ynum>
# site-file line format: <x> <y> <z>
# obs-file needs only the output file's name with no file extension
# available calculating types: potential, gradient and tensor

logfile=log.txt
execu=./build/bin/magtet
job=${1}

if [[ ${job} == "prism" ]]; then
echo "Executing the job \""${job}"\" by "${execu}
echo "Logging file:" ${logfile}
echo "======================"
cat <<- EOF > ${logfile}
	tet-file  = data/prism/prism.1
	mag-file  = (0,0,200)
	site-file = -30/30/-30/30/10/81/81
	obs-file  = data/prism/prism
	cal-type  = potential gradient tensor
EOF
${execu} ${logfile}

elif [[ ${job} == "pipeline" ]]; then
echo "Executing the job \""${job}"\" by "${execu}
echo "Logging file:" ${logfile}
echo "======================"
cat <<- EOF > ${logfile}
	tet-file  = data/pipeline/pipeline
	mag-file  = data/pipeline/magz.txt
	site-file = data/pipeline/site.txt
	obs-file  = data/pipeline/pipeline
	cal-type  = potential gradient tensor
EOF
${execu} ${logfile}
fi