-##-------------------------------- DEFAULT APPLICATION --------------------------------------
-APPLICATIONTMP="$(mktemp smpitmp-appXXXXXX)"
-#APPLICATIONTMP="app.xml"
-
-cat > "${APPLICATIONTMP}" <<APPLICATIONHEAD
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-APPLICATIONHEAD
-
-##---- cache hostnames of hostfile---------------
-if [ -n "${HOSTFILE}" ] && [ -f "${HOSTFILE}" ]; then
- hostnames=$(< "${HOSTFILE}" tr '\n\r' ' ')
-fi
-
-if [ -n "${APP_TRACES}" ]; then
- if [ -f "${APP_TRACES}" ]; then
- hosttraces=$(< "${APP_TRACES}" tr '\n\r' ' ' )
- NUMTRACES=$(< "${APP_TRACES}" wc -l)
- REPLAY=1
- else
- printf "File not found: %s\n" "${APP_TRACES:-\${APP_TRACES\}}" >&2
- exit 1
- fi
-fi
-
-##----------------------------------------------------------
-## generate application.xml with hostnames from hostfile:
-## the name of host_i (1<=i<=p, where -np p) is the line i in hostfile (where -hostfile hostfile), or "host$i" if
-## hostfile has less than i lines.
-##----------------------------------------------------------
-
-HAVE_SEQ="$(which seq 2>/dev/null)"
-
-if [ -n "${HAVE_SEQ}" ]; then
- SEQ=$(${HAVE_SEQ} 0 $(( NUMPROCS - 1)))
-else
- cnt=0
- while [ $cnt -lt "${NUMPROCS}" ] ; do
- SEQ="$SEQ $cnt"
- cnt=$((cnt + 1));
- done
-fi
-
-set -- $hostnames
-
-##---- generate <actor> tags------------------------------
-#prepare arguments at once
-for ARG in $PROC_ARGS; do
- XML_ARGS="${XML_ARGS}""<argument value=\"${ARG}\"/>
-"
-done
-
-for i in ${SEQ}
-do
- j=$(( i % hostfile_procs + 1 ))
- host=$(eval "echo \${$j}")
-
- ##---- optional display of ranks to actor mapping
- if [ ${MAPOPT} = 1 ]; then
- echo "[rank $i] -> $host"
- fi
- {
- echo " <actor host=\"${host}\" function=\"$i\"> <!-- function name used only for logging -->
- <prop id=\"instance_id\" value=\"smpirun\"/>
- <prop id=\"rank\" value=\"$i\"/>"
- if [ ${REPLAY} = 1 ]; then
- echo " <prop id=\"smpi_replay\" value=\"true\"/>"
- if [ "${NUMTRACES}" -gt 1 ]; then
- # Give each process its trace file (as an argument)
- echo " <argument value=\"$(echo "$hosttraces"|cut -d' ' -f$j)\"/>"
- elif [ ${i} = 0 ]; then
- # Give the shared trace file to rank 0 (as a property)
- echo " <prop id=\"tracefile\" value=\"$(echo "$hosttraces"|cut -d' ' -f1)\"/>"
- fi
- else
- echo "${XML_ARGS}"
- fi
- echo " </actor>"
- } >> "${APPLICATIONTMP}"
-done
-
-cat >> "${APPLICATIONTMP}" <<APPLICATIONFOOT
-</platform>
-APPLICATIONFOOT
-##-------------------------------- end DEFAULT APPLICATION --------------------------------------