2021-12-15 02:30:47 +01:00
|
|
|
#!/usr/bin/env bash
|
2012-09-05 16:16:20 +02:00
|
|
|
|
|
|
|
# set input/working/output folders
|
|
|
|
in=/Users/daniela/Desktop/scenario_001/files5s
|
|
|
|
work=/Users/daniela/Desktop/scenario_001/tmprzab2
|
|
|
|
out=/Users/daniela/Desktop/scenario_001/outrzab2
|
|
|
|
|
|
|
|
# launching points
|
|
|
|
rmin=690
|
|
|
|
rmax=710
|
|
|
|
dr=5
|
|
|
|
zmin=410
|
|
|
|
zmax=460
|
|
|
|
dz=5
|
|
|
|
|
|
|
|
# steering range
|
|
|
|
amin=20
|
|
|
|
amax=66
|
|
|
|
da=2
|
|
|
|
bmin=18
|
|
|
|
bmax=24
|
|
|
|
db=1
|
|
|
|
|
|
|
|
# check if working folder exists, otherwise create it
|
|
|
|
if [[ ! -e $work ]]; then
|
|
|
|
mkdir $work
|
|
|
|
else
|
|
|
|
if [[ ! -d $work ]]; then
|
|
|
|
echo $work is not a folder.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# move to working folder
|
|
|
|
cd $work
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
echo Cannot move to $work
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if output folder exists, otherwise create it
|
|
|
|
if [[ ! -e $out ]]; then
|
|
|
|
mkdir $out
|
|
|
|
else
|
|
|
|
if [[ ! -d $out ]]; then
|
|
|
|
echo $out is not a folder.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
eqfile=$in/F4E_Equil_10520.eqdsk
|
|
|
|
# look for time value in equil file
|
|
|
|
base=`basename $eqfile .eqdsk`
|
|
|
|
tstr=`echo $base | grep "[[:digit:]]\{5\}" -o`
|
|
|
|
t=`echo "$tstr-10000" | bc`
|
|
|
|
# copy input files in working folder
|
|
|
|
cp $eqfile ${base}.eqdsk
|
|
|
|
cp $in/${base}.prf ${base}.prf
|
|
|
|
|
|
|
|
# set output file names
|
|
|
|
f7file=$out/f7_Rzab_${tstr}.txt
|
|
|
|
rm -f $out/log_Rzab_${tstr}.txt
|
|
|
|
# add header in output file
|
|
|
|
echo "# =============================" > $f7file
|
|
|
|
echo "# `date`" >> $f7file
|
|
|
|
echo "# Loop on launch points" >> $f7file
|
|
|
|
echo "# time=$t" >> $f7file
|
|
|
|
echo "# =============================" >> $f7file
|
|
|
|
appendheader=0
|
|
|
|
#loop on R
|
|
|
|
for (( r0=$rmin; r0<=$rmax ; r0=r0+dr )); do
|
|
|
|
#loop on z
|
|
|
|
for (( z0=$zmin; z0<=$zmax ; z0=z0+dz )); do
|
|
|
|
#loop on beta
|
|
|
|
for (( beta=$bmin; beta<=$bmax ; beta=beta+db )); do
|
|
|
|
#loop on alpha
|
|
|
|
for (( alpha=$amin; alpha<=$amax ; alpha=alpha+da )); do
|
|
|
|
# replace dummy values in template for gray.data
|
|
|
|
sed "s/-alfa-/$alpha/g; \
|
|
|
|
s/-beta-/$beta/g; \
|
|
|
|
s/-x0-/$r0/g; \
|
|
|
|
s/-z0-/$z0/g; \
|
|
|
|
s/-equil-/$base/g; \
|
|
|
|
s/-prf-/$base/g" $in/gray0.data > gray.data
|
|
|
|
# run gray
|
|
|
|
gray >> $out/log_Rzab_${tstr}.txt
|
|
|
|
if (( $appendheader==0 )); then
|
|
|
|
# append parameters to header if first run of the loop
|
|
|
|
cat headers.txt >> $f7file
|
|
|
|
echo "#R z beta alpha`head -n 1 fort.7 | sed 's/#//'`" >> $f7file
|
|
|
|
appendheader=1
|
|
|
|
fi
|
|
|
|
# add time and alpha values in first two columns
|
|
|
|
awk 'NR>1 {print '$r0','$z0','$beta','$alpha',$0}' fort.7 >> $f7file
|
|
|
|
done
|
|
|
|
#end of alpha loop
|
|
|
|
echo " " >> $f7file
|
|
|
|
done
|
|
|
|
#end of beta loop
|
|
|
|
done
|
|
|
|
#end of z loop
|
|
|
|
done
|
|
|
|
#end of R loop
|
|
|
|
|
|
|
|
# remove files from working folder
|
|
|
|
rm ${base}.eqdsk ${base}.prf fort.*
|
|
|
|
|
|
|
|
#EOF
|