stardis-spk

Scripts and datasets for running Stardis simulations
git clone git://git.meso-star.fr/stardis-spk.git
Log | Files | Refs | README | LICENSE

commit 2c04730b3b4976b210f7607f39c67bc77c830438
parent 3cbfd298491eb3653c05c1c945735f8bc455b482
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu,  9 Apr 2026 10:41:48 +0200

Some improvements in writing shell scripts

Use 'printf' instead of 'echo', whose behavior is not standardized,
especially when used with variables.

Redirect error messages to the standard error output.

Diffstat:
Mcity/run_IR_rendering.sh | 15+++++++--------
Mcube/run_dump_path.sh | 20++++++++++----------
Mcube/run_green_evaluation.sh | 49++++++++++++++++++++++++++-----------------------
Mcube/run_probe_computation.sh | 27+++++++++++++--------------
Mheatsink/run_medium_computation.sh | 12++++++------
Mheatsink/run_medium_computation_multiple.sh | 1+
Mporous/run_IR_rendering.sh | 20+++++++++-----------
7 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/city/run_IR_rendering.sh b/city/run_IR_rendering.sh @@ -27,23 +27,22 @@ TARGET="50,30,0" #position targeted FILE=IR_rendering_${MODEL}_${WIDTH}x${HEIGHT}x${SPP} ### END USER PARAMETERS SECTION - #erase FILE result if exists rm -f "${FILE}".ht "${FILE}".ppm #check stardis installation if ! (command -v stardis > /dev/null) then - echo ">>> stardis command not found !" - echo ">>> To register stardis in the current shell you must type :" - echo ">>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile" - echo ">>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation" + >&2 printf '>>> stardis command not found !\n' + >&2 printf '>>> To register stardis in the current shell you must type :\n' + >&2 printf '>>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile\n' + >&2 printf '>>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation\n' exit 1 fi #launch Stardis -stardis -V 3 -M "${MODEL}" -R spp="${SPP}":img="${WIDTH}"x"${HEIGHT}":fov=30:pos="${POSITION}":tgt="${TARGET}":up=0,0,1 > "${FILE}".ht +stardis -V 3 -M "${MODEL}" -R spp="${SPP}":img="${WIDTH}"x"${HEIGHT}":fov=30:pos="${POSITION}":tgt="${TARGET}":up=0,0,1 > "${FILE}".ht -#convert ht file in ppm file +#convert ht file in ppm file htpp -f -o "${FILE}".ppm -v -m default:range=273,275 "${FILE}".ht -echo ">>> You can now watch the IR rendering by opening the file ${FILE}.ppm" +printf '>>> You can now watch the IR rendering by opening the file "%s".ppm\n' "${FILE}" diff --git a/cube/run_dump_path.sh b/cube/run_dump_path.sh @@ -18,7 +18,7 @@ set -e ### USER PARAMETERS SECTION -NPATH=10 +NPATH=10 GEOM_FILE=geom.vtk PATH_FILE_PREFIX=path X=0.5 @@ -32,20 +32,20 @@ rm -f "${GEOM_FILE} ${PATH_FILE_PREFIX}*" #check stardis installation if ! command -v stardis > /dev/null ; then - echo ">>> stardis command not found !" - echo ">>> To register stardis in the current shell you must type :" - echo ">>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile" - echo ">>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation" + >&2 printf '>>> stardis command not found !\n' + >&2 printf '>>> To register stardis in the current shell you must type :\n' + >&2 printf '>>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile\n' + >&2 printf '>>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation\n' exit 1 fi #launch Stardis to dump geometry in vtk format stardis -V 3 -M model.txt -d > "${GEOM_FILE}" -#launch Stardis to dump path for the probe X,Y,Z,TIME +#launch Stardis to dump path for the probe X,Y,Z,TIME stardis -V 3 -M model.txt -p "${X},${Y},${Z},${TIME}" -n "${NPATH}" -D all,"${PATH_FILE_PREFIX}" - -echo " " -echo ">>> You can now visualize the paths in the geometry with opening ${GEOM_FILE} and ${PATH_FILE_PREFIX}xxxxx.vtk files in paraview." -echo " " +printf '\n' +printf '>>> You can now visualize the paths in the geometry with opening %s and %sxxxxx.vtk files in paraview.\n' \ + "${GEOM_FILE}" "${PATH_FILE_PREFIX}" +printf '\n' diff --git a/cube/run_green_evaluation.sh b/cube/run_green_evaluation.sh @@ -18,7 +18,7 @@ set -e ### USER PARAMETERS SECTION -NREAL=10000 +NREAL=10000 X=0.5 Y=0.5 Z=0.5 @@ -29,35 +29,38 @@ SETTINGS_FILE=settings.txt #check stardis installation if ! command -v stardis > /dev/null ; then - echo ">>> stardis command not found !" - echo ">>> To register stardis in the current shell you must type :" - echo ">>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile" - echo ">>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation" + >&2 printf '>>> stardis command not found !' + >&2 printf '>>> To register stardis in the current shell you must type :' + >&2 printf '>>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile' + >&2 printf '>>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation' exit 1 fi if [ -f "${GREEN_FILE}" ]; then - echo " " - echo ">>> ${GREEN_FILE} exists." - echo ">>> Compute probe temperature by applying new source and boundary to the Green function." - echo " " - echo "${SOURCES_AND_BOUNDARIES}" > "${SETTINGS_FILE}" + printf '\n' + printf '>>> %s exists.\n' "${GREEN_FILE}" + printf '>>> Compute probe temperature by applying new source and boundary to the Green function.\n' + printf '\n' + printf '%s\n' "${SOURCES_AND_BOUNDARIES}" > "${SETTINGS_FILE}" sgreen -g "${GREEN_FILE}" -a "${SETTINGS_FILE}" -e - echo " " -else - echo " " - echo ">>> ${GREEN_FILE} does not exist." - echo ">>> Need to compute the Green function with stardis." - echo " " + printf '\n' + +else + printf '\n' + printf '>>> %s does not exist.\n' "${GREEN_FILE}" + printf '>>> Need to compute the Green function with stardis.\n' + printf '\n' + #launch stardis to produce the Green function for the probe X,Y,Z at steady state stardis -M model.txt -p "${X},${Y},${Z}" -n "${NREAL}" -G "${GREEN_FILE}" - echo " " - echo ">>> Now, compute probe temperature by applying new source and boundary to the Green function." - echo " " - echo "${SOURCES_AND_BOUNDARIES}" > "${SETTINGS_FILE}" + + printf '\n' + printf '>>> Now, compute probe temperature by applying new source and boundary to the Green function.\n' + printf '\n' + printf '%s\n' "${SOURCES_AND_BOUNDARIES}" > "${SETTINGS_FILE}" sgreen -g "${GREEN_FILE}" -a "${SETTINGS_FILE}" -e sgreen -g "${GREEN_FILE}" -s "${GREEN_FILE}.html" - echo " " - echo ">>> A html report (${GREEN_FILE}.html) was also produced about the Green function." - echo " " + printf '\n' + printf '>>> A html report (%s.html) was also produced about the Green function.\n' "${GREEN_FILE}" + printf '\n' fi diff --git a/cube/run_probe_computation.sh b/cube/run_probe_computation.sh @@ -23,40 +23,39 @@ TIME="10 50 100 200 300 400" FILE="stardis_result_N${NREAL}.txt" ### END USER PARAMETERS SECTION - #erase FILE result if exists rm -f "${FILE}" #check stardis installation if ! command -v stardis > /dev/null ; then - echo ">>> stardis command not found !" - echo ">>> To register stardis in the current shell you must type :" - echo ">>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile" - echo ">>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation" + >&2 printf '>>> stardis command not found !\n' + >&2 printf '>>> To register stardis in the current shell you must type :\n' + >&2 printf '>>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile\n' + >&2 printf '>>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation\n' exit 1 fi #launch Stardis for each defined TIME -echo "#time Temperature errorbar N_failures N_Realizations" >> "${FILE}" +printf '#time Temperature errorbar N_failures N_Realizations\n' >> "${FILE}" for i in ${TIME}; do -printf '%s ' "${i}" >> "${FILE}" +printf '%s ' "${i}" >> "${FILE}" stardis -V 3 -M model.txt -p 0.5,0.5,0.5,"${i}" -n "${NREAL}" >> "${FILE}" done -echo " " -echo ">>> Stardis simulation done" +printf '\n' +printf '>>> Stardis simulation done\n' printf '>>> Results are writte in %s \n' "${FILE}" -echo " " +printf '\n' #plot result with gnuplot if command -v gnuplot > /dev/null then { - echo "plot 'analytical_T.txt' w l title 'Analytical'" - echo "replot '${FILE}' u 1:2:3 w yerrorbar title 'Stardis'" - echo "pause -1" + printf 'plot '\''analytical_T.txt'\'' w l title '\''Analytical'\''\n' + printf 'replot '\''%s'\'' u 1:2:3 w yerrorbar title '\''Stardis'\''\n' "${FILE}" + printf 'pause -1\n' } > plot.gp gnuplot plot.gp else - echo "gnuplot is not install on your system. You can install gnuplot or view the simulation results in other tool." + >&2 printf 'gnuplot is not install on your system. You can install gnuplot or view the simulation results in other tool.\n' fi diff --git a/heatsink/run_medium_computation.sh b/heatsink/run_medium_computation.sh @@ -27,15 +27,15 @@ rm -f "${GEOM_FILE}" #check stardis installation if ! command -v stardis > /dev/null ; then - echo ">>> stardis command not found !" - echo ">>> To register stardis in the current shell you must type :" - echo ">>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile" - echo ">>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation" + >&2 printf '>>> stardis command not found !\n' + >&2 printf '>>> To register stardis in the current shell you must type :\n' + >&2 printf '>>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile\n' + >&2 printf '>>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation\n' exit 1 fi #launch Stardis to dump geometry in vtk format -stardis -V 3 -M model.txt -d > "${GEOM_FILE}" +#stardis -V 3 -M model.txt -d > "${GEOM_FILE}" #launch Stardis to compute mean temperature in the chip (named SIPw in model.txt) -stardis -V 3 -M model.txt -m SIPw,INF -n "${NREAL}" -e +stardis -V 3 -M model.txt -m SIPw,INF -o2 -n "${NREAL}" -e diff --git a/heatsink/run_medium_computation_multiple.sh b/heatsink/run_medium_computation_multiple.sh @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +set -e ### USER PARAMETERS SECTION NREAL=1000 diff --git a/porous/run_IR_rendering.sh b/porous/run_IR_rendering.sh @@ -18,31 +18,29 @@ set -e ### USER PARAMETERS SECTION -SPP=32 #samples per pixel +SPP=32 #samples per pixel WIDTH=320 HEIGHT=320 -POSITION="0.05,0.01,0" #camera position -TARGET="0,0,0" #position targeted +POSITION="0.05,0.01,0" #camera position +TARGET="0,0,0" #position targeted FILE="IR_rendering_${WIDTH}x${HEIGHT}x${SPP}" ### END USER PARAMETERS SECTION - #erase FILE result if exists rm -f "${FILE}.ht ${FILE}.ppm" #check stardis installation if ! command -v stardis > /dev/null ; then - echo ">>> stardis command not found !" - echo ">>> To register stardis in the current shell you must type :" - echo ">>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile" - echo ">>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation" + >&2 printf '>>> stardis command not found !\n' + >&2 printf '>>> To register stardis in the current shell you must type :\n' + >&2 printf '>>> . ~/Stardis-XXX-GNU-Linux64/etc/stardis.profile\n' + >&2 printf '>>> where ~/Stardis-XXX-GNU-Linux64 is the stardis directory installation\n' exit 1 fi #launch Stardis stardis -V 3 -M porous.txt -R spp="${SPP}":img="${WIDTH}"x"${HEIGHT}":fov=30:pos="${POSITION}":tgt="${TARGET}":up=0,0,1 > "${FILE}".ht - -#convert ht file in ppm file +#convert ht file in ppm file htpp -f -o "${FILE}.ppm" -v -m default:range=650,850 "${FILE}.ht" -echo ">>> You can now watch the IR rendering by opening the file ${FILE}.ppm" +printf '>>> You can now watch the IR rendering by opening the file "%s.ppm"\n' "${FILE}"