#!/bin/bash
echo ' '
echo =============================================================
echo Preparing reference fields, here semi-normed with increased L
echo =============================================================
echo =============================================================
echo Mesh with original L
echo =============================================================
divamesh
cp ./input/param.par ./input/param.par.ori
Filepar=./input/param.par
{
read linecomment
read lc
read linecomment
read icoordchange
read linecomment
read ispec
read linecomment
read ireg
read linecomment
read xori
read linecomment
read yori
read linecomment
read dx
read linecomment
read dy
read linecomment
read nx
read linecomment
read ny
read linecomment
read valex
read linecomment
read snr
read linecomment
read varbak
} < $Filepar
cd input
head -1 param.par.ori > param.par

##echo $lc  5 | ../../bin/multiply.a >> param.par
echo $(echo $lc | awk '{print ($1*5.0)}') >>  param.par


head -7 param.par.ori  | tail -5 >> param.par
echo 3 >> param.par
head -23 param.par.ori   | tail -15 >> param.par

##echo $snr 0.1 | ../../bin/multiply.a >> param.par
echo $(echo $snr | awk '{print ($1*0.1)}') >>  param.par

echo varba >> param.par
echo $varbak $snr | awk '{print 0.1*(1+$2)/(1+0.1*$2)*$1}' >> param.par
cd ..
divacalc
# echo saving reference fields
mv ./input/param.par.ori ./input/param.par
cd divawork
echo Output of results for user
echo ' '
cp -v fort.84 ../output/fieldgher.anl.ref
if [ -f fort.82 ]
then
cp -v fort.82 ../output/valatxyascii.anl.ref
fi
cp -v fort.83 ../output/fieldascii.anl.ref
cp -v fort.71 ../output/fieldatdatapoint.anl.ref
cd ..
echo ' '
echo ==============================================================
echo Finished preparing reference field
echo ==============================================================
